diff options
| author | benal01 <bja4245@rit.edu> | 2025-03-30 16:45:38 -0400 | 
|---|---|---|
| committer | benal01 <bja4245@rit.edu> | 2025-03-30 16:45:38 -0400 | 
| commit | 44323effa5ebdbf5146d028aa4d966cbb87a7f58 (patch) | |
| tree | 621e12fcfc14b18e4eed518d1f9bc1f73a7f371d /ufund-api/src/test/java/com/ufund/api/ufundapi/service | |
| parent | 5eba2e924c57a7771c002fa3833beb5ed4275fd2 (diff) | |
| parent | 01667682d27a7f3a094cd24fe4fe2c2a2f503660 (diff) | |
| download | JellySolutions-44323effa5ebdbf5146d028aa4d966cbb87a7f58.tar.gz JellySolutions-44323effa5ebdbf5146d028aa4d966cbb87a7f58.tar.bz2 JellySolutions-44323effa5ebdbf5146d028aa4d966cbb87a7f58.zip  | |
Merge branch 'list-and-cupboard-component-refactor' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b-jellysolutions into list-and-cupboard-component-refactor
Diffstat (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/service')
| -rw-r--r-- | ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java | 85 | 
1 files changed, 49 insertions, 36 deletions
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java index 05ea2e8..f3cbc23 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java @@ -36,16 +36,18 @@ public class CupboardServiceTest {      public void testCreateNeed() throws IOException, DuplicateKeyException {          // Setup          String name = "Jellyfish"; -        double maxGoal = 100.00; -        GoalType type = GoalType.MONETARY; -        Need need = new Need(name, type, maxGoal); +        String location = "Atlantis"; +        double maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          // When the same id is passed in, our mock User DAO will return the User object          when(mockCupboardDAO.addNeed(any())).thenReturn(need);          when(mockCupboardDAO.getNeeds()).thenReturn(new Need[0]);          // Invoke -        Need response = cupboardService.createNeed(name, maxGoal, type); +        Need response = cupboardService.createNeed(name, location, maxGoal, type, urgent);          // Analyze          assertNotNull(response); @@ -56,9 +58,11 @@ public class CupboardServiceTest {      public void testCreateNeedBadGoal() throws IOException {          // Setup          String name = "Jellyfish"; -        double maxGoal = -100.00; -        GoalType type = GoalType.MONETARY; -        Need need = new Need(name, type, maxGoal); +        String location = "Atlantis"; +        double maxGoal = -100.0; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          // When the same id is passed in, our mock User DAO will return the User object          when(mockCupboardDAO.addNeed(any())).thenReturn(need); @@ -69,16 +73,18 @@ public class CupboardServiceTest {          // Analyze          assertThrows(IllegalArgumentException.class, () -> -                cupboardService.createNeed(name, maxGoal, type)); +                cupboardService.createNeed(name, location, maxGoal, type, urgent));      }      @Test      public void testCreateNeedDuplicate() throws IOException {          // Setup          String name = "Jellyfish"; -        double maxGoal = 100.00; -        GoalType type = GoalType.MONETARY; -        Need need = new Need(name, type, maxGoal); +        String location = "Atlantis"; +        double maxGoal = 100.0; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          Need[] needs = { need };          // When the same id is passed in, our mock User DAO will return the User object @@ -90,16 +96,18 @@ public class CupboardServiceTest {          // Analyze          assertThrows(DuplicateKeyException.class, () -> -                cupboardService.createNeed(name, maxGoal, type)); +                cupboardService.createNeed(name, location, maxGoal, type, urgent));      }      @Test      public void testSearchNeeds() throws IOException {          // Setup          String name = "Jellyfish"; -        double maxGoal = 100.00; -        GoalType type = GoalType.MONETARY; -        Need need = new Need(name, type, maxGoal); +        String location = "Atlantis"; +        double maxGoal = 100.0; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          Need[] needs = { need };          // When the same id is passed in, our mock User DAO will return the User object @@ -117,9 +125,11 @@ public class CupboardServiceTest {      public void testSearchNeedsFail() throws IOException {          // Setup          String name = "Jellyfish"; -        double maxGoal = 100.00; -        GoalType type = GoalType.MONETARY; -        Need need = new Need(name, type, maxGoal); +        String location = "Atlantis"; +        double maxGoal = 100.0; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          Need[] needs = { need };          // When the same id is passed in, our mock User DAO will return the User object @@ -136,16 +146,17 @@ public class CupboardServiceTest {      public void testGetNeed() throws IOException {          // Setup          String name = "Jellyfish"; -        double maxGoal = 100.00; -        int id = 0; -        GoalType type = GoalType.MONETARY; -        Need need = new Need(name, type, maxGoal); +        String location = "Atlantis"; +        double maxGoal = 100.0; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          // When the same id is passed in, our mock User DAO will return the User object -        when(mockCupboardDAO.getNeed(id)).thenReturn(need); +        when(mockCupboardDAO.getNeed(0)).thenReturn(need);          // Invoke -        Need response = cupboardService.getNeed(id); +        Need response = cupboardService.getNeed(need.getId());          // Analyze          assertEquals(need, response); @@ -155,17 +166,18 @@ public class CupboardServiceTest {      public void testUpdateNeed() throws IOException {          // Setup          String name = "Jellyfish"; -        double maxGoal = 100.00; -        int id = 0; -        GoalType type = GoalType.MONETARY; -        Need need = new Need(name, type, maxGoal); -        Need newNeed = new Need("Octopus", type, maxGoal); +        String location = "Atlantis"; +        double maxGoal = 100.0; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        Need need = new Need(name, location, maxGoal, type, urgent); +        Need newNeed = new Need("Octopus", location, maxGoal, type, urgent);          // When the same id is passed in, our mock User DAO will return the User object          when(mockCupboardDAO.updateNeed(any())).thenReturn(newNeed);          // Invoke -        Need response = cupboardService.updateNeed(newNeed, id); +        Need response = cupboardService.updateNeed(newNeed, need.getId());          // Analyze          assertEquals(newNeed, response); @@ -175,17 +187,18 @@ public class CupboardServiceTest {      public void testDeleteNeed() throws IOException {          // Setup          String name = "Jellyfish"; -        double maxGoal = 100.00; -        int id = 0; -        GoalType type = GoalType.MONETARY; -        Need need = new Need(name, type, maxGoal); +        String location = "Atlantis"; +        double maxGoal = 100.0; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        Need need = new Need(name, location, maxGoal, type, urgent);          // When the same id is passed in, our mock User DAO will return the User object -        when(mockCupboardDAO.deleteNeed(id)).thenReturn(true); +        when(mockCupboardDAO.deleteNeed(0)).thenReturn(true);          when(mockCupboardDAO.getNeeds()).thenReturn(new Need[0]);          // Invoke -        boolean response = cupboardService.deleteNeed(id); +        boolean response = cupboardService.deleteNeed(need.getId());          Need[] responseNeeds = cupboardService.getNeeds();          // Analyze  | 
