refactor(test/client): refactor client-side tests
This commit is contained in:
parent
73c42303c4
commit
c0add049be
2 changed files with 13 additions and 11 deletions
|
|
@ -25,7 +25,8 @@ class ServerUtilsTest {
|
||||||
);
|
);
|
||||||
static final List<RecipeIngredient> testIngredients = List.of(
|
static final List<RecipeIngredient> testIngredients = List.of(
|
||||||
new VagueIngredient(ingredients.get(0), "2 pieces 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
|
final int fakeId = -1; // If suppose ID's are only positive
|
||||||
|
|
||||||
|
|
@ -35,11 +36,6 @@ class ServerUtilsTest {
|
||||||
|
|
||||||
Assumptions.assumeTrue(dv.isServerAvailable(), "Server not available");
|
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();
|
Recipe r = new Recipe();
|
||||||
|
|
||||||
r.setName("Tosti");
|
r.setName("Tosti");
|
||||||
|
|
@ -92,7 +88,7 @@ class ServerUtilsTest {
|
||||||
|
|
||||||
assertEquals(testRecipe.getId(), r.getId());
|
assertEquals(testRecipe.getId(), r.getId());
|
||||||
assertEquals("Tosti", r.getName());
|
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());
|
assertIterableEquals(List.of("Step 1:", "Step 2"), r.getPreparationSteps());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@ package client.scenes;
|
||||||
|
|
||||||
import client.utils.PrintExportService;
|
import client.utils.PrintExportService;
|
||||||
import client.utils.ServerUtils;
|
import client.utils.ServerUtils;
|
||||||
|
import commons.Ingredient;
|
||||||
import commons.Recipe;
|
import commons.Recipe;
|
||||||
|
import commons.RecipeIngredient;
|
||||||
|
import commons.VagueIngredient;
|
||||||
import org.junit.jupiter.api.Assumptions;
|
import org.junit.jupiter.api.Assumptions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
@ -18,6 +21,9 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class PrintExportTest {
|
public class PrintExportTest {
|
||||||
static ServerUtils dv = new ServerUtils();
|
static ServerUtils dv = new ServerUtils();
|
||||||
|
private VagueIngredient getVague(String name) {
|
||||||
|
return new VagueIngredient(new Ingredient(name, 0., 0., 0.), "some");
|
||||||
|
}
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup(){
|
public void setup(){
|
||||||
Assumptions.assumeTrue(dv.isServerAvailable(), "Server not available");
|
Assumptions.assumeTrue(dv.isServerAvailable(), "Server not available");
|
||||||
|
|
@ -25,9 +31,9 @@ public class PrintExportTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void buildRecipeTextTest(){
|
public void buildRecipeTextTest(){
|
||||||
List<String> ingredients = new ArrayList<>();
|
List<RecipeIngredient> ingredients = new ArrayList<>();
|
||||||
ingredients.add("Banana");
|
ingredients.add(getVague("Banana"));
|
||||||
ingredients.add("Bread");
|
ingredients.add(getVague("Bread"));
|
||||||
final long testRecipeId = 1234L;
|
final long testRecipeId = 1234L;
|
||||||
List<String> preparationSteps = new ArrayList<>();
|
List<String> preparationSteps = new ArrayList<>();
|
||||||
preparationSteps.add("Mix Ingredients");
|
preparationSteps.add("Mix Ingredients");
|
||||||
|
|
@ -37,7 +43,7 @@ public class PrintExportTest {
|
||||||
assertEquals("""
|
assertEquals("""
|
||||||
Title: Banana Bread
|
Title: Banana Bread
|
||||||
Recipe ID: 1234
|
Recipe ID: 1234
|
||||||
Ingredients: Banana, Bread,\s
|
Ingredients: some Banana, some Bread,\s
|
||||||
Steps:
|
Steps:
|
||||||
1: Mix Ingredients
|
1: Mix Ingredients
|
||||||
2: Heat in Oven
|
2: Heat in Oven
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue