WIP: non working findRecipeWithIDTest, need create button

This commit is contained in:
Mei Chang van der Werff 2025-11-26 17:14:21 +01:00
commit ce4d1945ef
2 changed files with 19 additions and 3 deletions

View file

@ -45,7 +45,7 @@ public class DetailView {
* @param id every recipe has it's unique id * @param id every recipe has it's unique id
* @return a singe recipe with the given 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() HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL+"/" + id)) .uri(URI.create(BASE_URL+"/" + id))
.GET() .GET()

View file

@ -11,12 +11,21 @@ import static org.junit.jupiter.api.Assertions.*;
class DetailViewTest { class DetailViewTest {
static DetailView dv; static DetailView dv;
static Recipe testRecipe;
@BeforeAll @BeforeAll
static void setup(){ static void setup(){
dv = new DetailView(); 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 @Test
void findAll() throws IOException, InterruptedException { void findAll() throws IOException, InterruptedException {
List<Recipe> recipes = dv.findAll(); List<Recipe> 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());
}
} }