aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-04-14 17:37:21 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-04-14 17:37:21 -0400
commitfe251b166e6315fdcba8481e5b6b4adfce7885a7 (patch)
treea36a1dfbf96b83e8bba93cec8a28e13d2ab17eef /ufund-api/src/test/java/com/ufund/api/ufundapi/service/CupboardServiceTest.java
parenta99dac870391305e4b82a3674febda1fe59e5556 (diff)
downloadJellySolutions-fe251b166e6315fdcba8481e5b6b4adfce7885a7.tar.gz
JellySolutions-fe251b166e6315fdcba8481e5b6b4adfce7885a7.tar.bz2
JellySolutions-fe251b166e6315fdcba8481e5b6b4adfce7885a7.zip
Fixed sonarqube issues in tests
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.java52
1 files changed, 18 insertions, 34 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 57cb0bf..d1109c5 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
@@ -15,22 +15,22 @@ import com.ufund.api.ufundapi.model.Need.GoalType;
import com.ufund.api.ufundapi.persistence.CupboardDAO;
@Tag("Service-tier")
-public class CupboardServiceTest {
+class CupboardServiceTest {
private CupboardDAO mockCupboardDAO;
private CupboardService cupboardService;
private AuthService mockAuthService;
@BeforeEach
- public void setupCupboardService() {
+ void setupCupboardService() {
mockCupboardDAO = mock(CupboardDAO.class);
- AuthService mockAuthService = mock(AuthService.class);
+ mockAuthService = mock(AuthService.class);
cupboardService = new CupboardService(mockAuthService, mockCupboardDAO);
this.mockAuthService = mock(AuthService.class);
}
@Test
- public void testCreateNeed() throws IOException, DuplicateKeyException {
+ void testCreateNeed() throws IOException, DuplicateKeyException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -54,7 +54,7 @@ public class CupboardServiceTest {
}
@Test
- public void testCreateNeedBadGoal() throws IOException {
+ void testCreateNeedBadGoal() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -69,16 +69,13 @@ public class CupboardServiceTest {
when(mockCupboardDAO.addNeed(any())).thenReturn(need);
when(mockCupboardDAO.getNeeds()).thenReturn(new Need[0]);
- // Invoke
- // Need response = cupboardService.createNeed(name, maxGoal, type);
-
// Analyze
assertThrows(IllegalArgumentException.class, () ->
cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description));
}
@Test
- public void testCreateNeedBadPhysicalGoal() throws IOException {
+ void testCreateNeedBadPhysicalGoal() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -93,16 +90,13 @@ public class CupboardServiceTest {
when(mockCupboardDAO.addNeed(any())).thenReturn(need);
when(mockCupboardDAO.getNeeds()).thenReturn(new Need[0]);
- // Invoke
- // Need response = cupboardService.createNeed(name, maxGoal, type);
-
// Analyze
assertThrows(IllegalArgumentException.class, () ->
cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description));
}
@Test
- public void testCreateNeedBadBlankFields() throws IOException {
+ void testCreateNeedBadBlankFields() throws IOException {
// Setup
String name = "";
String location = "Atlantis";
@@ -117,16 +111,13 @@ public class CupboardServiceTest {
when(mockCupboardDAO.addNeed(any())).thenReturn(need);
when(mockCupboardDAO.getNeeds()).thenReturn(new Need[0]);
- // Invoke
- // Need response = cupboardService.createNeed(name, maxGoal, type);
-
// Analyze
assertThrows(IllegalArgumentException.class, () ->
cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description));
}
@Test
- public void testCreateNeedNullFields() throws IOException {
+ void testCreateNeedNullFields() throws IOException {
// Setup
String name = "";
String location = "Atlantis";
@@ -141,16 +132,13 @@ public class CupboardServiceTest {
when(mockCupboardDAO.addNeed(any())).thenReturn(need);
when(mockCupboardDAO.getNeeds()).thenReturn(new Need[0]);
- // Invoke
- // Need response = cupboardService.createNeed(name, maxGoal, type);
-
// Analyze
assertThrows(IllegalArgumentException.class, () ->
cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description));
}
@Test
- public void testCreateNeedDuplicate() throws IOException {
+ void testCreateNeedDuplicate() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -166,16 +154,13 @@ public class CupboardServiceTest {
when(mockCupboardDAO.addNeed(any())).thenReturn(need);
when(mockCupboardDAO.getNeeds()).thenReturn(needs);
- // Invoke
- // Need response = cupboardService.createNeed(name, maxGoal, type);
-
// Analyze
assertThrows(DuplicateKeyException.class, () ->
cupboardService.createNeed(name, location, image, maxGoal, type, urgent, description));
}
@Test
- public void testSearchNeeds() throws IOException {
+ void testSearchNeeds() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -199,7 +184,7 @@ public class CupboardServiceTest {
}
@Test
- public void testSearchNeedsFail() throws IOException {
+ void testSearchNeedsFail() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -222,7 +207,7 @@ public class CupboardServiceTest {
}
@Test
- public void testGetNeed() throws IOException {
+ void testGetNeed() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -244,7 +229,7 @@ public class CupboardServiceTest {
}
@Test
- public void testUpdateNeed() throws IOException {
+ void testUpdateNeed() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -267,7 +252,7 @@ public class CupboardServiceTest {
}
@Test
- public void testUpdateNeedBadGoal() throws IOException {
+ void testUpdateNeedBadGoal() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -289,7 +274,7 @@ public class CupboardServiceTest {
}
@Test
- public void testUpdateNeedBadPhysicalGoal() throws IOException {
+ void testUpdateNeedBadPhysicalGoal() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -311,7 +296,7 @@ public class CupboardServiceTest {
}
@Test
- public void testUpdateNeedBlankFields() throws IOException {
+ void testUpdateNeedBlankFields() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -333,7 +318,7 @@ public class CupboardServiceTest {
}
@Test
- public void testUpdateNeedNotMatchingIDs() throws IOException {
+ void testUpdateNeedNotMatchingIDs() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";
@@ -342,7 +327,6 @@ public class CupboardServiceTest {
boolean urgent = false;
String image = "";
String description = "";
- var need = new Need(name, image, location, maxGoal, type, urgent, description);
// passed in blank name, should throw error
Need newNeed = new Need(name, image, location, maxGoal, type, urgent, description);
@@ -355,7 +339,7 @@ public class CupboardServiceTest {
}
@Test
- public void testDeleteNeed() throws IOException {
+ void testDeleteNeed() throws IOException {
// Setup
String name = "Jellyfish";
String location = "Atlantis";