@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 checkPasswordTrueTest() { String encryptedPW = BCrypt.hashpw("testPW", BCrypt.gensalt()); userRepository.addUser(new User("testEmail", encryptedPW, "testUser", "testRole")); userRepository.checkPassword("testEmail", "testPW"); }
@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 public void userIdDoesNotAlreadyExistTest() { userRepository.checkUserIdAlreadyExists("testUser"); }
@Test(expected = ObjectAlreadyExistException.class) public void userIdAlreadyTest() { userRepository.addUser(new User("testEmail", "testPW", "testUser", "testRole")); userRepository.checkUserIdAlreadyExists("testUser"); }
@Test public void emailDoesNotAlreadyExistTest() { userRepository.checkEmailAlreadyExists("testEmail"); }
@Before public void setUp() throws Exception { userRepository = new UserRepository(); userRepository.setMongoTemplate(mongoTemplate); }