use of ddf.catalog.operation.impl.SourceResponseImpl in project ddf by codice.
the class SortedQueryMonitor method executePostFederationQueryPluginsWithSourceError.
private void executePostFederationQueryPluginsWithSourceError(QueryRequest queryRequest, String sourceId, Exception e, Set<ProcessingDetails> processingDetails) {
ProcessingDetails processingDetail = new ProcessingDetailsImpl(sourceId, e);
SourceResponse sourceResponse = new SourceResponseImpl(queryRequest, new ArrayList<>());
sourceResponse.getProcessingErrors().add(processingDetail);
processingDetails.add(processingDetail);
executePostFederationQueryPlugins(sourceResponse, queryRequest);
}
use of ddf.catalog.operation.impl.SourceResponseImpl in project ddf by codice.
the class TestCswQueryResponseTransformer method createSourceResponse.
private SourceResponse createSourceResponse(GetRecordsType request, int resultCount) {
int first = 1;
int last = 2;
int max = 0;
if (request != null) {
first = request.getStartPosition().intValue();
max = request.getMaxRecords().intValue();
int next = request.getMaxRecords().intValue() + first;
last = next - 1;
if (last >= resultCount) {
last = resultCount;
}
}
QueryImpl query = new QueryImpl(filter, first, max, null, true, 0);
SourceResponseImpl sourceResponse = new SourceResponseImpl(new QueryRequestImpl(query), createResults(first, last));
sourceResponse.setHits(resultCount);
return sourceResponse;
}
use of ddf.catalog.operation.impl.SourceResponseImpl in project ddf by codice.
the class CatalogFrameworkImplTest method testPostQueryStopExecution.
@Test(expected = FederationException.class)
public void testPostQueryStopExecution() throws UnsupportedQueryException, FederationException, SourceUnavailableException {
SourcePoller poller = mock(SourcePoller.class);
when(poller.getCachedSource(isA(Source.class))).thenReturn(null);
BundleContext context = null;
FilterFactory filterFactory = new FilterFactoryImpl();
Filter filter = filterFactory.like(filterFactory.property(Metacard.METADATA), "goodyear", "*", "?", "/", false);
QueryRequest request = new QueryRequestImpl(new QueryImpl(filter));
SourceResponseImpl sourceResponse = new SourceResponseImpl(request, new ArrayList<Result>());
QueryResponseImpl queryResponse = new QueryResponseImpl(sourceResponse, "anyId");
CatalogProvider provider = mock(CatalogProvider.class);
when(provider.query(isA(QueryRequest.class))).thenReturn(sourceResponse);
FederationStrategy federationStrategy = mock(FederationStrategy.class);
when(federationStrategy.federate(isA(List.class), isA(QueryRequest.class))).thenReturn(queryResponse);
PostQueryPlugin stopQueryPlugin = new PostQueryPlugin() {
@Override
public QueryResponse process(QueryResponse input) throws PluginExecutionException, StopProcessingException {
throw new StopProcessingException("Testing that the framework will stop the query.");
}
};
FrameworkProperties props = new FrameworkProperties();
props.setCatalogProviders(Collections.singletonList((CatalogProvider) provider));
props.setBundleContext(context);
props.setPostQuery(Arrays.asList(stopQueryPlugin));
props.setFederationStrategy(federationStrategy);
props.setQueryResponsePostProcessor(mock(QueryResponsePostProcessor.class));
props.setSourcePoller(poller);
props.setFilterBuilder(new GeotoolsFilterBuilder());
CatalogFrameworkImpl framework = createFramework(props);
framework.query(request);
}
use of ddf.catalog.operation.impl.SourceResponseImpl in project ddf by codice.
the class RefreshRegistryEntriesTest method testNoUpdatesOnOlder.
@Test
public void testNoUpdatesOnOlder() throws Exception {
MetacardImpl localMcard = getPopulatedTestRegistryMetacard(TEST_METACARD_ID, RegistryObjectMetacardType.REGISTRY_ID, 0, true);
Metacard remoteMcard = getPopulatedTestRegistryMetacard("remoteMcardId", RegistryObjectMetacardType.REGISTRY_ID, -5000L);
when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.singletonList(localMcard));
SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(remoteMcard)));
when(registryStore.query(any(QueryRequest.class))).thenReturn(response);
refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore.isAvailable()).thenReturn(true);
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService, never()).updateRegistryEntry(any(Metacard.class));
}
use of ddf.catalog.operation.impl.SourceResponseImpl in project ddf by codice.
the class RefreshRegistryEntriesTest method testWriteRemoteUpdates.
@Test
public void testWriteRemoteUpdates() throws Exception {
Metacard localMcard = getPopulatedTestRegistryMetacard(TEST_METACARD_ID, RegistryObjectMetacardType.REGISTRY_ID, 0, true);
Metacard remoteMcard = getPopulatedTestRegistryMetacard("remoteMcardId", RegistryObjectMetacardType.REGISTRY_ID, 1000L);
when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.singletonList(localMcard));
SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(remoteMcard)));
when(registryStore.query(any(QueryRequest.class))).thenReturn(response);
refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore.isAvailable()).thenReturn(true);
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService).updateRegistryEntry(remoteMcard);
}
Aggregations