use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class FilterBuilderTest method propertyIsNotEqual.
@Test
public void propertyIsNotEqual() {
FilterVisitor visitor = spy(new DefaultFilterVisitor() {
});
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.attribute(FOO_ATTRIBUTE).notEqualTo().text("bar");
filter.accept(visitor, null);
filter = builder.attribute(FOO_ATTRIBUTE).is().notEqualTo().text("bar");
filter.accept(visitor, null);
filter = builder.attribute(null).is().notEqualTo().text(null);
filter.accept(visitor, null);
InOrder inOrder = inOrder(visitor);
inOrder.verify(visitor, times(3)).visit(isA(PropertyIsNotEqualTo.class), any());
}
use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class FilterBuilderTest method orNull.
@Test
public void orNull() {
FilterVisitor visitor = spy(new DefaultFilterVisitor() {
});
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.anyOf(builder.attribute(FOO_ATTRIBUTE).is().empty());
filter.accept(visitor, null);
InOrder inOrder = inOrder(visitor);
inOrder.verify(visitor, times(1)).visit(isA(Or.class), any());
inOrder.verify(visitor).visit(isA(PropertyIsNull.class), any());
}
use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class FilterBuilderTest method likeFuzzy.
@Test
public void likeFuzzy() {
FilterVisitor visitor = spy(new DefaultFilterVisitor() {
});
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.attribute(FOO_ATTRIBUTE).is().like().fuzzyText("bar");
filter.accept(visitor, null);
InOrder inOrder = inOrder(visitor);
inOrder.verify(visitor, times(1)).visit(isA(PropertyIsLike.class), any());
// TODO check for fuzzy
}
use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class FilterBuilderTest method after.
@Test
public void after() {
FilterVisitor visitor = spy(new DefaultFilterVisitor() {
});
FilterBuilder builder = new GeotoolsFilterBuilder();
Filter filter = builder.attribute(FOO_ATTRIBUTE).after().date(new Date());
filter.accept(visitor, null);
filter = builder.attribute(FOO_ATTRIBUTE).is().after().date(new Date());
filter.accept(visitor, null);
InOrder inOrder = inOrder(visitor);
inOrder.verify(visitor, times(2)).visit(isA(After.class), any());
}
use of ddf.catalog.filter.FilterBuilder in project ddf by codice.
the class CopyFilterDelegateTest method testFilterModification.
@Test
public void testFilterModification() {
Filter filterIn = FF.equals(TEST_PROPERTY, FOO_LITERAL);
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterDelegate<Filter> delegate = new FilterModifierDelegate(filterBuilder);
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
Filter modifiedFilter = null;
try {
modifiedFilter = fa.adapt(filterIn, delegate);
} catch (UnsupportedQueryException e) {
fail(e.getMessage());
}
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName("testFeatureType");
b.add(TEST_PROPERTY_VALUE, String.class);
b.add("classification", String.class);
SimpleFeatureType featureType = b.buildFeatureType();
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
builder.add(FOO_LITERAL_VALUE);
builder.add("UNCLASS");
SimpleFeature feature = builder.buildFeature("test");
assertTrue(modifiedFilter.evaluate(feature));
}
Aggregations