Search in sources :

Example 6 with FilterExpression

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

the class FilterExpressionCheckEvaluationVisitor method visitAndExpression.

@Override
public Boolean visitAndExpression(AndFilterExpression expression) {
    FilterExpression left = expression.getLeft();
    FilterExpression right = expression.getRight();
    return left.accept(this) && right.accept(this);
}
Also used : NotFilterExpression(com.yahoo.elide.core.filter.expression.NotFilterExpression) OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression)

Example 7 with FilterExpression

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

the class PermissionToFilterExpressionVisitorTest method testSingleFilterExpression.

@ParameterizedTest
@MethodSource("identityProvider")
public void testSingleFilterExpression(String permission, FilterExpression expected) {
    FilterExpression computed = filterExpressionForPermissions(permission);
    assertEquals(expected, computed, String.format("%s != %s", permission, expected.toString()));
}
Also used : OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 8 with FilterExpression

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

the class PermissionToFilterExpressionVisitorTest method testSimpleExpression.

@ParameterizedTest
@MethodSource("simpleAndProvider")
public void testSimpleExpression(String left, String op, String right, FilterExpression expected) {
    String permission = String.format("%s %s %s", left, op, right);
    FilterExpression computed = filterExpressionForPermissions(permission);
    assertEquals(expected, computed, String.format("%s != %s", permission, expected));
    boolean specialCase = isSpecialCase(computed);
    boolean isFilterable = containsOnlyFilterableExpressions(computed);
    assertTrue(specialCase || isFilterable, String.format("compound expression contains unfilterable clause '%s'", computed));
}
Also used : OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 9 with FilterExpression

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

the class PermissionToFilterExpressionVisitorTest method testNotFilterExpression.

@ParameterizedTest
@MethodSource("notExpressionProvider")
public void testNotFilterExpression(String permission, FilterExpression expected) {
    String expression = String.format("NOT %s", permission);
    FilterExpression computed = filterExpressionForPermissions(expression);
    assertEquals(expected, computed);
}
Also used : OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 10 with FilterExpression

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

the class PermissionToFilterExpressionVisitorTest method testNestedExpressions.

@ParameterizedTest
@MethodSource("nestedExpressionProvider")
public void testNestedExpressions(String left, String join, String compound, FilterExpression expected) {
    String permission = String.format("%s %s (%s)", left, join, compound);
    FilterExpression computed = filterExpressionForPermissions(permission);
    assertEquals(expected, computed, String.format("%s != %s", permission, computed));
    boolean specialCase = isSpecialCase(computed);
    boolean isFilterable = containsOnlyFilterableExpressions(computed);
    assertTrue(specialCase || isFilterable, String.format("compound expression contains unfilterable clause '%s'", computed));
}
Also used : OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

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