use of org.locationtech.geowave.core.store.query.filter.expression.text.TextBinaryPredicate in project geowave by locationtech.
the class GWQLParserTest method testTextPredicateFunctions.
@Test
public void testTextPredicateFunctions() {
final DataStore dataStore = createDataStore();
String statement = "SELECT * FROM type WHERE strStartsWith(pid, 'val')";
Statement gwStatement = GWQLParser.parseStatement(dataStore, statement);
assertTrue(gwStatement instanceof SelectStatement);
SelectStatement<?> selectStatement = (SelectStatement<?>) gwStatement;
assertNotNull(selectStatement.getFilter());
Filter filter = selectStatement.getFilter();
assertTrue(filter instanceof StartsWith);
TextBinaryPredicate predicate = (TextBinaryPredicate) filter;
assertFalse(predicate.isIgnoreCase());
assertTrue(predicate.getExpression1() instanceof TextFieldValue);
assertEquals("pid", ((TextFieldValue) predicate.getExpression1()).getFieldName());
assertTrue(predicate.getExpression2() instanceof TextLiteral);
assertEquals("val", ((TextLiteral) predicate.getExpression2()).getValue());
statement = "SELECT * FROM type WHERE strStartsWith(pid, 'val', true)";
gwStatement = GWQLParser.parseStatement(dataStore, statement);
assertTrue(gwStatement instanceof SelectStatement);
selectStatement = (SelectStatement<?>) gwStatement;
assertNotNull(selectStatement.getFilter());
filter = selectStatement.getFilter();
assertTrue(filter instanceof StartsWith);
predicate = (TextBinaryPredicate) filter;
assertTrue(predicate.isIgnoreCase());
assertTrue(predicate.getExpression1() instanceof TextFieldValue);
assertEquals("pid", ((TextFieldValue) predicate.getExpression1()).getFieldName());
assertTrue(predicate.getExpression2() instanceof TextLiteral);
assertEquals("val", ((TextLiteral) predicate.getExpression2()).getValue());
statement = "SELECT * FROM type WHERE strEndsWith(pid, 'val')";
gwStatement = GWQLParser.parseStatement(dataStore, statement);
assertTrue(gwStatement instanceof SelectStatement);
selectStatement = (SelectStatement<?>) gwStatement;
assertNotNull(selectStatement.getFilter());
filter = selectStatement.getFilter();
assertTrue(filter instanceof EndsWith);
predicate = (TextBinaryPredicate) filter;
assertFalse(predicate.isIgnoreCase());
assertTrue(predicate.getExpression1() instanceof TextFieldValue);
assertEquals("pid", ((TextFieldValue) predicate.getExpression1()).getFieldName());
assertTrue(predicate.getExpression2() instanceof TextLiteral);
assertEquals("val", ((TextLiteral) predicate.getExpression2()).getValue());
statement = "SELECT * FROM type WHERE strEndsWith(pid, 'val', true)";
gwStatement = GWQLParser.parseStatement(dataStore, statement);
assertTrue(gwStatement instanceof SelectStatement);
selectStatement = (SelectStatement<?>) gwStatement;
assertNotNull(selectStatement.getFilter());
filter = selectStatement.getFilter();
assertTrue(filter instanceof EndsWith);
predicate = (TextBinaryPredicate) filter;
assertTrue(predicate.isIgnoreCase());
assertTrue(predicate.getExpression1() instanceof TextFieldValue);
assertEquals("pid", ((TextFieldValue) predicate.getExpression1()).getFieldName());
assertTrue(predicate.getExpression2() instanceof TextLiteral);
assertEquals("val", ((TextLiteral) predicate.getExpression2()).getValue());
statement = "SELECT * FROM type WHERE strContains(pid, 'val')";
gwStatement = GWQLParser.parseStatement(dataStore, statement);
assertTrue(gwStatement instanceof SelectStatement);
selectStatement = (SelectStatement<?>) gwStatement;
assertNotNull(selectStatement.getFilter());
filter = selectStatement.getFilter();
assertTrue(filter instanceof Contains);
predicate = (TextBinaryPredicate) filter;
assertFalse(predicate.isIgnoreCase());
assertTrue(predicate.getExpression1() instanceof TextFieldValue);
assertEquals("pid", ((TextFieldValue) predicate.getExpression1()).getFieldName());
assertTrue(predicate.getExpression2() instanceof TextLiteral);
assertEquals("val", ((TextLiteral) predicate.getExpression2()).getValue());
statement = "SELECT * FROM type WHERE strContains(pid, 'val', true)";
gwStatement = GWQLParser.parseStatement(dataStore, statement);
assertTrue(gwStatement instanceof SelectStatement);
selectStatement = (SelectStatement<?>) gwStatement;
assertNotNull(selectStatement.getFilter());
filter = selectStatement.getFilter();
assertTrue(filter instanceof Contains);
predicate = (TextBinaryPredicate) filter;
assertTrue(predicate.isIgnoreCase());
assertTrue(predicate.getExpression1() instanceof TextFieldValue);
assertEquals("pid", ((TextFieldValue) predicate.getExpression1()).getFieldName());
assertTrue(predicate.getExpression2() instanceof TextLiteral);
assertEquals("val", ((TextLiteral) predicate.getExpression2()).getValue());
}
Aggregations