use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsPagingTest method testEmptyQuery.
@Test
public void testEmptyQuery() {
List<User> users = JPAUtils.queryEntities(em, User.class, new QueryParameters());
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 testLimit.
@Test
public void testLimit() {
QueryParameters q = new QueryParameters();
q.setLimit(10);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(10, users.size());
Assert.assertNotNull(users.get(0).getId());
Assert.assertEquals(1, users.get(0).getId().intValue());
Assert.assertNotNull(users.get(9).getId());
Assert.assertEquals(10, users.get(9).getId().intValue());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsPagingTest method testOffset.
@Test
public void testOffset() {
QueryParameters q = new QueryParameters();
q.setOffset(30);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(70, users.size());
Assert.assertNotNull(users.get(0).getId());
Assert.assertEquals(31, users.get(0).getId().intValue());
Assert.assertNotNull(users.get(69).getId());
Assert.assertEquals(100, users.get(69).getId().intValue());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class QueryStringBuilderFieldsTest method testEmptyFieldWithoutDelimiter.
@Test
public void testEmptyFieldWithoutDelimiter() {
QueryParameters query = QueryParameters.query("fields").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getFields());
Assert.assertEquals(0, query.getFields().size());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class QueryStringBuilderFieldsTest method testSingleField.
@Test
public void testSingleField() {
QueryParameters query = QueryParameters.query("fields=username").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getFields());
Assert.assertEquals(1, query.getFields().size());
Assert.assertEquals("username", query.getFields().get(0));
}
Aggregations