use of org.geotools.filter.visitor.DefaultExpressionVisitor in project ddf by codice.
the class FilterBuilderTest method andOrNull.
@Test
public void andOrNull() {
FilterVisitor visitor = spy(new DefaultFilterVisitor() {
});
// FilterBuilder builder = new GeotoolsFilterBuilder();
//
//
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.allOf(builder.anyOf(builder.attribute(FOO_ATTRIBUTE).is().empty()));
filter.accept(visitor, null);
InOrder inOrder = inOrder(visitor);
inOrder.verify(visitor, times(1)).visit(isA(And.class), anyObject());
inOrder.verify(visitor).visit(isA(Or.class), anyObject());
ArgumentCaptor<PropertyIsNull> propertyIsNullArgument = ArgumentCaptor.forClass(PropertyIsNull.class);
verify(visitor).visit(propertyIsNullArgument.capture(), anyObject());
ExpressionVisitor expVisitor = spy(new DefaultExpressionVisitor() {
});
propertyIsNullArgument.getValue().getExpression().accept(expVisitor, null);
ArgumentCaptor<PropertyName> propertyNameArgument = ArgumentCaptor.forClass(PropertyName.class);
verify(expVisitor).visit(propertyNameArgument.capture(), anyObject());
assertEquals(FOO_ATTRIBUTE, propertyNameArgument.getValue().getPropertyName());
}
use of org.geotools.filter.visitor.DefaultExpressionVisitor in project ddf by codice.
the class FilterBuilderTest method afterDate.
@Test
public void afterDate() {
final Date date = new Date();
FilterVisitor visitor = spy(new DefaultFilterVisitor() {
});
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.attribute(FOO_ATTRIBUTE).is().after().date(date);
filter.accept(visitor, null);
ArgumentCaptor<After> expressionArgument = ArgumentCaptor.forClass(After.class);
verify(visitor).visit(expressionArgument.capture(), anyObject());
ExpressionVisitor expVisitor = spy(new DefaultExpressionVisitor() {
});
expressionArgument.getValue().getExpression1().accept(expVisitor, null);
ArgumentCaptor<PropertyName> propertyNameArgument = ArgumentCaptor.forClass(PropertyName.class);
verify(expVisitor).visit(propertyNameArgument.capture(), anyObject());
assertEquals(FOO_ATTRIBUTE, propertyNameArgument.getValue().getPropertyName());
expressionArgument.getValue().getExpression2().accept(expVisitor, null);
ArgumentCaptor<Literal> literalArgument = ArgumentCaptor.forClass(Literal.class);
verify(expVisitor).visit(literalArgument.capture(), anyObject());
assertEquals(date, ((Instant) literalArgument.getValue().getValue()).getPosition().getDate());
}
Aggregations