use of com.yahoo.document.select.convert.SelectionExpressionConverter in project vespa by vespa-engine.
the class DocumentSelectorTestCase method assertVisitWithValidNowWorks.
public void assertVisitWithValidNowWorks(String expression) throws ParseException {
DocumentSelector selector = new DocumentSelector(expression);
NowCheckVisitor visitor = new NowCheckVisitor();
selector.visit(visitor);
assertTrue(visitor.requiresConversion());
SelectionExpressionConverter converter = new SelectionExpressionConverter();
try {
selector.visit(converter);
} catch (Exception e) {
assertFalse("Converter throws exception : " + e.getMessage(), true);
}
}
use of com.yahoo.document.select.convert.SelectionExpressionConverter in project vespa by vespa-engine.
the class DocumentSelectorTestCase method assertVisitWithInvalidNowFails.
public void assertVisitWithInvalidNowFails(String expression, String expectedError) throws ParseException {
DocumentSelector selector = new DocumentSelector(expression);
NowCheckVisitor visitor = new NowCheckVisitor();
selector.visit(visitor);
assertTrue(visitor.requiresConversion());
SelectionExpressionConverter converter = new SelectionExpressionConverter();
try {
selector.visit(converter);
assertFalse("Should not be able to convert " + expression + " query", true);
} catch (Exception e) {
assertEquals(expectedError, e.getMessage());
}
}
use of com.yahoo.document.select.convert.SelectionExpressionConverter in project vespa by vespa-engine.
the class DocumentSelectorTestCase method assertThatQueriesAreCreated.
public void assertThatQueriesAreCreated(String selection, List<String> expectedDoctypes, List<String> expectedQueries) throws ParseException {
DocumentSelector selector = new DocumentSelector(selection);
NowCheckVisitor visitor = new NowCheckVisitor();
selector.visit(visitor);
assertTrue(visitor.requiresConversion());
SelectionExpressionConverter converter = new SelectionExpressionConverter();
selector.visit(converter);
Map<String, String> queryMap = converter.getQueryMap();
assertEquals(expectedQueries.size(), queryMap.size());
for (int i = 0; i < expectedQueries.size(); i++) {
assertTrue(queryMap.containsKey(expectedDoctypes.get(i)));
assertEquals(expectedQueries.get(i), queryMap.get(expectedDoctypes.get(i)));
}
}
Aggregations