@Test public void checkPasswordTrueTest() { String encryptedPW = BCrypt.hashpw("testPW", BCrypt.gensalt()); userRepository.addUser(new User("testEmail", encryptedPW, "testUser", "testRole")); userRepository.checkPassword("testEmail", "testPW"); }
@Test(expected = InvalidInputException.class) public void checkPasswordFalseTest() { String encryptedPW = BCrypt.hashpw("testPW", BCrypt.gensalt()); userRepository.addUser(new User("testEmail", encryptedPW, "testUser", "testRole")); userRepository.checkPassword("testEmail", "testFalse"); }
@Test public void getUserByEmail() { User user1 = new User("testEmail", "testPW", "testUser", "testRole"); userRepository.addUser(user1); User user2 = userRepository.getUserByEmail("testEmail"); assertThat(user1.getUserId(), is(user2.getUserId())); }
@Test public void getUserRole() { userRepository.addUser(new User("testEmail", "testPW", "testUser", "testRole")); assertThat(userRepository.getUserRole("testEmail"), is("testRole")); }
@Test(expected = ObjectAlreadyExistException.class) public void userIdAlreadyTest() { userRepository.addUser(new User("testEmail", "testPW", "testUser", "testRole")); userRepository.checkUserIdAlreadyExists("testUser"); }