assertEquals(user.getId(), "SJDK3849CKMS3849DJCK2039ZMSK0003");
}
@Test
public void testFindPage() {
PageRequest request = new PageRequest();
request.setOrderBy("loginName,realName,state,id");
request.setOrderDir(Sort.ASC + "," + Sort.DESC + "," +Sort.ASC + "," + Sort.DESC);
Page<User> page = new Page<User>(request);
Criteria c = sessionFactory.getCurrentSession().createCriteria(User.class);
page = userDao.findPage(request, c.add(Restrictions.eq("loginName", "maurice")));
assertEquals(page.getTotalItems(), 1);
assertEquals(page.getTotalPages(), 1);
List<PropertyFilter> filters = Lists.newArrayList(
PropertyFilters.get("LIKES_loginName", "m"),
PropertyFilters.get("EQI_state", "1")
);
page = userDao.findPage(request, filters);
assertEquals(page.getTotalItems(), 5);
assertEquals(page.getTotalPages(), 1);
page = userDao.findPage(request, "from User u where u.loginName like ?", "%m%");
assertEquals(page.getTotalItems(), 5);
assertEquals(page.getTotalPages(), 1);
Query query = sessionFactory.getCurrentSession().createQuery("from User u where u.loginName like ?1");
query.setParameter("1", "%m%");
page = userDao.findPage(request, query);
assertEquals(page.getTotalItems(), 5);
assertEquals(page.getTotalPages(), 1);
page = userDao.findPage(request, "from User u where u.loginName like ?1", "%m%");
assertEquals(page.getTotalItems(), 5);
assertEquals(page.getTotalPages(), 1);
request.setOrderBy(null);
request.setOrderDir(null);
page = userDao.findPage(request, "QueryUserMenuJpa","SJDK3849CKMS3849DJCK2039ZMSK0001",1);
assertEquals(page.getTotalItems(), 8);
assertEquals(page.getTotalPages(), 1);