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();
}
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();
}
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);
}
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)));
}
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);
}
Aggregations