use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class UserServiceImplTest method testFindUsersByDisplayNamePartial_whitebox_expectUserServiceUnexpectedException.
@Test(expected = UserServiceUnexpectedException.class)
public void testFindUsersByDisplayNamePartial_whitebox_expectUserServiceUnexpectedException() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
fixture.findUsersByDisplayNamePartial(UserFactory.EXISTENT_USER, new PagerParams(20, 40));
fail();
}
use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class UserDaoImplTest method testFindUsersByDisplayNamePartial_expectUsersWillBeFound.
@Test
public void testFindUsersByDisplayNamePartial_expectUsersWillBeFound() throws Exception {
User user = UserFactory.createNewUserTemplate();
user.setDisplayName("oneUHapqoiwez");
user.setEmail("email1@aaa.ru");
userService.createUser(user);
user = UserFactory.createNewUserTemplate();
user.setDisplayName("twoUHapqoiwez");
user.setEmail("email2@aaa.ru");
userService.createUser(user);
user = UserFactory.createNewUserTemplate();
user.setDisplayName("threeUHapqoiwez");
user.setEmail("email3@aaa.ru");
userService.createUser(user);
user = UserFactory.createNewUserTemplate();
user.setDisplayName("other");
user.setEmail("other@aaa.ru");
userService.createUser(user);
PaginatedList<User> results = userService.findUsersByDisplayNamePartial("UHapqoiwez", new PagerParams());
assertNotNull(results);
assertNotNull(results.getItems());
assertTrue(results.getItems().size() == 3);
assertTrue(results.getTotalResults() == 3);
results = userService.findUsersByDisplayNamePartial("eUHapqoiwez", new PagerParams());
assertTrue(results.getItems().size() == 2);
assertTrue(results.getTotalResults() == 2);
results = userService.findUsersByDisplayNamePartial("UHapqoiwez", new PagerParams(0, 1));
assertTrue(results.getItems().size() == 1);
assertTrue(results.getTotalResults() == 3);
}
use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class EasyCrudControllerBase method getList.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView getList(HttpServletResponse response) throws Exception {
ModelAndView ret = new ModelAndView(viewNameForList);
if (initialPageSize > 0) {
ret.addObject(ATTR_LIST, service.query(new PagerParams(0, initialPageSize), null));
}
// TBD: Shouldn't we cache such things?
Map<String, Boolean> perms = getPermissionsMapForCurrentUser();
ret.addObject(ATTR_PERMISSIONS, gson.toJson(perms));
return ret;
}
use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class UserDaoImplTest method testFindUsersByDisplayNamePartial_expectCorrectSorting.
@Test
public // @Rollback(false)
void testFindUsersByDisplayNamePartial_expectCorrectSorting() throws Exception {
User user = UserFactory.createNewUserTemplate();
user.setDisplayName("ooUHapqoiwez");
user.setEmail("email2@aaa.ru");
userService.createUser(user);
user = UserFactory.createNewUserTemplate();
user.setDisplayName("oooUHapqoiwez");
user.setEmail("email3@aaa.ru");
userService.createUser(user);
user = UserFactory.createNewUserTemplate();
user.setDisplayName("oUHapqoiwez");
user.setEmail("email1@aaa.ru");
userService.createUser(user);
PaginatedList<User> results = userService.findUsersByDisplayNamePartial("UHapqoiwez", new PagerParams());
assertNotNull(results);
List<User> items = results.getItems();
assertNotNull(items);
assertTrue(items.size() == 3);
assertTrue(results.getTotalResults() == 3);
assertEquals("email1@aaa.ru", items.get(0).getEmail());
assertEquals("email2@aaa.ru", items.get(1).getEmail());
assertEquals("email3@aaa.ru", items.get(2).getEmail());
}
use of org.summerb.easycrud.api.dto.PagerParams 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