diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-04-04 22:58:26 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-04-04 22:58:26 -0400 |
commit | f70e86470f7083cda1949ff97556d9e39578ce1d (patch) | |
tree | 5cc8a3e1089409e10fd92896625605a7f8f6897b /ufund-api/src/test/java | |
parent | edfc9a8450d140ba1650b38e4b707000710b2faa (diff) | |
parent | 5a5d31896d79a736bce33b7d1aa7b3168ba308a9 (diff) | |
download | JellySolutions-f70e86470f7083cda1949ff97556d9e39578ce1d.tar.gz JellySolutions-f70e86470f7083cda1949ff97556d9e39578ce1d.tar.bz2 JellySolutions-f70e86470f7083cda1949ff97556d9e39578ce1d.zip |
Merge branch 'main' into need-list-abstraction
# Conflicts:
# ufund-ui/src/app/components/cupboard/cupboard.component.ts
# ufund-ui/src/app/components/funding-basket/funding-basket.component.html
# ufund-ui/src/app/components/funding-basket/funding-basket.component.ts
# ufund-ui/src/app/components/need-list/need-list.component.html
# ufund-ui/src/app/components/need-list/need-list.component.ts
# ufund-ui/src/app/components/need-page/need-page.component.html
Diffstat (limited to 'ufund-api/src/test/java')
-rw-r--r-- | ufund-api/src/test/java/com/ufund/api/ufundapi/controller/CupboardControllerTest.java | 48 |
1 files changed, 33 insertions, 15 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 8572ec6..7ea4455 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 @@ -1,6 +1,7 @@ package com.ufund.api.ufundapi.controller; import java.io.IOException; +import java.util.List; import java.util.Map; import static java.util.Map.entry; @@ -418,12 +419,14 @@ public class CupboardControllerTest { @Test public 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); - - Map<String, Integer> needMap = Map.ofEntries( - entry("needID", 0), - entry("amount", 20) + var needMap = List.of( + Map.ofEntries( + entry("needID", 0), + entry("quantity", 20) + ) ); var res = cupboardController.checkoutNeeds(needMap, key); @@ -435,9 +438,15 @@ public class CupboardControllerTest { public void checkoutNeedsBadRequest() throws IOException, IllegalAccessException { doThrow(new IllegalArgumentException()).when(mockCupboardService).checkoutNeed(0, 20, key); - Map<String, Integer> needMap = Map.ofEntries( - entry("needID", 0), - entry("amount", 20) + var needMap = List.of( + Map.ofEntries( + entry("needID", 0), + entry("quantity", 20) + ), + Map.ofEntries( + entry("needID", 2), + entry("quantity", 30) + ) ); var res = cupboardController.checkoutNeeds(needMap, key); @@ -447,11 +456,17 @@ public class CupboardControllerTest { @Test public void checkoutNeedsUnauthorized() throws IOException, IllegalAccessException { - doThrow(new IllegalAccessException()).when(mockCupboardService).checkoutNeed(0, 20, key); - - Map<String, Integer> needMap = Map.ofEntries( - entry("needID", 0), - entry("amount", 20) + doThrow(new IllegalAccessException()).when(mockAuthService).keyIsValid(key); + + var needMap = List.of( + Map.ofEntries( + entry("needID", 0), + entry("quantity", 20) + ), + Map.ofEntries( + entry("needID", 2), + entry("quantity", 30) + ) ); var res = cupboardController.checkoutNeeds(needMap, key); @@ -461,11 +476,14 @@ public class CupboardControllerTest { @Test public 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); - Map<String, Integer> needMap = Map.ofEntries( - entry("needID", 0), - entry("amount", 20) + var needMap = List.of( + Map.ofEntries( + entry("needID", 0), + entry("quantity", 20) + ) ); var res = cupboardController.checkoutNeeds(needMap, key); |