use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class CachingFederationStrategyTest method testFederateQueryUpdateCacheBlocking.
@Test
public void testFederateQueryUpdateCacheBlocking() throws Exception {
properties.put(QUERY_MODE, INDEX_QUERY_MODE);
QueryRequest fedQueryRequest = new QueryRequestImpl(mockQuery, properties);
Source mockSource = mock(Source.class);
when(mockSource.query(any(QueryRequest.class))).thenReturn(mockResponse);
doNothing().when(cacheCommitPhaser).add(cacheArgs.capture());
QueryResponse federateResponse = strategy.federate(Arrays.asList(mockSource), fedQueryRequest);
assertThat(requestArgumentCaptor.getValue().getPropertyValue(QUERY_MODE), is(INDEX_QUERY_MODE));
verify(mockSource).query(any(QueryRequest.class));
verify(cache, times(0)).query(any(QueryRequest.class));
// CacheCommitPhaser.add() is called
verify(cacheCommitPhaser).add(cacheArgs.getValue());
verifyCacheUpdated();
assertThat(federateResponse.getRequest().getQuery(), is(requestArgumentCaptor.getValue().getQuery()));
}
use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class CachingFederationStrategyTest method testValidCollectionWithNullSource.
@Test(expected = IllegalArgumentException.class)
public void testValidCollectionWithNullSource() throws Exception {
List<Source> sources = new ArrayList<>();
sources.add(null);
QueryRequest fedQueryRequest = mock(QueryRequest.class);
when(fedQueryRequest.getQuery()).thenReturn(mockQuery);
strategy.federate(sources, fedQueryRequest);
}
use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class CachingFederationStrategyTest method testFederateDuplicateSources.
@Test
public void testFederateDuplicateSources() throws Exception {
Query mockQ = new QueryImpl(mock(NullFilterImpl.class), 2, 2, mock(SortBy.class), true, LONG_TIMEOUT);
QueryRequest fedQueryRequest = new QueryRequestImpl(mockQ, properties);
List<Source> sources = new ArrayList<>();
// Multiple sources needed for OffsetResultHandler to be used
for (int i = 0; i < 2; i++) {
Source mockSource = mock(Source.class);
when(mockSource.getId()).thenReturn("mock source");
sources.add(mockSource);
}
strategy.federate(sources, fedQueryRequest);
verify(sources.get(0), atLeastOnce()).query(any(QueryRequest.class));
verify(sources.get(1), times(0)).query(any(QueryRequest.class));
}
use of ddf.catalog.operation.QueryRequest 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));
}
use of ddf.catalog.operation.QueryRequest in project ddf by codice.
the class FederationAdminServiceImplTest method getRegistryObjectByRegistryIdThatDoesNotExist.
@Test(expected = FederationAdminException.class)
public void getRegistryObjectByRegistryIdThatDoesNotExist() throws Exception {
QueryRequest request = getTestQueryRequest();
QueryResponse response = getPopulatedTestQueryResponse(request);
Metacard metacard = getTestMetacard();
when(security.getSystemSubject()).thenReturn(subject);
when(catalogFramework.query(any(QueryRequest.class))).thenReturn(response);
when(registryTransformer.transform(any(InputStream.class))).thenReturn(metacard);
federationAdminServiceImpl.getRegistryObjectByRegistryId("Not a metacard");
}
Aggregations