use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testCreateUser_whitebox_expectDuplicateUserException.
@Test(expected = FieldValidationException.class)
public void testCreateUser_whitebox_expectDuplicateUserException() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
User user = UserFactory.createNewUserTemplate();
doThrow(new DuplicateKeyException("duplicate user")).when(fixture.getUserDao()).createUser(any(User.class));
fixture.createUser(user);
fail();
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testCreateUser_blackbox_expectAllFieldsEqualsForCreatedUser.
@Test
public void testCreateUser_blackbox_expectAllFieldsEqualsForCreatedUser() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
User user = UserFactory.createNewUserTemplate();
User createdUser = fixture.createUser(user);
// add additional test code here
assertNotNull(createdUser);
assertEquals(createdUser.getDisplayName(), user.getDisplayName());
assertEquals(createdUser.getEmail(), user.getEmail());
assertEquals(createdUser.getIntegrationData(), user.getIntegrationData());
assertEquals(createdUser.getIsBlocked(), user.getIsBlocked());
assertEquals(createdUser.getLocale(), user.getLocale());
assertEquals(createdUser.getRegisteredAt(), user.getRegisteredAt());
assertEquals(createdUser.getTimeZone(), user.getTimeZone());
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserCachedTest method testGetUserByUuid_expectReferencesEqualityForReturnedDtos.
@Test
public void testGetUserByUuid_expectReferencesEqualityForReturnedDtos() throws Exception {
User userToCreate = UserFactory.createNewUserTemplate();
userToCreate = userService.createUser(userToCreate);
User foundUser = userService.getUserByUuid(userToCreate.getUuid());
User foundUserCached = userService.getUserByUuid(userToCreate.getUuid());
assertTrue(foundUser == foundUserCached);
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class PasswordDaoImplTest method testSetUserPassword_expectDuplicateWillBeRewrittenWithoutErrors.
@Test
public void testSetUserPassword_expectDuplicateWillBeRewrittenWithoutErrors() throws Exception {
User createdUser = userService.createUser(UserFactory.createNewUserTemplate());
String pwd1 = "aaaa";
passwordService.setUserPassword(createdUser.getUuid(), pwd1);
String pwd2 = "bbbb";
passwordService.setUserPassword(createdUser.getUuid(), pwd2);
boolean result = passwordService.isUserPasswordValid(createdUser.getUuid(), pwd2);
assertTrue(result);
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class PasswordDaoImplTest method testCreateRestorationToken_expectDuplicateWillBeRewrittenWithoutErrors.
@Test
public void testCreateRestorationToken_expectDuplicateWillBeRewrittenWithoutErrors() throws Exception {
User createdUser = userService.createUser(UserFactory.createNewUserTemplate());
String pwd1 = "aaaa";
passwordService.setUserPassword(createdUser.getUuid(), pwd1);
String restorationToken = passwordService.getNewRestorationTokenForUser(createdUser.getUuid());
boolean result = passwordService.isRestorationTokenValid(createdUser.getUuid(), restorationToken);
assertTrue(result);
passwordService.deleteRestorationToken(createdUser.getUuid());
result = passwordService.isRestorationTokenValid(createdUser.getUuid(), restorationToken);
assertFalse(result);
}
Aggregations