Search in sources :

Example 6 with CatalogProvider

use of ddf.catalog.source.CatalogProvider in project ddf by codice.

the class RemoteSolrCatalogProviderTest method testAvailabilitySourceMonitor.

@Test
public void testAvailabilitySourceMonitor() throws Exception {
    final SolrClient client = givenSolrClient(false);
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(client);
    final SourceMonitor monitor = mock(SourceMonitor.class);
    assertThat(provider.isAvailable(monitor), is(false));
    final ArgumentCaptor<Listener> listener = ArgumentCaptor.forClass(Listener.class);
    verify(client).isAvailable(listener.capture());
    verify(client).ping();
    // when the underlying listener is called with not available
    listener.getValue().changed(client, false);
    // so should our monitor
    verify(monitor).setUnavailable();
    // when the underlying listener is called with available
    listener.getValue().changed(client, true);
    // so should our monitor
    verify(monitor).setAvailable();
}
Also used : Listener(org.codice.solr.client.solrj.SolrClient.Listener) SolrClient(org.codice.solr.client.solrj.SolrClient) CatalogProvider(ddf.catalog.source.CatalogProvider) SourceMonitor(ddf.catalog.source.SourceMonitor) Test(org.junit.Test)

Example 7 with CatalogProvider

use of ddf.catalog.source.CatalogProvider in project ddf by codice.

the class RemoteSolrCatalogProviderTest method testIsAvailableWhenSolrClientStatusNotOk.

@Test
public void testIsAvailableWhenSolrClientStatusNotOk() throws Exception {
    final SolrClient client = givenSolrClient(false);
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(client);
    assertThat(provider.isAvailable(), is(false));
    verify(client).ping();
}
Also used : SolrClient(org.codice.solr.client.solrj.SolrClient) CatalogProvider(ddf.catalog.source.CatalogProvider) Test(org.junit.Test)

Example 8 with CatalogProvider

use of ddf.catalog.source.CatalogProvider in project ddf by codice.

the class TagsFilterQueryPluginTest method setup.

@Before
public void setup() {
    CatalogProvider catProvider1 = mock(CatalogProvider.class);
    CatalogProvider catProvider2 = mock(CatalogProvider.class);
    CatalogProvider catProvider3 = mock(CatalogProvider.class);
    when(catProvider1.getId()).thenReturn("cat1");
    when(catProvider2.getId()).thenReturn("cat2");
    when(catProvider3.getId()).thenReturn("cat3");
    ImmutableList<CatalogProvider> catalogProviders = ImmutableList.of(catProvider1, catProvider2, catProvider3);
    filterAdapter = mock(FilterAdapter.class);
    filterBuilder = mock(FilterBuilder.class);
    plugin = new TagsFilterQueryPlugin(catalogProviders, filterAdapter, filterBuilder);
    source = mock(CatalogProvider.class);
    when(source.getId()).thenReturn("cat2");
    cache = mock(SourceCache.class);
    when(cache.getId()).thenReturn("cache");
    queryRequest = mock(QueryRequest.class);
    query = mock(Query.class);
    when(queryRequest.getQuery()).thenReturn(query);
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) Query(ddf.catalog.operation.Query) CatalogProvider(ddf.catalog.source.CatalogProvider) FilterBuilder(ddf.catalog.filter.FilterBuilder) FilterAdapter(ddf.catalog.filter.FilterAdapter) SourceCache(ddf.catalog.source.SourceCache) Before(org.junit.Before)

Example 9 with CatalogProvider

use of ddf.catalog.source.CatalogProvider in project ddf by codice.

the class SourceOperationsTest method testGettingSourceActions.

