Search in sources :

Example 1 with PreQueryPlugin

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);
}
Also used : ContentType(ddf.catalog.data.ContentType) QueryRequest(ddf.catalog.operation.QueryRequest) Query(ddf.catalog.operation.Query) FederationStrategy(ddf.catalog.federation.FederationStrategy) PreQueryPlugin(ddf.catalog.plugin.PreQueryPlugin) StopProcessingException(ddf.catalog.plugin.StopProcessingException) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ContentType (ddf.catalog.data.ContentType)1 FederationStrategy (ddf.catalog.federation.FederationStrategy)1 Query (ddf.catalog.operation.Query)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 PreQueryPlugin (ddf.catalog.plugin.PreQueryPlugin)1 StopProcessingException (ddf.catalog.plugin.StopProcessingException)1 Date (java.util.Date)1 Test (org.junit.Test)1