Search in sources :

Example 11 with QueryStringDefaults

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());
}
Also used : QueryStringDefaults(com.github.tfaga.lynx.utils.QueryStringDefaults) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 12 with QueryStringDefaults

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());
}
Also used : QueryStringDefaults(com.github.tfaga.lynx.utils.QueryStringDefaults) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 13 with QueryStringDefaults

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());
}
Also used : QueryStringDefaults(com.github.tfaga.lynx.utils.QueryStringDefaults) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 14 with QueryStringDefaults

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());
}
Also used : QueryStringDefaults(com.github.tfaga.lynx.utils.QueryStringDefaults) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Aggregations

QueryParameters (com.github.tfaga.lynx.beans.QueryParameters)14 QueryStringDefaults (com.github.tfaga.lynx.utils.QueryStringDefaults)14 Test (org.junit.Test)14