From cd8b846a4455aba7664cc03e219f471d251ff9bf Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 20:44:22 -0400 Subject: Fixed broken tests due to new need fields --- .../api/ufundapi/service/CupboardServiceTest.java | 40 +++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java') 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 f3cbc23..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 @@ -40,14 +40,16 @@ public class CupboardServiceTest { double maxGoal = 100; GoalType type = Need.GoalType.MONETARY; boolean urgent = false; - var need = new Need(name, location, maxGoal, type, urgent); + 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, location, maxGoal, type, urgent); + Need response = cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description); // Analyze assertNotNull(response); @@ -62,7 +64,9 @@ public class CupboardServiceTest { double maxGoal = -100.0; GoalType type = Need.GoalType.MONETARY; boolean urgent = false; - var need = new Need(name, location, maxGoal, type, urgent); + 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); @@ -73,7 +77,7 @@ public class CupboardServiceTest { // Analyze assertThrows(IllegalArgumentException.class, () -> - cupboardService.createNeed(name, location, maxGoal, type, urgent)); + cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description)); } @Test @@ -84,7 +88,9 @@ public class CupboardServiceTest { double maxGoal = 100.0; GoalType type = Need.GoalType.MONETARY; boolean urgent = false; - var need = new Need(name, location, maxGoal, type, urgent); + 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 @@ -96,7 +102,7 @@ public class CupboardServiceTest { // Analyze assertThrows(DuplicateKeyException.class, () -> - cupboardService.createNeed(name, location, maxGoal, type, urgent)); + cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description)); } @Test @@ -107,7 +113,9 @@ public class CupboardServiceTest { double maxGoal = 100.0; GoalType type = Need.GoalType.MONETARY; boolean urgent = false; - var need = new Need(name, location, maxGoal, type, urgent); + 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 @@ -129,7 +137,9 @@ public class CupboardServiceTest { double maxGoal = 100.0; GoalType type = Need.GoalType.MONETARY; boolean urgent = false; - var need = new Need(name, location, maxGoal, type, urgent); + 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 @@ -150,7 +160,9 @@ public class CupboardServiceTest { double maxGoal = 100.0; GoalType type = Need.GoalType.MONETARY; boolean urgent = false; - var need = new Need(name, location, maxGoal, type, urgent); + 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(0)).thenReturn(need); @@ -170,8 +182,10 @@ public class CupboardServiceTest { 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); + 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); @@ -191,7 +205,9 @@ public class CupboardServiceTest { double maxGoal = 100.0; GoalType type = Need.GoalType.MONETARY; boolean urgent = false; - Need need = new Need(name, location, maxGoal, type, urgent); + 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(0)).thenReturn(true); -- cgit v1.2.3