Search in sources :

Example 96 with QueryParameters

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

the class QueryStringBuilderOrderTest method testSingleOrder.

@Test
public void testSingleOrder() {
    QueryParameters query = QueryParameters.query("order=username DESC").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getOrder());
    Assert.assertEquals(1, query.getOrder().size());
    Assert.assertEquals("username", 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)

Example 97 with QueryParameters

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

the class QueryStringBuilderOrderTest method testDisabledOrder.

@Test
public void testDisabledOrder() {
    QueryParameters query = QueryParameters.query("order=username DESC").enableOrder(false).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 98 with QueryParameters

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

the class QueryStringBuilderOrderTest method testMultipleOrdersWithEmptyBetween.

@Test
public void testMultipleOrdersWithEmptyBetween() {
    QueryParameters query = QueryParameters.query("order=username,,,,firstname 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("firstname", 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 99 with QueryParameters

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

the class QueryStringBuilderOrderTest method testOrderWithoutDirection.

@Test
public void testOrderWithoutDirection() {
    QueryParameters query = QueryParameters.query("sort=username").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getOrder());
    Assert.assertEquals(1, 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());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 100 with QueryParameters

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

the class QueryStringBuilderOrderTest method testMultipleOrderRepeatFields.

@Test
public void testMultipleOrderRepeatFields() {
    QueryParameters query = QueryParameters.query("order=username,firstname,username 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("firstname", query.getOrder().get(1).getField());
    Assert.assertNotNull(query.getOrder().get(1).getOrder());
    Assert.assertEquals(OrderDirection.ASC, query.getOrder().get(1).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