Search in sources :

Example 31 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.

the class RSQLFilterDialectTest method testGlobalExpressionParsingWithComplexAttribute.

@Test
public void testGlobalExpressionParsingWithComplexAttribute() throws Exception {
    MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
    queryParams.add("filter", "homeAddress.street1==*State*");
    FilterExpression expression = dialect.parseGlobalExpression("/author", queryParams, NO_VERSION);
    assertEquals("author.homeAddress.street1 INFIX [State]", expression.toString());
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Example 32 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.

the class RSQLFilterDialectTest method testNotEqualOperator.

@Test
public void testNotEqualOperator() throws Exception {
    MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
    queryParams.add("filter", "title!=Hemingway");
    FilterExpression expression = dialect.parseGlobalExpression("/book", queryParams, NO_VERSION);
    assertEquals("NOT (book.title IN [Hemingway])", expression.toString());
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Example 33 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.

the class RSQLFilterDialectTest method testBetweenOperator.

@Test
public void testBetweenOperator() throws Exception {
    MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
    queryParams.add("filter", "(publishDate=notbetween=(5,10))");
    FilterExpression expression = dialect.parseGlobalExpression("/book", queryParams, NO_VERSION);
    assertEquals("book.publishDate NOTBETWEEN [5, 10]", expression.toString());
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Example 34 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.

the class RSQLFilterDialectTest method testInfixFilterOnPrimitiveIdField.

@Test
public void testInfixFilterOnPrimitiveIdField() throws ParseException {
    MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
    queryParams.add("filter", "id==*1*");
    FilterExpression expression = dialect.parseGlobalExpression("/primitiveTypeId", queryParams, NO_VERSION);
    assertEquals(expression.toString(), "primitiveId.primitiveId INFIX [1]");
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Example 35 with FilterExpression

use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.

the class RSQLFilterDialectTest method testMemberOfToManyRelationship.

@Test
public void testMemberOfToManyRelationship() throws Exception {
    MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>();
    queryParams.add("filter", "authors.name=hasmember='0'");
    FilterExpression expression = dialect.parseGlobalExpression("/book", queryParams, NO_VERSION);
    assertEquals("book.authors.name HASMEMBER [0]", expression.toString());
}
Also used : MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Test(org.junit.jupiter.api.Test)

Aggregations

FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)214 Test (org.junit.jupiter.api.Test)161 OrFilterExpression (com.yahoo.elide.core.filter.expression.OrFilterExpression)91 AndFilterExpression (com.yahoo.elide.core.filter.expression.AndFilterExpression)72 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)49 FilterPredicate (com.yahoo.elide.core.filter.predicates.FilterPredicate)46 Path (com.yahoo.elide.core.Path)44 Query (com.yahoo.elide.datastores.aggregation.query.Query)42 Argument (com.yahoo.elide.core.request.Argument)39 SQLUnitTest (com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)39 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)34 SQLTable (com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable)34 HashMap (java.util.HashMap)29 Book (example.Book)28 NotFilterExpression (com.yahoo.elide.core.filter.expression.NotFilterExpression)24 EntityProjection (com.yahoo.elide.core.request.EntityProjection)22 Date (java.util.Date)21 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)20 Day (com.yahoo.elide.datastores.aggregation.timegrains.Day)19 HashSet (java.util.HashSet)18