use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class QueryStringDefaultsTest method testEmpty.
@Test
public void testEmpty() {
QueryParameters query = new QueryStringDefaults().builder().query("").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getLimit());
Assert.assertNotNull(query.getOffset());
Assert.assertEquals(10, query.getLimit().longValue());
Assert.assertEquals(0, query.getOffset().longValue());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class QueryStringDefaultsTest method testEnabledFilters.
@Test
public void testEnabledFilters() {
QueryParameters query = new QueryStringDefaults().enableFilters(true).builder().query("where=name:eq:tilen").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getFilters());
Assert.assertEquals(1, query.getFilters().size());
Assert.assertNotNull(query.getFilters().get(0));
Assert.assertEquals("name", query.getFilters().get(0).getField());
Assert.assertEquals(FilterOperation.EQ, query.getFilters().get(0).getOperation());
Assert.assertEquals("tilen", query.getFilters().get(0).getValue());
query = new QueryStringDefaults().builder().query("where=name:eq:tilen").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getFilters());
Assert.assertEquals(1, query.getFilters().size());
Assert.assertNotNull(query.getFilters().get(0));
Assert.assertEquals("name", query.getFilters().get(0).getField());
Assert.assertEquals(FilterOperation.EQ, query.getFilters().get(0).getOperation());
Assert.assertEquals("tilen", query.getFilters().get(0).getValue());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class QueryStringDefaultsTest method testMaxLimit.
@Test
public void testMaxLimit() {
QueryParameters query = new QueryStringDefaults().maxLimit(60).builder().query("limit=200").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getLimit());
Assert.assertEquals(60, query.getLimit().longValue());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class QueryStringDefaultsTest method testDisabledFields.
@Test
public void testDisabledFields() {
QueryParameters query = new QueryStringDefaults().enableFields(false).builder().query("fields=name,email").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 JPAUtilsPagingTest method testLimitWithOffset.
@Test
public void testLimitWithOffset() {
QueryOrder qo = new QueryOrder();
qo.setField("id");
qo.setOrder(OrderDirection.ASC);
QueryParameters q = new QueryParameters();
q.setLimit(25);
q.setOffset(0);
q.getOrder().add(qo);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(25, users.size());
q.setOffset(24);
List<User> usersOffseted = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(usersOffseted);
Assert.assertEquals(25, usersOffseted.size());
Assert.assertNotNull(users.get(24).getId());
Assert.assertNotNull(usersOffseted.get(0).getId());
Assert.assertEquals(users.get(24).getId().intValue(), usersOffseted.get(0).getId().intValue());
// Assert.assertEquals(65, users.get(24).getId().intValue());
}
Aggregations