use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsOrderTest method testNonExistentColumn.
@Test
public void testNonExistentColumn() {
QueryOrder qo = new QueryOrder();
qo.setField("lstnm");
qo.setOrder(OrderDirection.DESC);
QueryParameters q = new QueryParameters();
q.getOrder().add(qo);
try {
JPAUtils.queryEntities(em, User.class, q);
Assert.fail("No exception was thrown");
} catch (NoSuchEntityFieldException e) {
Assert.assertEquals("lstnm", e.getField());
}
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsOrderTest method testEmbedded.
@Test
public void testEmbedded() {
QueryOrder qo = new QueryOrder();
qo.setField("address.country");
QueryParameters q = new QueryParameters();
q.getOrder().add(qo);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(100, users.size());
Assert.assertNotNull(users.get(0).getAddress());
Assert.assertNotNull(users.get(0).getAddress().getCountry());
Assert.assertEquals("Argentina", users.get(0).getAddress().getCountry());
Assert.assertNotNull(users.get(99).getAddress());
Assert.assertNotNull(users.get(99).getAddress().getCountry());
Assert.assertEquals("Venezuela", users.get(99).getAddress().getCountry());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsOrderTest method testNullField.
@Test
public void testNullField() {
QueryOrder qo = new QueryOrder();
QueryParameters q = new QueryParameters();
q.getOrder().add(qo);
List<User> users = JPAUtils.queryEntities(em, User.class, q).stream().sorted(Comparator.comparing(User::getId)).collect(Collectors.toList());
Assert.assertNotNull(users);
Assert.assertEquals(100, users.size());
Assert.assertNotNull(users.get(0).getLastname());
Assert.assertEquals("Ramos", users.get(0).getLastname());
Assert.assertNotNull(users.get(99).getLastname());
Assert.assertEquals("Hall", users.get(99).getLastname());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsPagingTest method testLimitTooBig.
@Test
public void testLimitTooBig() {
QueryParameters q = new QueryParameters();
q.setLimit(300);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(100, users.size());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsPagingTest method testOffsetOutOfBounds.
@Test
public void testOffsetOutOfBounds() {
QueryParameters q = new QueryParameters();
q.setOffset(200);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(0, users.size());
}
Aggregations