use of com.yahoo.elide.core.request.Argument in project elide by yahoo.
the class DefaultQueryValidatorTest method testHavingFilterMatchesProjection.
@Test
public void testHavingFilterMatchesProjection() throws ParseException {
SQLTable source = (SQLTable) metaDataStore.getTable("playerStatsView", NO_VERSION);
Map<String, Argument> tableArguments = new HashMap<>();
tableArguments.put("rating", Argument.builder().name("rating").value("Terrible").build());
Map<String, Argument> arguments = new HashMap<>();
arguments.put("format", Argument.builder().name("format").value("lower").build());
FilterExpression havingFilter = filterParser.parseFilterExpression("countryName[format:lower]==usa", playerStatsViewType, false);
Query query = Query.builder().source(source).arguments(tableArguments).dimensionProjection(source.getDimensionProjection("countryName", arguments)).havingFilter(havingFilter).build();
validateQueryDoesNotThrow(query);
}
use of com.yahoo.elide.core.request.Argument in project elide by yahoo.
the class MatchesTemplateVisitorTest method complexExpressionTest.
@Test
public void complexExpressionTest() throws Exception {
String complexExpression = "(lowScore>100;((player.name==Bob*,lowScore>100);(highScore==123)))";
FilterExpression clientExpression = dialect.parseFilterExpression(complexExpression, playerStatsType, true);
FilterExpression templateExpression = dialect.parseFilterExpression("highScore=={{variable}}", playerStatsType, false, true);
Map<String, Argument> extractedArgs = new HashMap<>();
Argument expected = Argument.builder().name("variable").value(123L).build();
assertTrue(MatchesTemplateVisitor.isValid(templateExpression, clientExpression, extractedArgs));
assertEquals(1, extractedArgs.size());
assertEquals(extractedArgs.get("variable"), expected);
}
use of com.yahoo.elide.core.request.Argument in project elide by yahoo.
the class MatchesTemplateVisitorTest method predicateMismatchWithoutTemplateTest.
@Test
public void predicateMismatchWithoutTemplateTest() throws Exception {
FilterExpression clientExpression = dialect.parseFilterExpression("highScore==123", playerStatsType, true);
FilterExpression templateExpression = dialect.parseFilterExpression("highScore==456", 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.request.Argument in project elide by yahoo.
the class MatchesTemplateVisitorTest method disjunctionMatchesTest.
@Test
public void disjunctionMatchesTest() throws Exception {
FilterExpression clientExpression = dialect.parseFilterExpression("lowScore>100,highScore==123", playerStatsType, true);
FilterExpression templateExpression = dialect.parseFilterExpression("lowScore>100,highScore=={{variable}}", playerStatsType, false, true);
Map<String, Argument> extractedArgs = new HashMap<>();
Argument expected = Argument.builder().name("variable").value(123L).build();
assertTrue(MatchesTemplateVisitor.isValid(templateExpression, clientExpression, extractedArgs));
assertEquals(1, extractedArgs.size());
assertEquals(extractedArgs.get("variable"), expected);
}
use of com.yahoo.elide.core.request.Argument in project elide by yahoo.
the class MatchesTemplateVisitorTest method parameterizedFilterMatches.
@Test
public void parameterizedFilterMatches() throws Exception {
FilterExpression clientExpression = dialect.parseFilterExpression("recordedDate[grain:day]=='2020-01-01'", playerStatsType, true);
FilterExpression templateExpression = dialect.parseFilterExpression("recordedDate[grain:day]=={{day}}", playerStatsType, false, true);
Map<String, Argument> extractedArgs = new HashMap<>();
assertTrue(MatchesTemplateVisitor.isValid(templateExpression, clientExpression, extractedArgs));
assertEquals(1, extractedArgs.size());
}
Aggregations