use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class FilterBuilderTest method withinGeoTest.
/**
*/
@Test
public void withinGeoTest() {
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.attribute(Metacard.GEOGRAPHY).within().wkt(POINT_WKT);
filter.accept(new DefaultFilterVisitor() {
@Override
public Object visit(Within filter, Object data) {
Literal literalWrapper = (Literal) filter.getExpression2();
Geometry geometry = (Geometry) literalWrapper.evaluate(null);
geometry.getCentroid().getCoordinate();
return super.visit(filter, data);
}
}, null);
}
use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class FilterBuilderTest method likeXPath.
@Test
public void likeXPath() {
FilterVisitor visitor = spy(new DefaultFilterVisitor() {
});
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.xpath("//foo").like().text("bar");
filter.accept(visitor, null);
filter = builder.xpath("//foo").is().like().text("bar");
filter.accept(visitor, null);
InOrder inOrder = inOrder(visitor);
inOrder.verify(visitor, times(2)).visit(isA(PropertyIsLike.class), any());
}
use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class FilterBuilderTest method operatorDuringNull.
@Test(expected = IllegalArgumentException.class)
public void operatorDuringNull() {
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.attribute("something").during().dates(null, null);
}
use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class FilterBuilderTest method operatorWithinNull.
@Test(expected = IllegalArgumentException.class)
public void operatorWithinNull() {
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.attribute("something").within().wkt(null);
}
use of ddf.catalog.filter.FilterBuilder 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), any());
inOrder.verify(visitor).visit(isA(Or.class), any());
ArgumentCaptor<PropertyIsNull> propertyIsNullArgument = ArgumentCaptor.forClass(PropertyIsNull.class);
verify(visitor).visit(propertyIsNullArgument.capture(), any());
ExpressionVisitor expVisitor = spy(new DefaultExpressionVisitor() {
});
propertyIsNullArgument.getValue().getExpression().accept(expVisitor, null);
ArgumentCaptor<PropertyName> propertyNameArgument = ArgumentCaptor.forClass(PropertyName.class);
verify(expVisitor).visit(propertyNameArgument.capture(), any());
assertEquals(FOO_ATTRIBUTE, propertyNameArgument.getValue().getPropertyName());
}
Aggregations