aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java')
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java58
1 files changed, 29 insertions, 29 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 7ea4455..54873c8 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
@@ -20,14 +20,14 @@ import com.ufund.api.ufundapi.model.Need;
import com.ufund.api.ufundapi.model.Need.GoalType;
import com.ufund.api.ufundapi.service.CupboardService;
-public class CupboardControllerTest {
+class CupboardControllerTest {
private CupboardController cupboardController;
private CupboardService mockCupboardService;
private final String key = "dummyKey";
private AuthService mockAuthService;
@BeforeEach
- public void setupCupboardDAO() {
+ void setupCupboardDAO() {
mockAuthService = mock(AuthService.class);
mockCupboardService = mock(CupboardService.class);
cupboardController = new CupboardController(mockCupboardService, mockAuthService);
@@ -38,7 +38,7 @@ public class CupboardControllerTest {
}
@Test
- public void createNeed() throws IOException, DuplicateKeyException {
+ void createNeed() throws IOException, DuplicateKeyException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -67,7 +67,7 @@ public class CupboardControllerTest {
}
@Test
- public void createNeedBadMaxGoal() throws IOException, DuplicateKeyException {
+ void createNeedBadMaxGoal() throws IOException, DuplicateKeyException {
when(mockCupboardService.createNeed("Test", "", "Atlantis", -100, Need.GoalType.MONETARY, false, "")).thenThrow(new IllegalArgumentException());
Map<String, Object> needMap = Map.ofEntries(
@@ -86,7 +86,7 @@ public class CupboardControllerTest {
}
@Test
- public void createNeedIOException() throws IOException, DuplicateKeyException {
+ void createNeedIOException() throws IOException, DuplicateKeyException {
when(mockCupboardService.createNeed("Test", "", "Atlantis", 100, Need.GoalType.MONETARY, false, "")).thenThrow(new IOException());
Map<String, Object> needMap = Map.ofEntries(
@@ -105,7 +105,7 @@ public class CupboardControllerTest {
}
@Test
- public void createNeedConflict() throws IOException, DuplicateKeyException {
+ void createNeedConflict() throws IOException, DuplicateKeyException {
when(mockCupboardService.createNeed("Test", "", "Atlantis", 100, Need.GoalType.MONETARY, false, "")).thenThrow(new DuplicateKeyException(""));
Map<String, Object> needMap = Map.ofEntries(
@@ -124,7 +124,7 @@ public class CupboardControllerTest {
}
@Test
- public void createNeedUnauthorized() throws IOException, IllegalAccessException {
+ void createNeedUnauthorized() throws IOException, IllegalAccessException {
doThrow(new IllegalAccessException()).when(mockAuthService).keyHasAccessToCupboard(key);
Map<String, Object> needMap = Map.ofEntries(
@@ -141,7 +141,7 @@ public class CupboardControllerTest {
}
@Test
- public void getNeeds() throws IOException {
+ void getNeeds() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -159,7 +159,7 @@ public class CupboardControllerTest {
}
@Test
- public void getNeedsIOException() throws IOException {
+ void getNeedsIOException() throws IOException {
when(mockCupboardService.getNeeds()).thenThrow(new IOException());
var res = cupboardController.getNeeds();
@@ -168,7 +168,7 @@ public class CupboardControllerTest {
}
@Test
- public void getNeedsEmpty() throws IOException {
+ void getNeedsEmpty() throws IOException {
when(mockCupboardService.getNeeds()).thenReturn(new Need[]{});
var res = cupboardController.getNeeds();
@@ -178,7 +178,7 @@ public class CupboardControllerTest {
}
@Test
- public void searchNeeds() throws IOException {
+ void searchNeeds() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -196,7 +196,7 @@ public class CupboardControllerTest {
}
@Test
- public void searchNeedsIOException() throws IOException {
+ void searchNeedsIOException() throws IOException {
when(mockCupboardService.searchNeeds("Na")).thenThrow(new IOException());
var res = cupboardController.searchNeeds("Na");
@@ -205,7 +205,7 @@ public class CupboardControllerTest {
}
@Test
- public void searchNeedsEmpty() throws IOException {
+ void searchNeedsEmpty() throws IOException {
when(mockCupboardService.searchNeeds("Na")).thenReturn(new Need[]{});
var res = cupboardController.searchNeeds("Na");
@@ -215,7 +215,7 @@ public class CupboardControllerTest {
}
@Test
- public void getNeed() throws IOException {
+ void getNeed() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -233,7 +233,7 @@ public class CupboardControllerTest {
}
@Test
- public void getNeedIOException() throws IOException {
+ void getNeedIOException() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -250,7 +250,7 @@ public class CupboardControllerTest {
}
@Test
- public void getNeedFail() throws IOException {
+ void getNeedFail() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -268,7 +268,7 @@ public class CupboardControllerTest {
}
@Test
- public void updateNeeds() throws IOException {
+ void updateNeeds() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -286,7 +286,7 @@ public class CupboardControllerTest {
}
@Test
- public void updateNeedsIOException() throws IOException {
+ void updateNeedsIOException() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -303,7 +303,7 @@ public class CupboardControllerTest {
}
@Test
- public void updateNeedMissing() throws IOException {
+ void updateNeedMissing() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -320,7 +320,7 @@ public class CupboardControllerTest {
}
@Test
- public void updateNeedBadRequest() throws IOException {
+ void updateNeedBadRequest() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -337,7 +337,7 @@ public class CupboardControllerTest {
}
@Test
- public void updateNeedUnauthorized() throws IOException, IllegalAccessException {
+ void updateNeedUnauthorized() throws IOException, IllegalAccessException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -354,7 +354,7 @@ public class CupboardControllerTest {
}
@Test
- public void deleteNeed() throws IOException {
+ void deleteNeed() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -372,7 +372,7 @@ public class CupboardControllerTest {
}
@Test
- public void deleteNeedFail() throws IOException {
+ void deleteNeedFail() throws IOException {
when(mockCupboardService.getNeed(1)).thenReturn(null);
when(mockCupboardService.deleteNeed(1)).thenReturn(false);
@@ -382,7 +382,7 @@ public class CupboardControllerTest {
}
@Test
- public void deleteNeedUnauthorized() throws IOException, IllegalAccessException {
+ void deleteNeedUnauthorized() throws IOException, IllegalAccessException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -400,7 +400,7 @@ public class CupboardControllerTest {
}
@Test
- public void deleteNeedIOException() throws IOException {
+ void deleteNeedIOException() throws IOException {
String name = "Test";
String location = "Atlantis";
int maxGoal = 100;
@@ -418,7 +418,7 @@ public class CupboardControllerTest {
}
@Test
- public void checkoutNeeds() throws IOException, IllegalAccessException {
+ void checkoutNeeds() throws IOException, IllegalAccessException {
when(mockCupboardService.getNeed(0)).thenReturn(new Need("name", "image", "location", 0, 10, GoalType.MONETARY, true, "a"));
doNothing().when(mockCupboardService).checkoutNeed(0, 20, key);
@@ -435,7 +435,7 @@ public class CupboardControllerTest {
}
@Test
- public void checkoutNeedsBadRequest() throws IOException, IllegalAccessException {
+ void checkoutNeedsBadRequest() throws IOException, IllegalAccessException {
doThrow(new IllegalArgumentException()).when(mockCupboardService).checkoutNeed(0, 20, key);
var needMap = List.of(
@@ -455,7 +455,7 @@ public class CupboardControllerTest {
}
@Test
- public void checkoutNeedsUnauthorized() throws IOException, IllegalAccessException {
+ void checkoutNeedsUnauthorized() throws IOException, IllegalAccessException {
doThrow(new IllegalAccessException()).when(mockAuthService).keyIsValid(key);
var needMap = List.of(
@@ -475,7 +475,7 @@ public class CupboardControllerTest {
}
@Test
- public void checkoutNeedsInternalError() throws IOException, IllegalAccessException {
+ void checkoutNeedsInternalError() throws IOException, IllegalAccessException {
when(mockCupboardService.getNeed(0)).thenReturn(new Need("name", "image", "location", 0, 10, GoalType.MONETARY, true, "a"));
doThrow(new IOException()).when(mockCupboardService).checkoutNeed(0, 20, key);