@Test public void testListPage() { em.createNativeQuery( "insert into address (id, anrede, vorname, nachname, email) values (2, " + Anreden.FRAU.ordinal() + ", 'Angela', 'Merkel', '*****@*****.**')") .executeUpdate(); AddressQuery query = new AddressQuery(); query.setMaxResults(1); List<Address> res = dao.list(query, new HashMap<String, Object>()); assertEquals(1, res.size()); assertEquals("Angela Merkel", res.get(0).getName()); }
@Test public void testListSortDesc() { em.createNativeQuery( "insert into address (id, anrede, vorname, nachname, email) values (2, " + Anreden.FRAU.ordinal() + ", 'Berta', 'Merkel', '*****@*****.**')") .executeUpdate(); AddressQuery query = new AddressQuery(); query.setOrderBy(AddressProperties.VORNAME); query.setOrderDescending(true); List<Address> res = dao.list(query, new HashMap<String, Object>()); assertEquals(2, res.size()); assertEquals("Berta Merkel", res.get(0).getName()); }