diff --git a/client/src/main/java/client/DetailView.java b/client/src/main/java/client/DetailView.java index b67de78..2989bdb 100644 --- a/client/src/main/java/client/DetailView.java +++ b/client/src/main/java/client/DetailView.java @@ -45,7 +45,7 @@ public class DetailView { * @param id every recipe has it's unique id * @return a singe recipe with the given id */ - public Recipe findId(int id) throws IOException, InterruptedException { + public Recipe findId(long id) throws IOException, InterruptedException { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(BASE_URL+"/" + id)) .GET() diff --git a/client/src/test/java/client/DetailViewTest.java b/client/src/test/java/client/DetailViewTest.java index dc6b417..24d3a0e 100644 --- a/client/src/test/java/client/DetailViewTest.java +++ b/client/src/test/java/client/DetailViewTest.java @@ -11,12 +11,21 @@ import static org.junit.jupiter.api.Assertions.*; class DetailViewTest { static DetailView dv; + static Recipe testRecipe; @BeforeAll - static void setup() { + static void setup(){ dv = new DetailView(); + + Recipe r = new Recipe(); + r.setName("Tosti"); + r.setIngredients(List.of("Bread", "Cheese", "Ham")); + r.setPreparationSteps(List.of("Step 1:", "Step 2")); + +// testRecipe = dv.create(r); } + @Test void findAll() throws IOException, InterruptedException { List recipes = dv.findAll(); @@ -26,5 +35,12 @@ class DetailViewTest { } - + @Test + void findRecipeWithIDTest() throws IOException, InterruptedException { + Recipe r = dv.findId(testRecipe.getId()); + assertEquals(testRecipe.getId(), r.getId()); + assertEquals("Tosti", r.getName()); + assertIterableEquals(List.of("Bread", "Cheese", "Ham"), r.getIngredients()); + assertIterableEquals(List.of("Step 1: ", "Step 2: "), r.getPreparationSteps()); + } } \ No newline at end of file