Search in sources :

Example 51 with QueryParameters

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

the class QueryStringBuilderFiltersTest method testQueryEncoded.

@Test
public void testQueryEncoded() {
    QueryParameters query = QueryParameters.queryEncoded("where=firstname:like:Kar%25").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFilters());
    Assert.assertEquals(1, query.getFilters().size());
    Assert.assertEquals("firstname", query.getFilters().get(0).getField());
    Assert.assertNotNull(query.getFilters().get(0).getOperation());
    Assert.assertEquals(FilterOperation.LIKE, query.getFilters().get(0).getOperation());
    Assert.assertEquals("Kar%", query.getFilters().get(0).getValue());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 52 with QueryParameters

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

the class QueryStringBuilderOrderTest method testEmptyOrder.

@Test
public void testEmptyOrder() {
    QueryParameters query = QueryParameters.query("order=").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getOrder());
    Assert.assertEquals(0, query.getOrder().size());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 53 with QueryParameters

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

the class QueryStringBuilderOrderTest method testMultipleOrders.

@Test
public void testMultipleOrders() {
    QueryParameters query = QueryParameters.query("order=username ASC,lastname DESC").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getOrder());
    Assert.assertEquals(2, query.getOrder().size());
    Assert.assertEquals("username", query.getOrder().get(0).getField());
    Assert.assertNotNull(query.getOrder().get(0).getOrder());
    Assert.assertEquals(OrderDirection.ASC, query.getOrder().get(0).getOrder());
    Assert.assertEquals("lastname", query.getOrder().get(1).getField());
    Assert.assertNotNull(query.getOrder().get(1).getOrder());
    Assert.assertEquals(OrderDirection.DESC, query.getOrder().get(1).getOrder());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 54 with QueryParameters

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

the class QueryStringBuilderOrderTest method testQueryOrderObject.

@Test
public void testQueryOrderObject() {
    QueryParameters query = new QueryParameters();
    Assert.assertNotNull(query.getOrder());
    Assert.assertEquals(0, query.getOrder().size());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 55 with QueryParameters

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

the class QueryStringBuilderOrderTest method testMultipleOrderKeys.

@Test
public void testMultipleOrderKeys() {
    QueryParameters query = QueryParameters.query("order=username,firstname&sort=lastname DESC").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getOrder());
    Assert.assertEquals(1, query.getOrder().size());
    Assert.assertEquals("lastname", query.getOrder().get(0).getField());
    Assert.assertNotNull(query.getOrder().get(0).getOrder());
    Assert.assertEquals(OrderDirection.DESC, query.getOrder().get(0).getOrder());
}
Also used : 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