diff --git a/client/src/test/java/client/ServerUtilsTest.java b/client/src/test/java/client/ServerUtilsTest.java index 74c92c7..fe16ba3 100644 --- a/client/src/test/java/client/ServerUtilsTest.java +++ b/client/src/test/java/client/ServerUtilsTest.java @@ -25,7 +25,8 @@ class ServerUtilsTest { ); static final List testIngredients = List.of( new VagueIngredient(ingredients.get(0), "2 pieces of"), - new VagueIngredient(ingredients.get(1), "1 slice of") + new VagueIngredient(ingredients.get(1), "1 slice of"), + new VagueIngredient(ingredients.get(2), "1 slice of") ); final int fakeId = -1; // If suppose ID's are only positive @@ -35,11 +36,6 @@ class ServerUtilsTest { Assumptions.assumeTrue(dv.isServerAvailable(), "Server not available"); - //Making sure there is no recipe in the backend yet - for (Recipe recipe : dv.getRecipes()) { - dv.deleteRecipe(recipe.getId()); - } - Recipe r = new Recipe(); r.setName("Tosti"); @@ -92,7 +88,7 @@ class ServerUtilsTest { assertEquals(testRecipe.getId(), r.getId()); assertEquals("Tosti", r.getName()); - assertIterableEquals(List.of("Bread", "Cheese", "Ham"), r.getIngredients()); + assertIterableEquals(testIngredients, r.getIngredients()); assertIterableEquals(List.of("Step 1:", "Step 2"), r.getPreparationSteps()); } diff --git a/client/src/test/java/client/scenes/PrintExportTest.java b/client/src/test/java/client/scenes/PrintExportTest.java index 897c88d..e63ab3d 100644 --- a/client/src/test/java/client/scenes/PrintExportTest.java +++ b/client/src/test/java/client/scenes/PrintExportTest.java @@ -2,7 +2,10 @@ package client.scenes; import client.utils.PrintExportService; import client.utils.ServerUtils; +import commons.Ingredient; import commons.Recipe; +import commons.RecipeIngredient; +import commons.VagueIngredient; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +21,9 @@ import static org.junit.jupiter.api.Assertions.*; public class PrintExportTest { static ServerUtils dv = new ServerUtils(); + private VagueIngredient getVague(String name) { + return new VagueIngredient(new Ingredient(name, 0., 0., 0.), "some"); + } @BeforeEach public void setup(){ Assumptions.assumeTrue(dv.isServerAvailable(), "Server not available"); @@ -25,9 +31,9 @@ public class PrintExportTest { @Test public void buildRecipeTextTest(){ - List ingredients = new ArrayList<>(); - ingredients.add("Banana"); - ingredients.add("Bread"); + List ingredients = new ArrayList<>(); + ingredients.add(getVague("Banana")); + ingredients.add(getVague("Bread")); final long testRecipeId = 1234L; List preparationSteps = new ArrayList<>(); preparationSteps.add("Mix Ingredients"); @@ -37,7 +43,7 @@ public class PrintExportTest { assertEquals(""" Title: Banana Bread Recipe ID: 1234 - Ingredients: Banana, Bread,\s + Ingredients: some Banana, some Bread,\s Steps: 1: Mix Ingredients 2: Heat in Oven