use of ddf.catalog.filter.FilterAdapter in project ddf by codice.
the class CopyFilterDelegateTest method assertFilterEquals.
private void assertFilterEquals(Filter filterIn) {
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
FilterDelegate<Filter> delegate = new CopyFilterDelegate(filterBuilder);
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
Filter filterCopy = null;
try {
filterCopy = fa.adapt(filterIn, delegate);
} catch (UnsupportedQueryException e) {
fail(e.getMessage());
}
assertNotNull(filterCopy);
// Verify object references are different, indicating a copy was made of the filter
assertNotSame(filterIn, filterCopy);
assertFilterContentsEqual(filterIn, filterCopy);
// Verify filter contents (attributes, operands, etc) are identical
assertThat(filterCopy, is(filterIn));
}
use of ddf.catalog.filter.FilterAdapter 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));
}
use of ddf.catalog.filter.FilterAdapter in project ddf by codice.
the class FilterAdapterTest method assertFilterEquals.
private void assertFilterEquals(String expected, Filter filter) {
FilterDelegate<String> delegate = new FilterToTextDelegate();
FilterAdapter fa = new GeotoolsFilterAdapterImpl();
String result = null;
try {
result = fa.adapt(filter, delegate);
} catch (UnsupportedQueryException e) {
fail(e.getMessage());
}
assertThat(result, is(expected));
}
use of ddf.catalog.filter.FilterAdapter in project ddf by codice.
the class CswQueryFactoryTest method testQueryTags.
@Test
public void testQueryTags() throws Exception {
queryFactory.setSchemaToTagsMapping(new String[] { CswConstants.CSW_OUTPUT_SCHEMA + "=myTag" });
List<String> ids = new ArrayList<>();
ids.add("someId");
FilterAdapter adapter = new GeotoolsFilterAdapterImpl();
assertThat(adapter.adapt(queryFactory.updateQueryRequestTags(queryFactory.getQueryById(ids), CswConstants.CSW_OUTPUT_SCHEMA).getQuery(), new TagsFilterDelegate("myTag")), is(true));
}
use of ddf.catalog.filter.FilterAdapter in project ddf by codice.
the class CswQueryFactoryTest method setUp.
@org.junit.Before
public void setUp() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
filterBuilder = new GeotoolsFilterBuilder();
FilterAdapter filterAdapter = new GeotoolsFilterAdapterImpl();
metacardTypeList = new ArrayList<>();
queryFactory = new CswQueryFactory(filterBuilder, filterAdapter, getCswMetacardType(), metacardTypeList);
AttributeRegistry mockAttributeRegistry = mock(AttributeRegistry.class);
when(mockAttributeRegistry.lookup(TITLE_TEST_ATTRIBUTE)).thenReturn(Optional.of(mock(AttributeDescriptor.class)));
queryFactory.setAttributeRegistry(mockAttributeRegistry);
polygon = new WKTReader().read(POLYGON_STR);
gmlObjectFactory = new net.opengis.gml.v_3_1_1.ObjectFactory();
filterObjectFactory = new ObjectFactory();
}
Aggregations