Search in sources :

Example 56 with User

use of org.summerb.microservices.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);
}
Also used : User(org.summerb.microservices.users.api.dto.User) Test(org.junit.Test)

Example 57 with User

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

the class UserCachedTest method testDeleteUser_expectUserNotFoundException.

// (expected=UserNotFoundException.class)
@Test
public void testDeleteUser_expectUserNotFoundException() throws Exception {
    User userToCreate = UserFactory.createNewUserTemplate();
    userToCreate = userService.createUser(userToCreate);
    userService.getUserByUuid(userToCreate.getUuid());
    userService.deleteUserByUuid(userToCreate.getUuid());
    try {
        userService.getUserByUuid(userToCreate.getUuid());
        fail();
    } catch (UserNotFoundException e) {
    }
}
Also used : UserNotFoundException(org.summerb.microservices.users.api.exceptions.UserNotFoundException) User(org.summerb.microservices.users.api.dto.User) Test(org.junit.Test)

Example 58 with User

use of org.summerb.microservices.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.microservices.users.api.dto.User) Test(org.junit.Test)

Example 59 with User

use of org.summerb.microservices.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.microservices.users.api.dto.User) Test(org.junit.Test)

Example 60 with User

use of org.summerb.microservices.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());
}
Also used : User(org.summerb.microservices.users.api.dto.User) PagerParams(org.summerb.approaches.jdbccrud.api.dto.PagerParams) Test(org.junit.Test)

Aggregations

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