Search in sources :

Example 86 with QueryParameters

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

the class QueryStringBuilderFiltersTest method testMultipleFiltersWithPlus.

@Test
public void testMultipleFiltersWithPlus() {
    QueryParameters query = QueryParameters.query("where=username:eq:'test test'+lastname:gte:gale").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFilters());
    Assert.assertEquals(2, query.getFilters().size());
    Assert.assertEquals("username", query.getFilters().get(0).getField());
    Assert.assertNotNull(query.getFilters().get(0).getOperation());
    Assert.assertEquals(FilterOperation.EQ, query.getFilters().get(0).getOperation());
    Assert.assertEquals("test test", query.getFilters().get(0).getValue());
    Assert.assertEquals("lastname", query.getFilters().get(1).getField());
    Assert.assertNotNull(query.getFilters().get(1).getOperation());
    Assert.assertEquals(FilterOperation.GTE, query.getFilters().get(1).getOperation());
    Assert.assertEquals("gale", query.getFilters().get(1).getValue());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 87 with QueryParameters

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

the class QueryStringBuilderFiltersTest method testUriEncoded.

@Test
public void testUriEncoded() {
    QueryParameters query = QueryParameters.uriEncoded("api.github" + ".com/tfaga/repos?where=firstname:like:Kar%25%20").build();
    Boolean a = Boolean.parseBoolean("asdadas");
    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 88 with QueryParameters

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

the class QueryStringBuilderFiltersTest method testMultipleKeyFilters.

@Test
public void testMultipleKeyFilters() {
    QueryParameters query = QueryParameters.query("where=username:eq:'test test' " + "lastname:gte:gale&filter=country:neq:SI").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFilters());
    Assert.assertEquals(1, query.getFilters().size());
    Assert.assertEquals("country", query.getFilters().get(0).getField());
    Assert.assertNotNull(query.getFilters().get(0).getOperation());
    Assert.assertEquals(FilterOperation.NEQ, query.getFilters().get(0).getOperation());
    Assert.assertEquals("SI", query.getFilters().get(0).getValue());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 89 with QueryParameters

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

the class QueryStringBuilderFiltersTest method testQuotesInNinicFilter.

@Test
public void testQuotesInNinicFilter() {
    QueryParameters query = QueryParameters.query("where=country:ninic:['Czech Republic','United States']").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFilters());
    Assert.assertEquals(1, query.getFilters().size());
    Assert.assertEquals("country", query.getFilters().get(0).getField());
    Assert.assertNotNull(query.getFilters().get(0).getOperation());
    Assert.assertEquals(FilterOperation.NINIC, query.getFilters().get(0).getOperation());
    Assert.assertNull(query.getFilters().get(0).getValue());
    Assert.assertEquals(2, query.getFilters().get(0).getValues().size());
    Assert.assertEquals("Czech Republic", query.getFilters().get(0).getValues().get(0));
    Assert.assertEquals("United States", query.getFilters().get(0).getValues().get(1));
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 90 with QueryParameters

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

the class QueryStringBuilderFiltersTest method testDisabledFilters.

@Test
public void testDisabledFilters() {
    QueryParameters query = QueryParameters.query("filter=username:eq:test").enableFilters(false).build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFilters());
    Assert.assertEquals(0, query.getFilters().size());
}
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