Search in sources :

Example 16 with CatalogProvider

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

the class TestQueryMonitor method testActiveSearchConstructorNullUUID.

@Test
public void testActiveSearchConstructorNullUUID() {
    CatalogProvider mockSource = mock(CatalogProvider.class);
    as = new ActiveSearch(QUERY_TEXT, mockSource, null, CLIENT_TEXT);
    assertThat(as.getCQL(), is(QUERY_TEXT));
    assertThat(as.getSource(), is(mockSource));
    assertThat(as.getUniqueID(), instanceOf(UUID.class));
    assertThat(as.getClientInfo(), is(CLIENT_TEXT));
}
Also used : CatalogProvider(ddf.catalog.source.CatalogProvider) UUID(java.util.UUID) Test(org.junit.Test)

Example 17 with CatalogProvider

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

the class FederationStrategyTest method testNegativePageSizeQuery.

@Test
public void testNegativePageSizeQuery() throws Exception {
    when(mockQuery.getPageSize()).thenReturn(-1);
    QueryRequest fedQueryRequest = mock(QueryRequest.class);
    when(fedQueryRequest.getQuery()).thenReturn(mockQuery);
    Result mockResult = mock(Result.class);
    SourceResponse mockResponse = mock(SourceResponse.class);
    List<Result> results = Arrays.asList(mockResult);
    when(mockResponse.getHits()).thenReturn((long) results.size());
    when(mockResponse.getResults()).thenReturn(results);
    CatalogProvider mockProvider = mock(CatalogProvider.class);
    when(mockProvider.query(any(QueryRequest.class))).thenReturn(mockResponse);
    when(mockProvider.getId()).thenReturn("mock provider");
    List<Source> sources = new ArrayList<Source>();
    sources.add(mockProvider);
    SortedFederationStrategy sortedStrategy = new SortedFederationStrategy(executor, new ArrayList<PreFederatedQueryPlugin>(), new ArrayList<PostFederatedQueryPlugin>());
    QueryResponse fedResponse = sortedStrategy.federate(sources, fedQueryRequest);
    assertEquals(1, fedResponse.getResults().size());
    FifoFederationStrategy fifoStrategy = new FifoFederationStrategy(executor, new ArrayList<PreFederatedQueryPlugin>(), new ArrayList<PostFederatedQueryPlugin>());
    fedResponse = fifoStrategy.federate(sources, fedQueryRequest);
    assertEquals(1, fedResponse.getResults().size());
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) PreFederatedQueryPlugin(ddf.catalog.plugin.PreFederatedQueryPlugin) ArrayList(java.util.ArrayList) Source(ddf.catalog.source.Source) PostFederatedQueryPlugin(ddf.catalog.plugin.PostFederatedQueryPlugin) Result(ddf.catalog.data.Result) CatalogProvider(ddf.catalog.source.CatalogProvider) QueryResponse(ddf.catalog.operation.QueryResponse) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 18 with CatalogProvider

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

the class RemoteSolrCatalogProviderTest method testUnconfiguredQuery.

@Test(expected = IllegalStateException.class)
public void testUnconfiguredQuery() throws UnsupportedQueryException {
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(null);
    provider.query(mock(QueryRequest.class));
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) CatalogProvider(ddf.catalog.source.CatalogProvider) Test(org.junit.Test)

Example 19 with CatalogProvider

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

the class RemoteSolrCatalogProviderTest method testUnconfiguredCreate.

@Test
public void testUnconfiguredCreate() throws IngestException, SolrServerException, IOException {
    SolrClient givenClient = givenSolrClient(false);
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(givenClient);
    try {
        provider.create(mock(CreateRequest.class));
    } catch (IllegalStateException e) {
        assertThat(e.getMessage(), containsString("Solr client is not connected"));
    }
}
Also used : SolrClient(org.apache.solr.client.solrj.SolrClient) CatalogProvider(ddf.catalog.source.CatalogProvider) CreateRequest(ddf.catalog.operation.CreateRequest) Test(org.junit.Test)

Example 20 with CatalogProvider

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

the class RemoteSolrCatalogProviderTest method testUnconfiguredDelete.

@Test(expected = IllegalStateException.class)
public void testUnconfiguredDelete() throws IngestException {
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(null);
    provider.delete(mock(DeleteRequest.class));
}
Also used : CatalogProvider(ddf.catalog.source.CatalogProvider) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

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