Exemple #1
0
 @Test
 public void resetPassword() {
   String newPassword = service.resetUserPassword(user);
   service.saveUser(user);
   User savedUser = service.getUserByUserName(user.getUsername());
   assertTrue(service.encryptString(newPassword).equals(savedUser.getPassword()));
 }
Exemple #2
0
 public User populateUser() {
   Date date = new Date();
   User user = new User();
   user.setUsername("aac" + date.getTime() + "@mailinator.com");
   user.setPassword("darthVadar");
   user.setConfirmPassword("darthVadar");
   errors = new BeanPropertyBindingResult(user, "user");
   return user;
 }
Exemple #3
0
 @Test
 public void testCreatingEvaluation() {
   user = populateUser();
   evaluation = factory.createEvalution();
   evaluation.setName("Test Evaluation #1");
   evaluation.setUser(user);
   user.addEvaluation(evaluation);
   service.saveUser(user);
   user = service.getUserByUserName(user.getUsername());
 }
Exemple #4
0
 @Test
 public void testCreatingMultipleEvaluations() {
   Date date = new Date();
   String firstName = "Test Evaluation List #1 " + date.toString();
   String secondName = "Test Evaluation List #2 " + date.toString();
   user = populateUser();
   evaluation = factory.createEvalution();
   evaluation.setName(firstName);
   secondEvaluation = factory.createEvalution();
   secondEvaluation.setName(secondName);
   user.addEvaluation(evaluation);
   user.addEvaluation(secondEvaluation);
   service.saveUser(user);
   user = service.getUserByUserName(user.getUsername());
   assertTrue(user.getEvaluationSet().size() == 2);
 }
Exemple #5
0
 @Test
 public void incorrectConfirmPassword() {
   user = populateUser();
   user.setConfirmPassword("OrcaRocks");
   userValidator.validate(user, errors);
   assertTrue(errors.hasErrors());
 }
Exemple #6
0
 @Test
 public void incorrectPassword() {
   user = populateUser();
   user.setPassword("short");
   userValidator.validate(user, errors);
   assertTrue(errors.hasErrors());
 }
Exemple #7
0
 @Test
 public void incorrectEmail() {
   user = populateUser();
   user.setUsername("Hi_Mom!");
   userValidator.validate(user, errors);
   assertTrue(errors.hasErrors());
 }
Exemple #8
0
 @Test
 public void getUser() {
   service.saveUser(user);
   selectedUser = service.getUserByUserName(user.getUsername());
   assertTrue(user.getUsername().equals(selectedUser.getUsername()));
   assertTrue(user.getPassword().equals(selectedUser.getPassword()));
   assertTrue(user.getIsAdmin() == (selectedUser.getIsAdmin()));
   Boolean userNameAvailable = service.emailAvailable(user.getUsername());
   assertFalse(userNameAvailable);
 }