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/controller | |
| 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/controller')
| -rw-r--r-- | ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java | 95 | 
1 files changed, 75 insertions, 20 deletions
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java index 89697bf..31e085b 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java @@ -38,16 +38,20 @@ public class CupboardControllerTest {      @Test      public void createNeed() throws IOException, DuplicateKeyException {          String name = "Test"; +        String location = "Atlantis";          int maxGoal = 100;          GoalType type = Need.GoalType.MONETARY; -        var need = new Need(name, type, maxGoal); -        when(mockCupboardService.createNeed(name, maxGoal, type)).thenReturn(need); +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent); +        when(mockCupboardService.createNeed(name, "Atlantis", maxGoal, type, false)).thenReturn(need);          Map<String, Object> needMap = Map.ofEntries(                  entry("name", "Test"), +                entry("location", "Atlantis"),                  entry("maxGoal", 100.0), -                entry("type", "MONETARY") +                entry("type", "MONETARY"), +                entry("urgent", false)          );          var res = cupboardController.createNeed(needMap, key); @@ -58,12 +62,15 @@ public class CupboardControllerTest {      @Test      public void createNeedBadMaxGoal() throws IOException, DuplicateKeyException { -        when(mockCupboardService.createNeed("Name", -100, Need.GoalType.MONETARY)).thenThrow(new IllegalArgumentException()); +        when(mockCupboardService.createNeed("Test", "Atlantis", -100, Need.GoalType.MONETARY, false)).thenThrow(new IllegalArgumentException());          Map<String, Object> needMap = Map.ofEntries( -                entry("name", "Name"), -                entry("maxGoal", -100.0), -                entry("type", "MONETARY")); +                entry("name", "Test"), +                entry("location", "Atlantis"), +                entry("maxGoal", -100), +                entry("type", "MONETARY"), +                entry("urgent", false) +        );          var res = cupboardController.createNeed(needMap, key); @@ -72,12 +79,15 @@ public class CupboardControllerTest {      @Test      public void createNeedIOException() throws IOException, DuplicateKeyException { -        when(mockCupboardService.createNeed("Name", 100, Need.GoalType.MONETARY)).thenThrow(new IOException()); +        when(mockCupboardService.createNeed("Test", "Atlantis", 100, Need.GoalType.MONETARY, false)).thenThrow(new IOException());          Map<String, Object> needMap = Map.ofEntries( -                entry("name", "Name"), -                entry("maxGoal", 100.0), -                entry("type", "MONETARY")); +                entry("name", "Test"), +                entry("location", "Atlantis"), +                entry("maxGoal", 100), +                entry("type", "MONETARY"), +                entry("urgent", false) +        );          var res = cupboardController.createNeed(needMap, key); @@ -86,7 +96,12 @@ public class CupboardControllerTest {      @Test      public void getNeeds() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.getNeeds()).thenReturn(new Need[]{need});          var res = cupboardController.getNeeds(); @@ -116,7 +131,12 @@ public class CupboardControllerTest {      @Test      public void searchNeeds() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.searchNeeds("Na")).thenReturn(new Need[]{need});          var res = cupboardController.searchNeeds("Na"); @@ -146,7 +166,12 @@ public class CupboardControllerTest {      @Test      public void getNeed() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.getNeed(need.getId())).thenReturn(need);          var res = cupboardController.getNeed(need.getId()); @@ -157,7 +182,12 @@ public class CupboardControllerTest {      @Test      public void getNeedIOException() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.getNeed(need.getId())).thenThrow(new IOException());          var res = cupboardController.getNeed(need.getId()); @@ -167,7 +197,12 @@ public class CupboardControllerTest {      @Test      public void getNeedFail() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.getNeed(need.getId())).thenReturn(null);          var res = cupboardController.getNeed(need.getId()); @@ -178,7 +213,12 @@ public class CupboardControllerTest {      @Test      public void updateNeeds() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.updateNeed(need, 1)).thenReturn(need);          var res = cupboardController.updateNeed(need, 1, key); @@ -189,7 +229,12 @@ public class CupboardControllerTest {      @Test      public void updateNeedsIOException() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.updateNeed(need, 1)).thenThrow(new IOException());          var res = cupboardController.updateNeed(need, 1, key); @@ -199,7 +244,12 @@ public class CupboardControllerTest {      @Test      public void deleteNeed() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.getNeed(1)).thenReturn(need);          when(mockCupboardService.deleteNeed(1)).thenReturn(true); @@ -220,7 +270,12 @@ public class CupboardControllerTest {      @Test      public void deleteNeedIOException() throws IOException { -        var need = new Need("Name", 1, 100, Need.GoalType.MONETARY); +        String name = "Test"; +        String location = "Atlantis"; +        int maxGoal = 100; +        GoalType type = Need.GoalType.MONETARY; +        boolean urgent = false; +        var need = new Need(name, location, maxGoal, type, urgent);          when(mockCupboardService.getNeed(1)).thenReturn(need);          when(mockCupboardService.deleteNeed(1)).thenThrow(new IOException());  | 
