Search in sources :

Example 1 with CatalogProvider

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

the class RemoteSolrCatalogProviderTest method testAvailability.

@Test
public void testAvailability() throws IngestException {
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(null);
    assertThat(provider.isAvailable(), is(false));
}
Also used : CatalogProvider(ddf.catalog.source.CatalogProvider) Test(org.junit.Test)

Example 2 with CatalogProvider

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

the class RemoteSolrCatalogProviderTest method testUnconfiguredCreateSolrException.

/**
     * Tests what happens when a {@link SolrException} is thrown when Solr is pinged
     *
     * @throws IngestException
     * @throws SolrServerException
     * @throws IOException
     */
@Test
public void testUnconfiguredCreateSolrException() throws IngestException, SolrServerException, IOException {
    // given
    SolrClient givenClient = mock(SolrClient.class);
    when(givenClient.ping()).thenThrow(SolrException.class);
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(givenClient);
    // when
    String message = null;
    try {
        provider.create(mock(CreateRequest.class));
    } catch (IllegalStateException e) {
        message = e.getMessage();
    }
    // then
    assertThat(message, containsString("Solr client is not connected"));
    verify(givenClient, times(1)).ping();
}
Also used : SolrClient(org.apache.solr.client.solrj.SolrClient) CatalogProvider(ddf.catalog.source.CatalogProvider) CreateRequest(ddf.catalog.operation.CreateRequest) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 3 with CatalogProvider

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

the class TestQueryMonitor method testActiveSearchConstructorNullQueryString.

@Test
public void testActiveSearchConstructorNullQueryString() {
    CatalogProvider mockSource = mock(CatalogProvider.class);
    uuid = UUID.randomUUID();
    as = new ActiveSearch(null, mockSource, uuid, CLIENT_TEXT);
    assertThat(as.getSource(), is(mockSource));
    assertThat(as.getUniqueID(), is(uuid));
    assertThat(as.getClientInfo(), is(CLIENT_TEXT));
}
Also used : CatalogProvider(ddf.catalog.source.CatalogProvider) Test(org.junit.Test)

Example 4 with CatalogProvider

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

the class CachingFederationStrategyTest method testCatalogProviderSource.

@Test
public void testCatalogProviderSource() throws Exception {
    CatalogProvider catalogProviderSource = mock(CatalogProvider.class);
    when(catalogProviderSource.getId()).thenReturn(SystemInfo.getSiteName());
    QueryRequest fedQueryRequest = new QueryRequestImpl(mockQuery, properties);
    strategy.federate(Arrays.asList(catalogProviderSource), fedQueryRequest);
    verify(validationQueryFactory).getQueryRequestWithValidationFilter(any(QueryRequest.class), any(Boolean.class), any(Boolean.class));
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) CatalogProvider(ddf.catalog.source.CatalogProvider) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) Test(org.junit.Test)

Example 5 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)

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