use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.
the class MatchesTemplateVisitorTest method conjunctionDoesNotContainTest.
@Test
public void conjunctionDoesNotContainTest() throws Exception {
FilterExpression clientExpression = dialect.parseFilterExpression("lowScore>100;player.name==Bob*", playerStatsType, true);
FilterExpression templateExpression = dialect.parseFilterExpression("highScore=={{variable}}", playerStatsType, false, true);
Map<String, Argument> extractedArgs = new HashMap<>();
assertFalse(MatchesTemplateVisitor.isValid(templateExpression, clientExpression, extractedArgs));
assertEquals(0, extractedArgs.size());
}
use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.
the class MatchesTemplateVisitorTest method predicateMatchTest.
@Test
public void predicateMatchTest() throws Exception {
FilterExpression clientExpression = dialect.parseFilterExpression("highScore==123", playerStatsType, true);
FilterExpression templateExpression = dialect.parseFilterExpression("highScore=={{foo}}", playerStatsType, false, true);
Map<String, Argument> extractedArgs = new HashMap<>();
Argument expected = Argument.builder().name("foo").value(123L).build();
assertTrue(MatchesTemplateVisitor.isValid(templateExpression, clientExpression, extractedArgs));
assertEquals(1, extractedArgs.size());
assertEquals(extractedArgs.get("foo"), expected);
}
use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.
the class MatchesTemplateVisitorTest method disjunctionContainsTest.
@Test
public void disjunctionContainsTest() throws Exception {
FilterExpression clientExpression = dialect.parseFilterExpression("lowScore>100,highScore==123", playerStatsType, true);
FilterExpression templateExpression = dialect.parseFilterExpression("highScore=={{variable}}", playerStatsType, false, true);
Map<String, Argument> extractedArgs = new HashMap<>();
assertFalse(MatchesTemplateVisitor.isValid(templateExpression, clientExpression, extractedArgs));
assertEquals(0, extractedArgs.size());
}
use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.
the class DefaultQueryPlanMergerTest method testCannotMergeMismatchedNestedWhere.
@Test
public void testCannotMergeMismatchedNestedWhere() {
Queryable source = mock(Queryable.class);
// A root source.
when(source.getSource()).thenReturn(source);
MetricProjection m1 = mock(MetricProjection.class);
MetricProjection m2 = mock(MetricProjection.class);
when(m1.getName()).thenReturn("m1");
when(m2.getName()).thenReturn("m2");
when(m1.canNest(any(), any())).thenReturn(true);
when(m1.nest(any(), any(), anyBoolean())).thenReturn(Pair.of(m1, Set.of(m1)));
when(m2.canNest(any(), any())).thenReturn(true);
when(m2.nest(any(), any(), anyBoolean())).thenReturn(Pair.of(m2, Set.of(m2)));
FilterExpression filterA = mock(FilterExpression.class);
FilterExpression filterB = mock(FilterExpression.class);
QueryPlan a = QueryPlan.builder().source(source).whereFilter(filterA).metricProjection(m1).build();
QueryPlan nested = QueryPlan.builder().source(source).whereFilter(filterB).metricProjection(m2).build();
QueryPlan b = QueryPlan.builder().source(nested).metricProjection(m2).build();
MetaDataStore metaDataStore = mock(MetaDataStore.class);
DefaultQueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
assertFalse(merger.canMerge(a, b));
assertFalse(merger.canMerge(b, a));
}
use of com.yahoo.elide.core.filter.expression.FilterExpression in project elide by yahoo.
the class JpaDataStoreTransactionTest method getTestArguments.
private Stream<Arguments> getTestArguments() throws Exception {
RSQLFilterDialect parser = RSQLFilterDialect.builder().dictionary(dictionary).build();
FilterExpression expression = parser.parse(ClassType.of(Book.class), Collections.emptySet(), "title=='foo'", NO_VERSION);
return Stream.of(arguments(true, 1, null, true), arguments(true, 2, null, true), arguments(false, 1, null, true), arguments(false, 2, null, true), arguments(true, 1, expression, false), arguments(true, 2, expression, true), arguments(false, 1, expression, false), arguments(false, 2, expression, false));
}
Aggregations