use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserDaoImplTest method testFindUsersByDisplayNamePartial_expectCorrectSorting.
@Test
public // @Rollback(false)
void testFindUsersByDisplayNamePartial_expectCorrectSorting() throws Exception {
User user = UserFactory.createNewUserTemplate();
user.setDisplayName("ooUHapqoiwez");
user.setEmail("email2@aaa.ru");
userService.createUser(user);
user = UserFactory.createNewUserTemplate();
user.setDisplayName("oooUHapqoiwez");
user.setEmail("email3@aaa.ru");
userService.createUser(user);
user = UserFactory.createNewUserTemplate();
user.setDisplayName("oUHapqoiwez");
user.setEmail("email1@aaa.ru");
userService.createUser(user);
PaginatedList<User> results = userService.findUsersByDisplayNamePartial("UHapqoiwez", new PagerParams());
assertNotNull(results);
List<User> items = results.getItems();
assertNotNull(items);
assertTrue(items.size() == 3);
assertTrue(results.getTotalResults() == 3);
assertEquals("email1@aaa.ru", items.get(0).getEmail());
assertEquals("email2@aaa.ru", items.get(1).getEmail());
assertEquals("email3@aaa.ru", items.get(2).getEmail());
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class AuthTokenServiceImpl method validateAndGetUser.
private User validateAndGetUser(String userEmail, String passwordPlain) throws UserNotFoundException, FieldValidationException, InvalidPasswordException {
try {
User user = userService.getUserByEmail(userEmail);
boolean isPasswordValid = passwordService.isUserPasswordValid(user.getUuid(), passwordPlain);
if (!isPasswordValid) {
throw new InvalidPasswordException();
}
return user;
} catch (Throwable t) {
Throwables.throwIfInstanceOf(t, UserNotFoundException.class);
Throwables.throwIfInstanceOf(t, FieldValidationException.class);
Throwables.throwIfInstanceOf(t, InvalidPasswordException.class);
String msg = String.format("Failed to validate user '%s' and password '%s'", userEmail, passwordPlain);
throw new UserServiceUnexpectedException(msg, t);
}
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testCreateUser_blackbox_expectValidationExceptionOnInvalidEmail.
@Test(expected = FieldValidationException.class)
public void testCreateUser_blackbox_expectValidationExceptionOnInvalidEmail() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
User user = UserFactory.createNewUserTemplate();
user.setEmail("abara-cadabara");
fixture.createUser(user);
fail();
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testCreateUser_blackbox_expectRegisteredAtWillBePopulated.
@Test
public void testCreateUser_blackbox_expectRegisteredAtWillBePopulated() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
User user = UserFactory.createNewUserTemplate();
user.setRegisteredAt(0);
User createdUser = fixture.createUser(user);
// add additional test code here
assertNotNull(createdUser);
assertTrue(createdUser.getRegisteredAt() != 0L);
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testUpdateUser_blackbox_fveOnFailedValidation.
@Test(expected = FieldValidationException.class)
public void testUpdateUser_blackbox_fveOnFailedValidation() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
User user = UserFactory.createExistingUser();
user.setEmail("asdasd");
when(fixture.getUserDao().updateUser(any(User.class))).thenReturn(true);
fixture.updateUser(user);
fail();
}
Aggregations