diff options
Diffstat (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/service')
3 files changed, 32 insertions, 37 deletions
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java index 55cf7a9..d3085e5 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java @@ -11,7 +11,6 @@ import org.junit.jupiter.api.BeforeEach;  import org.junit.jupiter.api.Tag;  import org.junit.jupiter.api.Test; -import com.ufund.api.ufundapi.DuplicateKeyException;  import com.ufund.api.ufundapi.model.User;  import com.ufund.api.ufundapi.model.UserAuth;  import com.ufund.api.ufundapi.persistence.UserAuthDAO; @@ -51,16 +50,16 @@ public class AuthServiceTest {      } -//    @Test -//    public void testAuthenticateMismatchName() throws IOException { -//        // Mock -//        when(mockAuthDAO.getUserAuth(key)).thenReturn(new UserAuth(key, "EvilFish", null)); -//        when(mockUserService.getUser("EvilFish")).thenReturn(user); -// -//        // Analyze -//        assertThrows(IllegalAccessException.class, () -> authService.authenticate(username, key)); -// -//    } +    @Test +    public void testAuthenticateMismatchName() throws IOException { +        // Mock +        when(mockAuthDAO.getUserAuth(key)).thenReturn(new UserAuth(key, "EvilFish", null)); +        when(mockUserService.getUser("EvilFish")).thenReturn(user); + +        // Analyze +        assertThrows(IllegalAccessException.class, () -> authService.authenticate(username, key)); + +    }      @Test      public void testAuthenticateMissingUserAuth() throws IOException { @@ -73,7 +72,7 @@ public class AuthServiceTest {      }      @Test -    public void testLogin() throws IOException, DuplicateKeyException, IllegalAccessException { +    public void testLogin() throws IOException {          // Mock          when(mockUserService.getUser(username)).thenReturn(user); @@ -83,7 +82,7 @@ public class AuthServiceTest {      }      @Test -    public void testLoginNullUser() throws IOException, DuplicateKeyException, IllegalAccessException { +    public void testLoginNullUser() throws IOException {          // Mock          when(mockUserService.getUser(username)).thenReturn(null); @@ -92,7 +91,7 @@ public class AuthServiceTest {      }      @Test -    public void testLoginMismatchPasswords() throws IOException, DuplicateKeyException, IllegalAccessException { +    public void testLoginMismatchPasswords() throws IOException {          // Mock          when(mockUserService.getUser(username)).thenReturn(User.create(username, "fries")); @@ -101,7 +100,7 @@ public class AuthServiceTest {      }      @Test -    public void testLogout() throws IOException, DuplicateKeyException, IllegalAccessException { +    public void testLogout() {          // Analyze          assertDoesNotThrow(() -> authService.logout(key)); 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 59f5b1b..05ea2e8 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 @@ -23,12 +23,11 @@ public class CupboardServiceTest {      private CupboardDAO mockCupboardDAO;      private CupboardService cupboardService; -    private AuthService mockAuthService;      @BeforeEach      public void setupCupboardService() {          mockCupboardDAO = mock(CupboardDAO.class); -        mockAuthService = mock(AuthService.class); +        AuthService mockAuthService = mock(AuthService.class);          cupboardService = new CupboardService(mockAuthService, mockCupboardDAO);      } @@ -54,7 +53,7 @@ public class CupboardServiceTest {      }      @Test -    public void testCreateNeedBadGoal() throws IOException, DuplicateKeyException { +    public void testCreateNeedBadGoal() throws IOException {          // Setup          String name = "Jellyfish";          double maxGoal = -100.00; @@ -69,13 +68,12 @@ public class CupboardServiceTest {          // Need response = cupboardService.createNeed(name, maxGoal, type);          // Analyze -        assertThrows(IllegalArgumentException.class, () -> { -            cupboardService.createNeed(name, maxGoal, type); -        }); +        assertThrows(IllegalArgumentException.class, () -> +                cupboardService.createNeed(name, maxGoal, type));      }      @Test -    public void testCreateNeedDuplicate() throws IOException, DuplicateKeyException { +    public void testCreateNeedDuplicate() throws IOException {          // Setup          String name = "Jellyfish";          double maxGoal = 100.00; @@ -91,13 +89,12 @@ public class CupboardServiceTest {          // Need response = cupboardService.createNeed(name, maxGoal, type);          // Analyze -        assertThrows(DuplicateKeyException.class, () -> { -            cupboardService.createNeed(name, maxGoal, type); -        }); +        assertThrows(DuplicateKeyException.class, () -> +                cupboardService.createNeed(name, maxGoal, type));      }      @Test -    public void testSearchNeeds() throws IOException, DuplicateKeyException { +    public void testSearchNeeds() throws IOException {          // Setup          String name = "Jellyfish";          double maxGoal = 100.00; @@ -117,7 +114,7 @@ public class CupboardServiceTest {      }      @Test -    public void testSearchNeedsFail() throws IOException, DuplicateKeyException { +    public void testSearchNeedsFail() throws IOException {          // Setup          String name = "Jellyfish";          double maxGoal = 100.00; @@ -136,7 +133,7 @@ public class CupboardServiceTest {      }      @Test -    public void testGetNeed() throws IOException, DuplicateKeyException { +    public void testGetNeed() throws IOException {          // Setup          String name = "Jellyfish";          double maxGoal = 100.00; @@ -155,7 +152,7 @@ public class CupboardServiceTest {      }      @Test -    public void testUpdateNeed() throws IOException, DuplicateKeyException { +    public void testUpdateNeed() throws IOException {          // Setup          String name = "Jellyfish";          double maxGoal = 100.00; @@ -175,7 +172,7 @@ public class CupboardServiceTest {      }      @Test -    public void testDeleteNeed() throws IOException, DuplicateKeyException { +    public void testDeleteNeed() throws IOException {          // Setup          String name = "Jellyfish";          double maxGoal = 100.00; diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/service/UserServiceTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/service/UserServiceTest.java index e57c5a3..5adabf1 100644 --- a/ufund-api/src/test/java/com/ufund/api/ufundapi/service/UserServiceTest.java +++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/service/UserServiceTest.java @@ -19,13 +19,12 @@ public class UserServiceTest {      private UserService userService;      private UserDAO mockUserDAO; -    private CupboardService mockCupboardService;      @BeforeEach      public void setupUserService() {          mockUserDAO = mock(UserDAO.class); -        mockCupboardService = mock(CupboardService.class); +        CupboardService mockCupboardService = mock(CupboardService.class);          userService = new UserService(mockUserDAO, mockCupboardService);      } @@ -47,7 +46,7 @@ public class UserServiceTest {      }      @Test -    public void testCreateUserDuplicate() throws IOException, DuplicateKeyException { +    public void testCreateUserDuplicate() throws IOException {          // Setup          String username = "Jelly";          String password = "Fish"; @@ -62,7 +61,7 @@ public class UserServiceTest {      }      @Test -    public void testGetUser() throws IOException, DuplicateKeyException { +    public void testGetUser() throws IOException {          // Setup          String username = "Jelly";          String password = "Fish"; @@ -76,7 +75,7 @@ public class UserServiceTest {      }      @Test -    public void testUpdateUser() throws IOException, DuplicateKeyException { +    public void testUpdateUser() throws IOException {          // Setup          String username = "Jelly";          String password = "Fish"; @@ -94,7 +93,7 @@ public class UserServiceTest {      }      @Test -    public void testUpdateUserDifferentUsernames() throws IOException, DuplicateKeyException { +    public void testUpdateUserDifferentUsernames() throws IOException {          // Setup          String username = "Jelly";          String password = "Fish"; @@ -112,7 +111,7 @@ public class UserServiceTest {      }      @Test -    public void testDeleteUser() throws IOException, DuplicateKeyException { +    public void testDeleteUser() throws IOException {          // Setup          String username = "Jelly";          String password = "Fish";  | 
