use of ddf.catalog.plugin.PreQueryPlugin in project ddf by codice.
the class CatalogFrameworkImplTest method testPreQueryStopExecution.
@Test(expected = FederationException.class)
public void testPreQueryStopExecution() throws UnsupportedQueryException, FederationException, SourceUnavailableException {
MockMemoryProvider provider = new MockMemoryProvider("Provider", "Provider", "v1.0", "DDF", new HashSet<ContentType>(), true, new Date());
FederationStrategy federationStrategy = mock(FederationStrategy.class);
QueryRequest request = mock(QueryRequest.class);
when(request.getQuery()).thenReturn(mock(Query.class));
PreQueryPlugin stopQueryPlugin = new PreQueryPlugin() {
@Override
public QueryRequest process(QueryRequest input) throws PluginExecutionException, StopProcessingException {
throw new StopProcessingException("Testing that the framework will stop the query.");
}
};
FrameworkProperties frameworkProperties = new FrameworkProperties();
frameworkProperties.setPreQuery(Arrays.asList(stopQueryPlugin));
frameworkProperties.setFederationStrategy(federationStrategy);
frameworkProperties.setCatalogProviders(Collections.singletonList(provider));
CatalogFrameworkImpl framework = createFramework(frameworkProperties);
framework.query(request);
}
Aggregations