Search in sources :

Example 1 with QueryStringDefaults

use of com.github.tfaga.lynx.utils.QueryStringDefaults in project lynx by TFaga.

the class QueryStringDefaultsTest method testEnabledPagination.

@Test
public void testEnabledPagination() {
    QueryParameters query = new QueryStringDefaults().enablePagination(true).builder().query("limit=100&offset=200").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getLimit());
    Assert.assertNotNull(query.getOffset());
    Assert.assertEquals(100, query.getLimit().longValue());
    Assert.assertEquals(200, query.getOffset().longValue());
    query = new QueryStringDefaults().builder().query("limit=100&offset=200").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getLimit());
    Assert.assertNotNull(query.getOffset());
    Assert.assertEquals(100, query.getLimit().longValue());
    Assert.assertEquals(200, query.getOffset().longValue());
}
Also used : QueryStringDefaults(com.github.tfaga.lynx.utils.QueryStringDefaults) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 2 with QueryStringDefaults

use of com.github.tfaga.lynx.utils.QueryStringDefaults in project lynx by TFaga.

the class QueryStringDefaultsTest method testEnabledFields.

@Test
public void testEnabledFields() {
    QueryParameters query = new QueryStringDefaults().enableFields(true).builder().query("fields=name,email").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFields());
    Assert.assertEquals(2, query.getFields().size());
    Assert.assertEquals("name", query.getFields().get(0));
    Assert.assertEquals("email", query.getFields().get(1));
    query = new QueryStringDefaults().builder().query("fields=name,email").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFields());
    Assert.assertEquals(2, query.getFields().size());
    Assert.assertEquals("name", query.getFields().get(0));
    Assert.assertEquals("email", query.getFields().get(1));
}
Also used : QueryStringDefaults(com.github.tfaga.lynx.utils.QueryStringDefaults) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 3 with QueryStringDefaults

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

Example 4 with QueryStringDefaults

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

Example 5 with QueryStringDefaults

use of com.github.tfaga.lynx.utils.QueryStringDefaults 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());
}
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