Skip to content

Commit ba08b1e

Browse files
author
Mohamed
committed
Fix: Modified tests to closer fit the needs
1 parent a960458 commit ba08b1e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lesson_16/api/api_app/src/test/java/com/codedifferently/lesson16/web/PatronControllerTest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void testController_getsAllPatrons() throws Exception {
5454
.perform(get("/patrons").contentType(MediaType.APPLICATION_JSON))
5555
.andExpect(status().isOk())
5656
.andExpect(jsonPath("$.patrons").isArray())
57-
.andExpect(jsonPath("$.patrons.length()").value(5));
57+
.andExpect(jsonPath("$.patrons.length()").value(4));
5858
}
5959

6060
@Test
@@ -139,14 +139,10 @@ void testController_deletesPatron() throws Exception {
139139
}
140140

141141
UUID getGuestId(List<LibraryGuest> list) {
142-
if (list.get(0).getCheckedOutMediaItems().size() == 0) {
143-
return list.get(0).getId();
144-
} else if (list.get(1).getCheckedOutMediaItems().size() == 0) {
145-
return list.get(1).getId();
146-
} else if (list.get(2).getCheckedOutMediaItems().size() == 0) {
147-
return list.get(2).getId();
148-
} else if (list.get(3).getCheckedOutMediaItems().size() == 0) {
149-
return list.get(3).getId();
142+
for (LibraryGuest guest : list) {
143+
if (guest.getCheckedOutMediaItems().size() == 0) {
144+
return guest.getId();
145+
}
150146
}
151147
return list.get(4).getId();
152148
}

0 commit comments

Comments
 (0)