diff options
Diffstat (limited to 'ufund-api/src')
8 files changed, 138 insertions, 56 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java index cce016c..12fb0a9 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java @@ -5,7 +5,6 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import com.ufund.api.ufundapi.service.AuthService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -22,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController; import com.ufund.api.ufundapi.DuplicateKeyException; import com.ufund.api.ufundapi.model.Need; import com.ufund.api.ufundapi.model.Need.GoalType; +import com.ufund.api.ufundapi.service.AuthService; import com.ufund.api.ufundapi.service.CupboardService; @RestController @@ -55,14 +55,16 @@ public class CupboardController { LOG.log(Level.INFO, "POST /cupboard body={0}", params); String name = (String) params.get("name"); + String image = (String) params.get("image"); String location = (String) params.get("location"); double maxGoal = ((Number) params.get("maxGoal")).doubleValue(); boolean urgent = (Boolean) params.get("urgent"); + String description = (String) params.get("description"); Need.GoalType goalType = GoalType.valueOf((String) params.get("type")); try { authService.keyHasAccessToCupboard(key); - Need need = cupboardService.createNeed(name, location, maxGoal, goalType, urgent); + Need need = cupboardService.createNeed(name, image, location, maxGoal, goalType, urgent, description); return new ResponseEntity<>(need, HttpStatus.OK); } catch (DuplicateKeyException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage()); diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java index 55a9441..9b6170b 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java @@ -10,6 +10,7 @@ public class Need { } @JsonProperty("name") private String name; + @JsonProperty("image") private String image; @JsonProperty("location") private String location; @JsonProperty("id") private int id; @JsonProperty("filterAttributes") private String[] filterAttributes; @@ -17,6 +18,7 @@ public class Need { @JsonProperty("maxGoal") private double maxGoal; @JsonProperty("urgent") private boolean urgent; @JsonProperty("current") private double current; + @JsonProperty("description") private String description; /** * Create a new need, used by the controller @@ -27,31 +29,38 @@ public class Need { * @param maxGoal The maximum goal for this need * @param type The type of need (monetary, physical) * @param urgent The urgency of the need + * @param description The description of the need */ - public Need(@JsonProperty("name") String name, @JsonProperty("location") String location, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type, @JsonProperty("urgent") boolean urgent) { + public Need(@JsonProperty("name") String name, @JsonProperty("image") String image, @JsonProperty("location") String location, @JsonProperty("id") int id, @JsonProperty("maxGoal") double maxGoal, @JsonProperty("type") GoalType type, @JsonProperty("urgent") boolean urgent, @JsonProperty("Description") String description) { this.id = id; + this.image = image; this.location = location; this.name = name; this.maxGoal = maxGoal; this.type = type; this.urgent = urgent; + this.description = description; } /** * Create a new need * * @param name The name of the need + * @param image The image representation of the need * @param location The location of the need * @param maxGoal The maximum goal for this need * @param type The type of need (monetary, physical) * @param urgent The urgency of the need + * @param description The description of the need */ - public Need(String name, String location, double maxGoal, GoalType type, boolean urgent) { + public Need(String name, String image, String location, double maxGoal, GoalType type, boolean urgent, String description) { this.name = name; + this.image = image; this.location = location; this.type = type; this.maxGoal = maxGoal; this.urgent = urgent; + this.description = description; } /** @@ -61,6 +70,7 @@ public class Need { */ public Need(Need other) { this.name = other.name; + this.image = other.image; this.location = other.location; this.id = other.id; this.filterAttributes = other.filterAttributes; @@ -68,6 +78,7 @@ public class Need { this.maxGoal = other.maxGoal; this.current = other.current; this.urgent = other.urgent; + this.description = other.description; } public String getName() { @@ -94,6 +105,7 @@ public class Need { return current; } + public void setCurrent(double current) { this.current = current; } diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java index a86fe28..993e7c1 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java @@ -25,13 +25,17 @@ public class CupboardService { * Creates a new Need * * @param name The name of the need to create + * @param image The image representation of the need to create + * @param location The location of the new need * @param maxGoal The max goal of the new need * @param goalType The goal type of the new need + * @param urgent The urgency of the new need + * @param description The description of the new need * @return The need that was created * @throws IOException Thrown if there was any issue saving the data * @throws DuplicateKeyException If there already exists a need with the same name */ - public Need createNeed(String name, String location, double maxGoal, Need.GoalType goalType, boolean urgent) throws IOException, DuplicateKeyException { + public Need createNeed(String name, String image, String location, double maxGoal, Need.GoalType goalType, boolean urgent, String description) throws IOException, DuplicateKeyException { if (maxGoal <= 0) { throw new IllegalArgumentException("Max Goal must be greater than zero"); @@ -45,7 +49,7 @@ public class CupboardService { } } - Need need = new Need(name, location, maxGoal, goalType, urgent); + Need need = new Need(name, image, location, maxGoal, goalType, urgent, description); return cupboardDAO.addNeed(need); } 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 c159db4..8572ec6 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 @@ -43,16 +43,20 @@ public class CupboardControllerTest { int maxGoal = 100; GoalType type = Need.GoalType.MONETARY; boolean urgent = false; - var need = new Need(name, location, maxGoal, type, urgent); - when(mockCupboardService.createNeed(name, "Atlantis", maxGoal, type, false)).thenReturn(need); + String image = ""; + String description = ""; + var need = new Need(name, location, image, maxGoal, type, urgent, description); + when(mockCupboardService.createNeed(name, image, location, maxGoal, type, urgent, description)).thenReturn(need); Map<String, Object> needMap = Map.ofEntries( entry("name", "Test"), + entry("image", ""), entry("location", "Atlantis"), - entry("maxGoal", 100.0), + entry("maxGoal", 100), entry("type", "MONETARY"), - entry("urgent", false) + entry("urgent", false), + entry("description", "") ); var res = cupboardController.createNeed(needMap, key); @@ -63,14 +67,16 @@ public class CupboardControllerTest { @Test public void createNeedBadMaxGoal() throws IOException, DuplicateKeyException { - when(mockCupboardService.createNeed("Test", "Atlantis", -100, Need.GoalType.MONETARY, false)).thenThrow(new IllegalArgumentException()); + when(mockCupboardService.createNeed("Test", "", "Atlantis", -100, Need.GoalType.MONETARY, false, "")).thenThrow(new IllegalArgumentException()); Map<String, Object> needMap = Map.ofEntries( entry("name", "Test"), + entry("image", ""), entry("location", "Atlantis"), entry("maxGoal", -100), entry("type", "MONETARY"), - entry("urgent", false) + entry("urgent", false), + entry("description", "") ); var res = cupboardController.createNeed(needMap, key); @@ -80,14 +86,16 @@ public class CupboardControllerTest { @Test public void createNeedIOException() throws IOException, DuplicateKeyException { - when(mockCupboardService.createNeed("Test", "Atlantis", 100, Need.GoalType.MONETARY, false)).thenThrow(new IOException()); + when(mockCupboardService.createNeed("Test", "", "Atlantis", 100, Need.GoalType.MONETARY, false, "")).thenThrow(new IOException()); Map<String, Object> needMap = Map.ofEntries( entry("name", "Test"), + entry("image", ""), entry("location", "Atlantis"), entry("maxGoal", 100), entry("type", "MONETARY"), - entry("urgent", false) + entry("urgent", false), + entry("description", "") ); var res = cupboardController.createNeed(needMap, key); @@ -97,14 +105,16 @@ public class CupboardControllerTest { @Test public void createNeedConflict() throws IOException, DuplicateKeyException { - when(mockCupboardService.createNeed("Test", "Atlantis", 100, Need.GoalType.MONETARY, false)).thenThrow(new DuplicateKeyException("")); + when(mockCupboardService.createNeed("Test", "", "Atlantis", 100, Need.GoalType.MONETARY, false, "")).thenThrow(new DuplicateKeyException("")); Map<String, Object> needMap = Map.ofEntries( entry("name", "Test"), + entry("image", ""), entry("location", "Atlantis"), entry("maxGoal", 100), entry("type", "MONETARY"), - entry("urgent", false) + entry("urgent", false), + entry("description", "") ); var res = cupboardController.createNeed(needMap, key); @@ -136,7 +146,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.getNeeds()).thenReturn(new Need[]{need}); var res = cupboardController.getNeeds(); @@ -171,7 +183,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.searchNeeds("Na")).thenReturn(new Need[]{need}); var res = cupboardController.searchNeeds("Na"); @@ -206,7 +220,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.getNeed(need.getId())).thenReturn(need); var res = cupboardController.getNeed(need.getId()); @@ -222,7 +238,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.getNeed(need.getId())).thenThrow(new IOException()); var res = cupboardController.getNeed(need.getId()); @@ -237,7 +255,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.getNeed(need.getId())).thenReturn(null); var res = cupboardController.getNeed(need.getId()); @@ -253,7 +273,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.updateNeed(need, 1)).thenReturn(need); var res = cupboardController.updateNeed(need, 1, key); @@ -269,7 +291,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.updateNeed(need, 1)).thenThrow(new IOException()); var res = cupboardController.updateNeed(need, 1, key); @@ -284,7 +308,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.updateNeed(need, 1)).thenReturn(null); var res = cupboardController.updateNeed(need, 1, key); @@ -299,7 +325,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.updateNeed(need, 1)).thenThrow(new IllegalArgumentException()); var res = cupboardController.updateNeed(need, 1, key); @@ -314,7 +342,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); doThrow(new IllegalAccessException()).when(mockAuthService).keyHasAccessToCupboard(key); var res = cupboardController.updateNeed(need, 1, key); @@ -329,7 +359,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.getNeed(1)).thenReturn(need); when(mockCupboardService.deleteNeed(1)).thenReturn(true); @@ -355,7 +387,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.getNeed(1)).thenReturn(need); doThrow(new IllegalAccessException()).when(mockAuthService).keyHasAccessToCupboard(key); @@ -371,7 +405,9 @@ public class CupboardControllerTest { int 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, location, image, maxGoal, type, urgent, description); when(mockCupboardService.getNeed(1)).thenReturn(need); when(mockCupboardService.deleteNeed(1)).thenThrow(new IOException()); diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java index c7d17c7..67d2b8f 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java @@ -18,7 +18,9 @@ public class NeedTest { 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, location, image, maxGoal, type, urgent, description); assertNotNull(need); } @@ -29,7 +31,9 @@ public class NeedTest { 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, location, image, maxGoal, type, urgent, description); assertEquals(name, need.getName()); @@ -45,7 +49,9 @@ public class NeedTest { 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, location, image, maxGoal, type, urgent, description); double current = 0.00; need.setCurrent(current); @@ -69,7 +75,9 @@ public class NeedTest { 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, location, image, maxGoal, type, urgent, description); String[] filterAttributes = {"seaweed", "divers", "pacific", "plankton"}; @@ -86,7 +94,9 @@ public class NeedTest { 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, location, image, maxGoal, type, urgent, description); double newGoal = 200.00; need.setMaxGoal(newGoal); @@ -103,7 +113,9 @@ public class NeedTest { 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, location, image, maxGoal, type, urgent, description); String newName = "TESTINGFUN"; need.setName(newName); diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java index 01b558c..ed48f54 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/model/UserTest.java @@ -52,7 +52,7 @@ public class UserTest { String expectedName = "Bob"; User user = User.create(expectedName, "pass"); - Need need = new Need("Test", "Atlantis", 0, 100, Need.GoalType.MONETARY, false); + Need need = new Need("Test", "", "Atlantis", 0, 100, Need.GoalType.MONETARY, false, ""); Need[] needs = { need }; when(cupboardService.getNeed(0)).thenReturn(need); @@ -71,8 +71,8 @@ public class UserTest { String expectedName = "Bob"; User user = User.create(expectedName, "pass"); - Need need = new Need("Test", "Atlantis", 0, 100, Need.GoalType.MONETARY, false); - Need need2 = new Need("Test2", "Atlantis", 0, 100, Need.GoalType.MONETARY, false); + Need need = new Need("Test", "", "Atlantis", 0, 100, Need.GoalType.MONETARY, false, ""); + Need need2 = new Need("Test2", "", "Atlantis", 0, 100, Need.GoalType.MONETARY, false, ""); when(cupboardService.getNeed(0)).thenReturn(need2); user.addToBasket(need); diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java index acb759a..76a8b40 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/persistence/CupboardFileDAOTest.java @@ -28,9 +28,9 @@ public class CupboardFileDAOTest { public void setupCupboardFileDao() throws IOException { ObjectMapper mockObjectMapper = mock(ObjectMapper.class); testNeeds = new Need[] { - new Need("one", "Atlantis", 0, 100, Need.GoalType.MONETARY, false), - new Need("two", "Atlantis", 1, 100, Need.GoalType.MONETARY, false), - new Need("three", "Atlantis", 2, 100, Need.GoalType.MONETARY, false) + new Need("one", "", "Atlantis", 0, 100, Need.GoalType.MONETARY, false, ""), + new Need("two", "", "Atlantis", 1, 100, Need.GoalType.MONETARY, false, ""), + new Need("three", "", "Atlantis", 2, 100, Need.GoalType.MONETARY, false, "") }; // When the object mapper is supposed to read from the file // the mock object mapper will return the hero array above @@ -54,7 +54,7 @@ public class CupboardFileDAOTest { @Test public void createNeedTest() throws IOException { - Need newNeed = new Need("sea urchin hats", "Atlantis", 100, GoalType.PHYSICAL, false); + Need newNeed = new Need("sea urchin hats", "", "Atlantis", 100, GoalType.PHYSICAL, false, ""); Need actualNeed = cupboardFileDao.addNeed(newNeed); @@ -90,7 +90,7 @@ public class CupboardFileDAOTest { Need unupdatedNeed = needs[needs.length - 1]; assertNotNull(unupdatedNeed); - Need updatedNeed = new Need("sequin sea urchin hats", "Atlantis", 100, GoalType.PHYSICAL, false); + Need updatedNeed = new Need("sequin sea urchin hats", "", "Atlantis", 100, GoalType.PHYSICAL, false, ""); Need actualNeed = cupboardFileDao.updateNeed(updatedNeed); assertEquals(actualNeed, updatedNeed); @@ -103,7 +103,7 @@ public class CupboardFileDAOTest { Need unupdatedNeed = needs[needs.length - 1]; assertNotNull(unupdatedNeed); - Need updatedNeed = new Need("sequin sea urchin hats", "Atlantis", 5, 100, GoalType.PHYSICAL, false); + Need updatedNeed = new Need("sequin sea urchin hats", "", "Atlantis", 5, 100, GoalType.PHYSICAL, false, ""); Need actualNeed = cupboardFileDao.updateNeed(updatedNeed); assertNull(actualNeed); 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); |