@Test
public void testGettingSourceActions() throws SourceUnavailableException {
    Action action = mock(Action.class);
    FrameworkProperties frameworkProperties = mock(FrameworkProperties.class);
    CatalogProvider catalogProvider = mock(CatalogProvider.class);
    when(frameworkProperties.getCatalogProviders()).thenReturn(Collections.singletonList(catalogProvider));
    ActionRegistry actionRegistry = mock(ActionRegistry.class);
    when(actionRegistry.list(any(Source.class))).thenReturn(Collections.singletonList(action));
    final SourcePoller<SourceStatus> mockStatusSourcePoller = mock(SourcePoller.class);
    when(mockStatusSourcePoller.getCachedValueForSource(isA(Source.class))).thenReturn(Optional.empty());
    SourceOperations sourceOperations = new SourceOperations(frameworkProperties, actionRegistry, mockStatusSourcePoller, mock(SourcePoller.class));
    sourceOperations.bind((CatalogProvider) null);
    SourceInfoRequest sourceInfoRequest = mock(SourceInfoRequest.class);
    SourceInfoResponse sourceInfoResponse = sourceOperations.getSourceInfo(sourceInfoRequest, true);
    assertThat(sourceInfoResponse.getSourceInfo(), hasSize(1));
    SourceDescriptor sourceDescriptor = sourceInfoResponse.getSourceInfo().toArray(new SourceDescriptor[0])[0];
    assertThat(sourceDescriptor.getActions(), is(Collections.singletonList(action)));
}
Also used : FrameworkProperties(ddf.catalog.impl.FrameworkProperties) Action(ddf.action.Action) SourceDescriptor(ddf.catalog.source.SourceDescriptor) CatalogProvider(ddf.catalog.source.CatalogProvider) SourceStatus(org.codice.ddf.catalog.sourcepoller.SourceStatus) SourceInfoRequest(ddf.catalog.operation.SourceInfoRequest) ActionRegistry(ddf.action.ActionRegistry) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) Source(ddf.catalog.source.Source) SourcePoller(org.codice.ddf.catalog.sourcepoller.SourcePoller) Test(org.junit.Test)

Example 10 with CatalogProvider

use of ddf.catalog.source.CatalogProvider in project ddf by codice.

the class RemoteDeleteOperationsTest method setUpFrameworkProperties.

private void setUpFrameworkProperties() {
    frameworkProperties = new FrameworkProperties();
    frameworkProperties.setAccessPlugins(new ArrayList<>());
    frameworkProperties.setPolicyPlugins(new ArrayList<>());
    frameworkProperties.setCatalogProviders(Collections.singletonList((CatalogProvider) provider));
    frameworkProperties.setPostResource(mockPostResourcePlugins);
    frameworkProperties.setFederationStrategy(mockFederationStrategy);
    frameworkProperties.setFilterBuilder(new GeotoolsFilterBuilder());
    frameworkProperties.setPreIngest(new ArrayList<>());
    frameworkProperties.setPostIngest(postIngestPlugins);
    frameworkProperties.setPreQuery(new ArrayList<>());
    frameworkProperties.setPostQuery(new ArrayList<>());
    frameworkProperties.setPreResource(new ArrayList<>());
    frameworkProperties.setPostResource(new ArrayList<>());
    frameworkProperties.setQueryResponsePostProcessor(mock(QueryResponsePostProcessor.class));
    frameworkProperties.setStorageProviders(Collections.singletonList(storageProvider));
    frameworkProperties.setMimeTypeMapper(new MimeTypeMapperImpl(Collections.singletonList(mimeTypeResolver)));
    frameworkProperties.setMimeTypeToTransformerMapper(mimeTypeToTransformerMapper);
}
Also used : FrameworkProperties(ddf.catalog.impl.FrameworkProperties) CatalogProvider(ddf.catalog.source.CatalogProvider) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) MimeTypeMapperImpl(ddf.mime.mapper.MimeTypeMapperImpl) QueryResponsePostProcessor(ddf.catalog.impl.QueryResponsePostProcessor)

Aggregations

CatalogProvider (ddf.catalog.source.CatalogProvider)41 Test (org.junit.Test)26 QueryRequest (ddf.catalog.operation.QueryRequest)13 ArrayList (java.util.ArrayList)9 Result (ddf.catalog.data.Result)8 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)8 FederatedSource (ddf.catalog.source.FederatedSource)8 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)8 Metacard (ddf.catalog.data.Metacard)7 QueryResponse (ddf.catalog.operation.QueryResponse)7 CatalogFramework (ddf.catalog.CatalogFramework)6 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)6 Source (ddf.catalog.source.Source)6 ByteSource (com.google.common.io.ByteSource)5 FederationStrategy (ddf.catalog.federation.FederationStrategy)5 Query (ddf.catalog.operation.Query)5 QueryImpl (ddf.catalog.operation.impl.QueryImpl)5 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)4 FederationException (ddf.catalog.federation.FederationException)4 QueryOperations (ddf.catalog.impl.operations.QueryOperations)4