Merge branch 'extra-server-tests' into 'main'
Added a few extra tests in RecipeControllerTest See merge request cse1105/2025-2026/teams/csep-team-76!90
This commit is contained in:
commit
f1fc55f674
1 changed files with 55 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ import server.service.RecipeService;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.LongStream;
|
||||
|
|
@ -127,6 +128,60 @@ public class RecipeControllerTest {
|
|||
.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("test-from-init-data")
|
||||
public void getRecipesWithNegativeLimit(){
|
||||
assertEquals(0,
|
||||
controller.getRecipes(Optional.empty(),
|
||||
Optional.of(-2),
|
||||
Optional.of(List.of("en")))
|
||||
.getBody().size());
|
||||
|
||||
}
|
||||
@Test
|
||||
@Tag("test-from-init-data")
|
||||
public void getRecipesWithSearch() {
|
||||
|
||||
recipeRepository.save(new Recipe(
|
||||
null,
|
||||
"banana pie",
|
||||
"en",
|
||||
List.of(),
|
||||
List.of()));
|
||||
|
||||
assertEquals(1, controller.getRecipes(
|
||||
Optional.of("banana"),
|
||||
Optional.empty(),
|
||||
Optional.of(List.of("en"))).getBody().size());
|
||||
|
||||
assertEquals("banana pie", Objects.requireNonNull(controller.getRecipes(
|
||||
Optional.of("banana"),
|
||||
Optional.empty(),
|
||||
Optional.of(List.of("en"))).getBody()).getFirst().getName());
|
||||
}
|
||||
@Test
|
||||
@Tag("test-from-init-data")
|
||||
public void getRecipesWithZeroLimit() {
|
||||
assertEquals(0, controller.getRecipes(
|
||||
Optional.empty(),
|
||||
Optional.of(0),
|
||||
Optional.of(List.of("en"))).getBody().size());
|
||||
}
|
||||
@Test
|
||||
@Tag("test-from-init-data")
|
||||
public void getRecipesWithEmptySearch() {
|
||||
var response = controller.getRecipes(
|
||||
Optional.of(" "),
|
||||
Optional.empty(),
|
||||
Optional.of(List.of("en"))
|
||||
);
|
||||
assertEquals(recipes.size(), response.getBody().size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@Tag("test-from-init-data")
|
||||
public void getSomeRecipes() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue