use of com.github.tfaga.lynx.utils.QueryStringDefaults in project lynx by TFaga.
the class QueryStringDefaultsTest method testDefaultOffset.
@Test
public void testDefaultOffset() {
QueryParameters query = new QueryStringDefaults().defaultOffset(20).builder().query("").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getOffset());
Assert.assertEquals(20, query.getOffset().longValue());
}
use of com.github.tfaga.lynx.utils.QueryStringDefaults in project lynx by TFaga.
the class QueryStringDefaultsTest method testEmptyDefaults.
@Test
public void testEmptyDefaults() {
QueryParameters query = new QueryStringDefaults().builder().query("limit=50&offset=10").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getLimit());
Assert.assertNotNull(query.getOffset());
Assert.assertEquals(50, query.getLimit().longValue());
Assert.assertEquals(10, query.getOffset().longValue());
query = new QueryStringDefaults().builder().query("limit=110&offset=20").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getLimit());
Assert.assertNotNull(query.getOffset());
Assert.assertEquals(100, query.getLimit().longValue());
Assert.assertEquals(20, query.getOffset().longValue());
}
use of com.github.tfaga.lynx.utils.QueryStringDefaults in project lynx by TFaga.
the class QueryStringDefaultsTest method testDisabledPagination.
@Test
public void testDisabledPagination() {
QueryParameters query = new QueryStringDefaults().enablePagination(false).builder().query("limit=100&offset=200").build();
Assert.assertNotNull(query);
Assert.assertNull(query.getLimit());
Assert.assertNull(query.getOffset());
}
use of com.github.tfaga.lynx.utils.QueryStringDefaults in project lynx by TFaga.
the class QueryStringDefaultsTest method testEnabledOrder.
@Test
public void testEnabledOrder() {
QueryParameters query = new QueryStringDefaults().enableOrder(true).builder().query("order=name ASC").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getOrder());
Assert.assertEquals(1, query.getOrder().size());
Assert.assertNotNull(query.getOrder().get(0));
Assert.assertEquals("name", query.getOrder().get(0).getField());
Assert.assertEquals(OrderDirection.ASC, query.getOrder().get(0).getOrder());
query = new QueryStringDefaults().builder().query("order=name ASC").build();
Assert.assertNotNull(query);
Assert.assertNotNull(query.getOrder());
Assert.assertEquals(1, query.getOrder().size());
Assert.assertNotNull(query.getOrder().get(0));
Assert.assertEquals("name", query.getOrder().get(0).getField());
Assert.assertEquals(OrderDirection.ASC, query.getOrder().get(0).getOrder());
}
Aggregations