Search in sources :

Example 1 with AuthTokenDao

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

the class AuthTokenServiceDbImplFactory method createAuthTokenServiceDbImpl.

public static AuthTokenServiceImpl createAuthTokenServiceDbImpl() {
    AuthTokenServiceImpl ret = new AuthTokenServiceImpl();
    ret.setPasswordService(PasswordServiceDbImplFactory.createPasswordServiceDbImpl());
    ret.setUserService(UserServiceImplFactory.createUsersServiceImpl());
    AuthTokenDao authTokenDao = Mockito.mock(AuthTokenDao.class);
    ret.setAuthTokenDao(authTokenDao);
    when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXCEPTION)).thenThrow(new IllegalStateException("test simulate exception"));
    when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXISTENT)).thenReturn(AuthTokenFactory.createAuthTokenForExistentUser());
    when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_NOT_EXISTENT)).thenReturn(null);
    when(authTokenDao.findAuthTokenByUuid(AuthTokenFactory.AUTH_TOKEN_EXPIRED)).thenReturn(AuthTokenFactory.createExpiredAuthToken());
    List<AuthToken> expiredTokens = new LinkedList<AuthToken>();
    expiredTokens.add(AuthTokenFactory.createExpiredAuthToken());
    PaginatedList<AuthToken> expiredAuthTokens = new PaginatedList<AuthToken>(new PagerParams(), expiredTokens, 1);
    return ret;
}
Also used : AuthTokenDao(org.summerb.microservices.users.impl.dao.AuthTokenDao) PagerParams(org.summerb.approaches.jdbccrud.api.dto.PagerParams) AuthToken(org.summerb.microservices.users.api.dto.AuthToken) PaginatedList(org.summerb.approaches.jdbccrud.api.dto.PaginatedList) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 PagerParams (org.summerb.approaches.jdbccrud.api.dto.PagerParams)1 PaginatedList (org.summerb.approaches.jdbccrud.api.dto.PaginatedList)1 AuthToken (org.summerb.microservices.users.api.dto.AuthToken)1 AuthTokenDao (org.summerb.microservices.users.impl.dao.AuthTokenDao)1