use of org.summerb.easycrud.api.dto.PaginatedList 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());
}
use of org.summerb.easycrud.api.dto.PaginatedList 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;
}
Aggregations