WIP: non working findRecipeWithIDTest, need create button
This commit is contained in:
parent
d0b35deb0f
commit
ce4d1945ef
2 changed files with 19 additions and 3 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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<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());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue