use of ddf.catalog.source.UnsupportedQueryException 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.source.UnsupportedQueryException 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.source.UnsupportedQueryException 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.source.UnsupportedQueryException in project ddf by codice.
the class CatalogMetrics method recordSourceQueryExceptions.
private void recordSourceQueryExceptions(QueryResponse response) {
Set<ProcessingDetails> processingDetails = (Set<ProcessingDetails>) response.getProcessingDetails();
if (processingDetails == null || processingDetails.iterator() == null) {
return;
}
Iterator<ProcessingDetails> iterator = processingDetails.iterator();
while (iterator.hasNext()) {
ProcessingDetails next = iterator.next();
if (next != null && next.getException() != null) {
if (next.getException() instanceof UnsupportedQueryException) {
unsupportedQueryExceptions.mark();
} else if (next.getException() instanceof SourceUnavailableException) {
sourceUnavailableExceptions.mark();
} else if (next.getException() instanceof FederationException) {
federationExceptions.mark();
}
exceptions.mark();
}
}
return;
}
use of ddf.catalog.source.UnsupportedQueryException in project ddf by codice.
the class CatalogMetricsTest method catalogExceptionMetric.
@Test
public void catalogExceptionMetric() throws Exception {
QueryResponse response = new QueryResponseImpl(new QueryRequestImpl(new QueryImpl(idFilter)));
Set<ProcessingDetails> details = response.getProcessingDetails();
details.addAll(new HashSet<ProcessingDetails>() {
{
add(new ProcessingDetailsImpl("source1", new UnsupportedQueryException()));
add(new ProcessingDetailsImpl("source2", new SourceUnavailableException()));
add(new ProcessingDetailsImpl("source3", new FederationException()));
add(new ProcessingDetailsImpl("source4", new Exception()));
}
});
underTest.process(response);
assertThat(underTest.exceptions.getCount(), is(4L));
assertThat(underTest.unsupportedQueryExceptions.getCount(), is(1L));
assertThat(underTest.sourceUnavailableExceptions.getCount(), is(1L));
assertThat(underTest.federationExceptions.getCount(), is(1L));
}
Aggregations