From 2d3dcd5bf43633c480be11bf6933c19d605fb373 Mon Sep 17 00:00:00 2001 From: Lara Blersch <lb210@hdm-stuttgart.de> Date: Tue, 16 Jan 2024 15:16:27 +0100 Subject: [PATCH] finished WishListRepositoryTest --- .../repositories/WishListRepositoryTest.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/test/java/hdm/mi/growbros/repositories/WishListRepositoryTest.java b/src/test/java/hdm/mi/growbros/repositories/WishListRepositoryTest.java index ea42d2d..8926d4c 100644 --- a/src/test/java/hdm/mi/growbros/repositories/WishListRepositoryTest.java +++ b/src/test/java/hdm/mi/growbros/repositories/WishListRepositoryTest.java @@ -77,4 +77,44 @@ public class WishListRepositoryTest { we4 = WishListEntry.builder().id(0L).plant(p3).user(user2).build(); underTest.saveAll(List.of(we1, we2, we3, we4)); } + + @Test + void shouldReturnCorrectList_ofEntriesForUser_orderedByNearestPlantingWeek() { + //when + var result = underTest.findAllByNearestPlantingWeek(user1, 1); + + //expect + assertEquals(List.of(we1, we2, we3), result); + } + + @Test + void shouldReturnCorrectList_ofEntriesForUser_orderedByCurrentPlantingWeek() { + //when + var result = underTest.findByCurrentPlantingWeek(user1, 1); + + //expect + assertEquals(List.of(we1), result); + } + + @Test + void shouldDeleteCorrectEntries_whenClearingGarden_forUser() { + //when + int deleted = underTest.deleteAllByUser(user2); + + //expect + assertEquals(1, deleted); + assertEquals(List.of(), underTest.findByUser(user2)); + assertThat(List.of(we1, we2, we3)).hasSameElementsAs(underTest.findByUser(user1)); + } + + @Test + void countShouldBeCorrect_forUser() { + //when + int user1Count = underTest.countByUser(user1); + int user2Count = underTest.countByUser(user2); + + //expect + assertEquals(3, user1Count); + assertEquals(1, user2Count); + } } -- GitLab