feat: language in recipes

This commit is contained in:
Natalia Cholewa 2026-01-09 14:54:42 +01:00
commit 74b6f25e24
6 changed files with 86 additions and 12 deletions

View file

@ -64,7 +64,7 @@ public class RecipeControllerTest {
public void setup(TestInfo info) {
recipes = LongStream
.range(0, NUM_RECIPES)
.mapToObj(x -> new Recipe(null, "Recipe " + x, List.of(), List.of()))
.mapToObj(x -> new Recipe(null, "Recipe " + x, "en", List.of(), List.of()))
.toList();
controller = new RecipeController(
recipeService,
@ -107,7 +107,7 @@ public class RecipeControllerTest {
@Tag("test-from-init-data")
public void getManyRecipes() {
// The number of recipes returned is the same as the entire input list
assertEquals(recipes.size(), controller.getRecipes(Optional.empty()).getBody().size());
assertEquals(recipes.size(), controller.getRecipes(Optional.empty(), Optional.empty()).getBody().size());
}
@Test
@ -115,7 +115,29 @@ public class RecipeControllerTest {
public void getSomeRecipes() {
final int LIMIT = 5;
// The number of recipes returned is the same as the entire input list
assertEquals(LIMIT, controller.getRecipes(Optional.of(LIMIT)).getBody().size());
assertEquals(LIMIT, controller.getRecipes(Optional.empty(), Optional.of(LIMIT)).getBody().size());
}
@Test
@Tag("test-from-init-data")
public void getManyRecipesWithLocale() {
// The number of recipes returned is the same as the entire input list
assertEquals(recipes.size(), controller.getRecipes(Optional.of(List.of("en", "nl")), Optional.empty()).getBody().size());
}
@Test
@Tag("test-from-init-data")
public void getNoRecipesWithLocale() {
// should have NO Dutch recipes (thank god)
assertEquals(0, controller.getRecipes(Optional.of(List.of("nl")), Optional.empty()).getBody().size());
}
@Test
@Tag("test-from-init-data")
public void getSomeRecipesWithLocale() {
final int LIMIT = 5;
// The number of recipes returned is the same as the entire input list
assertEquals(LIMIT, controller.getRecipes(Optional.of(List.of("en", "nl")), Optional.of(LIMIT)).getBody().size());
}
@Test