Search in sources :

Example 36 with User

use of org.summerb.users.api.dto.User in project summerb by skarpushin.

the class AuthTokenDaoImplTest method testUpdateUserPassword_expectWillReportAffectedRecords.

@Test
public void testUpdateUserPassword_expectWillReportAffectedRecords() throws Exception {
    User user = userService.createUser(UserFactory.createNewUserTemplate());
    passwordService.setUserPassword(user.getUuid(), "aaa");
    int result = passwordDao.updateUserPassword(user.getUuid(), "new-hash");
    assertTrue(result > 0);
    // do the same. Still expect affected > 0
    result = passwordDao.updateUserPassword(user.getUuid(), "new-hash");
    assertTrue(result > 0);
}
Also used : User(org.summerb.users.api.dto.User) Test(org.junit.Test)

Example 37 with User

use of org.summerb.users.api.dto.User in project summerb by skarpushin.

the class AuthTokenDaoImplTest method testSetRestorationToken_expectWillReportAffectedRecords.

@Test
public void testSetRestorationToken_expectWillReportAffectedRecords() throws Exception {
    User user = userService.createUser(UserFactory.createNewUserTemplate());
    passwordService.setUserPassword(user.getUuid(), "aaa");
    int result = passwordDao.setRestorationToken(user.getUuid(), "new-hash");
    assertTrue(result > 0);
    // do the same. Still expect affected > 0
    result = passwordDao.setRestorationToken(user.getUuid(), "new-hash");
    assertTrue(result > 0);
}
Also used : User(org.summerb.users.api.dto.User) Test(org.junit.Test)

Example 38 with User

use of org.summerb.users.api.dto.User in project summerb by skarpushin.

the class UserDaoImplTest method testCreateUser_expectUserWIllBeFoundByIdAfterCreateion.

@Test
public void testCreateUser_expectUserWIllBeFoundByIdAfterCreateion() throws Exception {
    User userToCreate = UserFactory.createNewUserTemplate();
    userToCreate = userService.createUser(userToCreate);
    User foundUser = userService.getUserByUuid(userToCreate.getUuid());
    assertNotNull(foundUser);
    assertEquals(userToCreate.getDisplayName(), foundUser.getDisplayName());
    assertEquals(userToCreate.getEmail(), foundUser.getEmail());
    assertEquals(userToCreate.getIntegrationData(), foundUser.getIntegrationData());
    assertEquals(userToCreate.getIsBlocked(), foundUser.getIsBlocked());
    assertEquals(userToCreate.getLocale(), foundUser.getLocale());
    assertEquals(userToCreate.getRegisteredAt(), foundUser.getRegisteredAt());
    assertEquals(userToCreate.getTimeZone(), foundUser.getTimeZone());
    assertEquals(userToCreate.getUuid(), foundUser.getUuid());
}
Also used : User(org.summerb.users.api.dto.User) Test(org.junit.Test)

Example 39 with User

use of org.summerb.users.api.dto.User in project summerb by skarpushin.

the class UserDaoImplTest method testCreateUser_expectUserWIllBeFoundByEmailAfterCreation.

@Test
public void testCreateUser_expectUserWIllBeFoundByEmailAfterCreation() throws Exception {
    User userToCreate = UserFactory.createNewUserTemplate();
    userToCreate = userService.createUser(userToCreate);
    User foundUser = userService.getUserByEmail(userToCreate.getEmail());
    assertNotNull(foundUser);
}
Also used : User(org.summerb.users.api.dto.User) Test(org.junit.Test)

Example 40 with User

use of org.summerb.users.api.dto.User in project summerb by skarpushin.

the class UserDaoImplTest method testUpdateUser_expectChangedValueAfterUpdate.

@Test
public void testUpdateUser_expectChangedValueAfterUpdate() throws Exception {
    User userToCreate = UserFactory.createNewUserTemplate();
    userToCreate.setDisplayName("old display name");
    userToCreate = userService.createUser(userToCreate);
    userToCreate.setDisplayName("new display name");
    userService.updateUser(userToCreate);
    User foundUser = userService.getUserByUuid(userToCreate.getUuid());
    assertEquals(userToCreate.getDisplayName(), foundUser.getDisplayName());
}
Also used : User(org.summerb.users.api.dto.User) Test(org.junit.Test)

Aggregations

User (org.summerb.users.api.dto.User)61 Test (org.junit.Test)33 UserNotFoundException (org.summerb.users.api.exceptions.UserNotFoundException)13 AuthToken (org.summerb.users.api.dto.AuthToken)11 UserServiceUnexpectedException (org.summerb.users.api.exceptions.UserServiceUnexpectedException)11 FieldValidationException (org.summerb.validation.FieldValidationException)11 Transactional (org.springframework.transaction.annotation.Transactional)8 Date (java.util.Date)4 PagerParams (org.summerb.easycrud.api.dto.PagerParams)4 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)3 InvalidPasswordException (org.summerb.users.api.exceptions.InvalidPasswordException)3 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 GenericException (org.summerb.utils.exceptions.GenericException)2 ValidationContext (org.summerb.validation.ValidationContext)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 EventBus (com.google.common.eventbus.EventBus)1 Locale (java.util.Locale)1 Secured (org.springframework.security.access.annotation.Secured)1 AuthenticationServiceException (org.springframework.security.authentication.AuthenticationServiceException)1