Search in sources :

Example 1 with UserService

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

the class PasswordServiceDbImplFactory method createPasswordServiceDbImpl.

public static PasswordServiceImpl createPasswordServiceDbImpl() {
    PasswordServiceImpl ret = new PasswordServiceImpl();
    ret.setPasswordEncoder(new StandardPasswordEncoder("test"));
    UserService userService = UserServiceImplFactory.createUsersServiceImpl();
    ret.setUserService(userService);
    PasswordDao passwordDao = Mockito.mock(PasswordDao.class);
    ret.setPasswordDao(passwordDao);
    when(passwordDao.findPasswordByUserUuid(UserFactory.EXISTENT_USER)).thenReturn(PasswordFactory.createExistentUserPassword());
    when(passwordDao.findPasswordByUserUuid(UserFactory.NON_EXISTENT_USER)).thenReturn(null);
    when(passwordDao.findPasswordByUserUuid(UserFactory.EXISTENT_USER_WITH_MISSING_PASSWORD)).thenReturn(null);
    when(passwordDao.findPasswordByUserUuid(UserFactory.USER_RESULT_IN_EXCEPTION)).thenThrow(new IllegalStateException("Simulate unexpected excception"));
    when(passwordDao.findPasswordByUserUuid(UserFactory.EXISTENT_USER_2_PROBLEM_WITH_PASSWORD)).thenThrow(new IllegalStateException("Simulate unexpected excception"));
    when(passwordDao.updateUserPassword(eq(UserFactory.EXISTENT_USER), anyString())).thenReturn(1);
    when(passwordDao.updateUserPassword(eq(UserFactory.EXISTENT_USER_WITH_MISSING_PASSWORD), anyString())).thenReturn(0);
    when(passwordDao.setRestorationToken(eq(UserFactory.EXISTENT_USER), anyString())).thenReturn(1);
    when(passwordDao.setRestorationToken(eq(UserFactory.EXISTENT_USER_WITH_MISSING_PASSWORD), anyString())).thenReturn(0);
    return ret;
}
Also used : StandardPasswordEncoder(org.springframework.security.crypto.password.StandardPasswordEncoder) PasswordDao(org.summerb.microservices.users.impl.dao.PasswordDao) UserService(org.summerb.microservices.users.api.UserService)

Aggregations

StandardPasswordEncoder (org.springframework.security.crypto.password.StandardPasswordEncoder)1 UserService (org.summerb.microservices.users.api.UserService)1 PasswordDao (org.summerb.microservices.users.impl.dao.PasswordDao)1