Search in sources :

Example 31 with User

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

the class UserServiceImplTest method testFindUsersByDisplayNamePartial_blackbox_shouldReturnExpectedResults.

@Test
public void testFindUsersByDisplayNamePartial_blackbox_shouldReturnExpectedResults() throws Exception {
    UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
    PagerParams pagerParams = new PagerParams(20, 40);
    PaginatedList<User> resultFromDao = new PaginatedList<User>();
    resultFromDao.setTotalResults(1);
    resultFromDao.setPagerParams(pagerParams);
    resultFromDao.setItems(new LinkedList<User>());
    resultFromDao.getItems().add(UserFactory.createNewUserTemplate());
    when(fixture.getUserDao().findUserByDisplayNamePartial("asd", pagerParams)).thenReturn(resultFromDao);
    PaginatedList<User> results = fixture.findUsersByDisplayNamePartial("asd", pagerParams);
    assertNotNull(results);
    assertNotNull(results.getPagerParams());
    assertEquals(pagerParams.getOffset(), results.getPagerParams().getOffset());
    assertEquals(pagerParams.getMax(), results.getPagerParams().getMax());
    assertEquals(1, results.getTotalResults());
}
Also used : User(org.summerb.microservices.users.api.dto.User) PagerParams(org.summerb.approaches.jdbccrud.api.dto.PagerParams) PaginatedList(org.summerb.approaches.jdbccrud.api.dto.PaginatedList) Test(org.junit.Test)

Example 32 with User

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

the class UserServiceImplTest method testCreateUser_whitebox_expectOurExceptionInsteadOfUnexpectedOne.

@Test(expected = UserServiceUnexpectedException.class)
public void testCreateUser_whitebox_expectOurExceptionInsteadOfUnexpectedOne() throws Exception {
    UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
    User user = UserFactory.createNewUserTemplate();
    doThrow(new IllegalArgumentException("test exception")).when(fixture.getUserDao()).createUser(any(User.class));
    fixture.createUser(user);
    fail();
}
Also used : User(org.summerb.microservices.users.api.dto.User) Test(org.junit.Test)

Example 33 with User

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

the class UserServiceImplTest method testCreateUser_whitebox_expectReturnedValueIsNotTheSameReferenceAsParameter.

@Test
public void testCreateUser_whitebox_expectReturnedValueIsNotTheSameReferenceAsParameter() throws Exception {
    UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
    User template = UserFactory.createNewUserTemplate();
    User result = fixture.createUser(template);
    // add additional test code here
    assertNotNull(result);
    assertNotSame(template, result);
}
Also used : User(org.summerb.microservices.users.api.dto.User) Test(org.junit.Test)

Example 34 with User

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

Example 35 with User

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

the class SecurityMailsMessageBuilderFactoryImpl method getAccountOperationsSender.

@Override
public User getAccountOperationsSender() {
    if (registrationEmailSender == null) {
        registrationEmailSender = new User();
        registrationEmailSender.setEmail(emailSenderAddress);
        registrationEmailSender.setDisplayName(emailSenderName);
    }
    return registrationEmailSender;
}
Also used : User(org.summerb.microservices.users.api.dto.User)

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