diff options
author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-04-01 07:47:16 -0400 |
---|---|---|
committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-04-01 07:47:16 -0400 |
commit | d8330f1ac85b26d08ca4df5ce3875078d7b4f47f (patch) | |
tree | 2046e58c146097aac21c9e352771420c31df6589 /ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java | |
parent | bc9d3417795d841b4cb3e9fb022f8d61448af946 (diff) | |
parent | 233fe120d2a9b30e0150401ebdfeb946dc9c2c07 (diff) | |
download | JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.tar.gz JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.tar.bz2 JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.zip |
Merge branch 'main' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b
Diffstat (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java')
-rw-r--r-- | ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java | 101 |
1 files changed, 65 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..2a3c8ee 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,20 @@ 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; + String image = ""; + String description = ""; + var need = new Need(name, image, location, maxGoal, type, urgent, description); // 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, image, maxGoal, type, urgent, description); // Analyze assertNotNull(response); @@ -56,9 +60,13 @@ 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; + String image = ""; + String description = ""; + var need = new Need(name, image, location, maxGoal, type, urgent, description); // When the same id is passed in, our mock User DAO will return the User object when(mockCupboardDAO.addNeed(any())).thenReturn(need); @@ -69,16 +77,20 @@ public class CupboardServiceTest { // Analyze assertThrows(IllegalArgumentException.class, () -> - cupboardService.createNeed(name, maxGoal, type)); + cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description)); } @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; + String image = ""; + String description = ""; + var need = new Need(name, image, location, maxGoal, type, urgent, description); Need[] needs = { need }; // When the same id is passed in, our mock User DAO will return the User object @@ -90,16 +102,20 @@ public class CupboardServiceTest { // Analyze assertThrows(DuplicateKeyException.class, () -> - cupboardService.createNeed(name, maxGoal, type)); + cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description)); } @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; + String image = ""; + String description = ""; + var need = new Need(name, image, location, maxGoal, type, urgent, description); Need[] needs = { need }; // When the same id is passed in, our mock User DAO will return the User object @@ -117,9 +133,13 @@ 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; + String image = ""; + String description = ""; + var need = new Need(name, image, location, maxGoal, type, urgent, description); Need[] needs = { need }; // When the same id is passed in, our mock User DAO will return the User object @@ -136,16 +156,19 @@ 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; + String image = ""; + String description = ""; + var need = new Need(name, image, location, maxGoal, type, urgent, description); // 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 +178,20 @@ 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; + String image = ""; + String description = ""; + var need = new Need(name, image, location, maxGoal, type, urgent, description); + Need newNeed = new Need("Octopus", image, location, maxGoal, type, urgent, description); // 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 +201,20 @@ 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; + String image = ""; + String description = ""; + var need = new Need(name, image, location, maxGoal, type, urgent, description); // 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 |