Search in sources :

Example 1 with UserDao

use of org.summerb.users.impl.dao.UserDao in project summerb by skarpushin.

the class UserServiceImplFactory method createUsersServiceImpl.

public static UserServiceImpl createUsersServiceImpl() {
    UserServiceImpl ret = new UserServiceImpl();
    UserDao userDao = Mockito.mock(UserDao.class);
    ret.setUserDao(userDao);
    ret.setEventBus(Mockito.mock(EventBus.class));
    User existingUser = UserFactory.createExistingUser();
    when(userDao.findUserByUuid(UserFactory.EXISTENT_USER)).thenReturn(existingUser);
    when(userDao.findUserByUuid(UserFactory.EXISTENT_USER_2_PROBLEM_WITH_PASSWORD)).thenReturn(UserFactory.createExistingUser2());
    when(userDao.findUserByUuid(UserFactory.EXISTENT_USER_WITH_MISSING_PASSWORD)).thenReturn(UserFactory.createUserWithMissingPassword());
    when(userDao.findUserByUuid(UserFactory.NON_EXISTENT_USER)).thenReturn(null);
    when(userDao.findUserByUuid(UserFactory.USER_RESULT_IN_EXCEPTION)).thenThrow(new IllegalStateException("Simulate unexpected excception"));
    when(userDao.findUserByEmail(UserFactory.EXISTENT_USER_EMAIL)).thenReturn(existingUser);
    when(userDao.findUserByEmail(UserFactory.NON_EXISTENT_USER_EMAIL)).thenReturn(null);
    when(userDao.findUserByEmail(UserFactory.USER_EMAIL_RESULT_IN_EXCEPTION)).thenThrow(new IllegalStateException("Simulate unexpected excception"));
    when(userDao.findUserByDisplayNamePartial(eq(UserFactory.EXISTENT_USER), any(PagerParams.class))).thenThrow(new IllegalStateException("Simulate unexpected excception"));
    when(userDao.findUserByUuid(UserFactory.EXISTENT_USER_WITH_EXPIRED_TOKEN)).thenReturn(UserFactory.createUserWithExpiredToken());
    when(userDao.updateUser(UserFactory.createDuplicateUser())).thenThrow(new DuplicateKeyException("Simulate unexpected excception"));
    return ret;
}
Also used : User(org.summerb.users.api.dto.User) UserDao(org.summerb.users.impl.dao.UserDao) PagerParams(org.summerb.easycrud.api.dto.PagerParams) EventBus(com.google.common.eventbus.EventBus) DuplicateKeyException(org.springframework.dao.DuplicateKeyException)

Aggregations

EventBus (com.google.common.eventbus.EventBus)1 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)1 PagerParams (org.summerb.easycrud.api.dto.PagerParams)1 User (org.summerb.users.api.dto.User)1 UserDao (org.summerb.users.impl.dao.UserDao)1