Search in sources :

Example 61 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.

the class QueryStringBuilderPagingTest method testOffsetUriObject.

@Test
public void testOffsetUriObject() throws URISyntaxException {
    URI uri = new URI("api.github.com/tfaga/repos?offset=12312");
    QueryParameters query = QueryParameters.uri(uri).build();
    Assert.assertNotNull(query.getOffset());
    Assert.assertEquals(12312, query.getOffset().longValue());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) URI(java.net.URI) Test(org.junit.Test)

Example 62 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.

the class QueryStringBuilderPagingTest method testDefaultOffset.

@Test
public void testDefaultOffset() {
    QueryParameters query = QueryParameters.query("limit=321").defaultOffset(0).build();
    Assert.assertNotNull(query.getLimit());
    Assert.assertNotNull(query.getOffset());
    Assert.assertEquals(321, query.getLimit().longValue());
    Assert.assertEquals(0, query.getOffset().longValue());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 63 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.

the class QueryStringBuilderPagingTest method testLimit.

@Test
public void testLimit() {
    QueryParameters query = QueryParameters.query("limit=123").build();
    Assert.assertNotNull(query.getLimit());
    Assert.assertEquals(123, query.getLimit().longValue());
    query = QueryParameters.query("max=321").build();
    Assert.assertNotNull(query.getLimit());
    Assert.assertEquals(321, query.getLimit().longValue());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 64 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters 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 65 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters 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)

Aggregations

QueryParameters (com.github.tfaga.lynx.beans.QueryParameters)158 Test (org.junit.Test)155 User (com.github.tfaga.lynx.test.entities.User)46 QueryFilter (com.github.tfaga.lynx.beans.QueryFilter)44 QueryStringDefaults (com.github.tfaga.lynx.utils.QueryStringDefaults)14 QueryOrder (com.github.tfaga.lynx.beans.QueryOrder)13 Project (com.github.tfaga.lynx.test.entities.Project)12 NoSuchEntityFieldException (com.github.tfaga.lynx.exceptions.NoSuchEntityFieldException)6 Date (java.util.Date)6 URI (java.net.URI)4 CriteriaField (com.github.tfaga.lynx.beans.CriteriaField)2 CriteriaWhereQuery (com.github.tfaga.lynx.beans.CriteriaWhereQuery)2 OrderDirection (com.github.tfaga.lynx.enums.OrderDirection)2 InvalidEntityFieldException (com.github.tfaga.lynx.exceptions.InvalidEntityFieldException)2 InvalidFieldValueException (com.github.tfaga.lynx.exceptions.InvalidFieldValueException)2 CriteriaFilter (com.github.tfaga.lynx.interfaces.CriteriaFilter)2 Field (java.lang.reflect.Field)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ZonedDateTime (java.time.ZonedDateTime)2 DateTimeParseException (java.time.format.DateTimeParseException)2