Search in sources :

Example 1 with ValidationQueryFactory

use of ddf.catalog.cache.solr.impl.ValidationQueryFactory in project ddf by codice.

the class CatalogFrameworkImplTest method createDummyCatalogFramework.

private CatalogFramework createDummyCatalogFramework(CatalogProvider provider, Map<String, CatalogStore> stores, Map<String, FederatedSource> sources, MockEventProcessor eventAdmin) {
    SourcePoller mockPoller = mock(SourcePoller.class);
    when(mockPoller.getCachedSource(isA(Source.class))).thenReturn(null);
    FederationStrategy federationStrategy = new FederationStrategy() {

        @Override
        public QueryResponse federate(List<Source> sources, QueryRequest query) throws FederationException {
            List<Result> results = new ArrayList<>();
            for (Source source : sources) {
                try {
                    SourceResponse response = source.query(query);
                    results.addAll(response.getResults());
                } catch (UnsupportedQueryException e) {
                }
            }
            return new QueryResponseImpl(query, results, results.size());
        }
    };
    ArrayList<PostIngestPlugin> postIngestPlugins = new ArrayList<>();
    postIngestPlugins.add(eventAdmin);
    FrameworkProperties frameworkProperties = new FrameworkProperties();
    frameworkProperties.setCatalogProviders(Collections.singletonList(provider));
    frameworkProperties.setStorageProviders(Collections.singletonList(storageProvider));
    frameworkProperties.setCatalogStoresMap(stores);
    frameworkProperties.setSourcePoller(mockPoller);
    frameworkProperties.setPreIngest(new ArrayList<>());
    frameworkProperties.setPostIngest(postIngestPlugins);
    frameworkProperties.setPreQuery(new ArrayList<>());
    frameworkProperties.setPostQuery(new ArrayList<>());
    frameworkProperties.setPolicyPlugins(new ArrayList<>());
    frameworkProperties.setAccessPlugins(new ArrayList<>());
    frameworkProperties.setFederatedSources(sources);
    frameworkProperties.setConnectedSources(new ArrayList<>());
    frameworkProperties.setFederationStrategy(federationStrategy);
    frameworkProperties.setQueryResponsePostProcessor(new QueryResponsePostProcessor(null, null));
    frameworkProperties.setFilterBuilder(new GeotoolsFilterBuilder());
    frameworkProperties.setValidationQueryFactory(new ValidationQueryFactory(new GeotoolsFilterAdapterImpl(), new GeotoolsFilterBuilder()));
    frameworkProperties.setDefaultAttributeValueRegistry(defaultAttributeValueRegistry);
    return createFramework(frameworkProperties);
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) FederationStrategy(ddf.catalog.federation.FederationStrategy) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ArrayList(java.util.ArrayList) ValidationQueryFactory(ddf.catalog.cache.solr.impl.ValidationQueryFactory) Source(ddf.catalog.source.Source) ByteSource(com.google.common.io.ByteSource) CachedSource(ddf.catalog.util.impl.CachedSource) FederatedSource(ddf.catalog.source.FederatedSource) SourcePoller(ddf.catalog.util.impl.SourcePoller) Result(ddf.catalog.data.Result) PostIngestPlugin(ddf.catalog.plugin.PostIngestPlugin) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyList(org.mockito.Matchers.anyList) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Aggregations

ByteSource (com.google.common.io.ByteSource)1 ValidationQueryFactory (ddf.catalog.cache.solr.impl.ValidationQueryFactory)1 Result (ddf.catalog.data.Result)1 FederationStrategy (ddf.catalog.federation.FederationStrategy)1 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 SourceResponse (ddf.catalog.operation.SourceResponse)1 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)1 PostIngestPlugin (ddf.catalog.plugin.PostIngestPlugin)1 FederatedSource (ddf.catalog.source.FederatedSource)1 Source (ddf.catalog.source.Source)1 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1 CachedSource (ddf.catalog.util.impl.CachedSource)1 SourcePoller (ddf.catalog.util.impl.SourcePoller)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Matchers.anyList (org.mockito.Matchers.anyList)1