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