Search in sources :

Example 1 with SelectionExpressionConverter

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);
    }
}
Also used : SelectionExpressionConverter(com.yahoo.document.select.convert.SelectionExpressionConverter) ParseException(com.yahoo.document.select.parser.ParseException)

Example 2 with SelectionExpressionConverter

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());
    }
}
Also used : SelectionExpressionConverter(com.yahoo.document.select.convert.SelectionExpressionConverter) ParseException(com.yahoo.document.select.parser.ParseException)

Example 3 with SelectionExpressionConverter

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)));
    }
}
Also used : SelectionExpressionConverter(com.yahoo.document.select.convert.SelectionExpressionConverter)

Aggregations

SelectionExpressionConverter (com.yahoo.document.select.convert.SelectionExpressionConverter)3 ParseException (com.yahoo.document.select.parser.ParseException)2