use of ddf.catalog.operation.impl.QueryResponseImpl in project ddf by codice.
the class QueryMonitorPluginImpl method process.
/**
* Method that is implemented for {@link PostFederatedQueryPlugin}. Uses the given {@link QueryResponse} information
* to remove the {@link ActiveSearch} from the {@link ActiveSearch} {@link Map}.
*
* @param input {@link QueryResponse} that corresponds to response from the source that was queried
* by the user's original {@link QueryRequest}
* @return {@link QueryResponse} that was given as a parameter
*/
@Override
public QueryResponse process(QueryResponse input) throws PluginExecutionException, StopProcessingException {
if (!removeSearchAfterComplete) {
LOGGER.debug("Not removing active search from map due to catalog:removeSearchAfterComplete false. To enable removing searches as searches finish, use command catalog:removesearchaftercomplete true.");
return input;
}
if (input == null) {
LOGGER.debug("Cannot remove ActiveSearch from the ActiveSearch Map. QueryResponse received in QueryMonitorPluginImpl was null.");
return null;
}
if (!removeActiveSearch((UUID) input.getRequest().getPropertyValue(SEARCH_ID))) {
QueryResponseImpl queryResponse = new QueryResponseImpl(input.getRequest(), new ArrayList<>(), 0);
queryResponse.closeResultQueue();
Set<ProcessingDetails> processingDetails = Collections.singleton(new ProcessingDetailsImpl(QueryMonitorPlugin.class.getCanonicalName(), new StopProcessingException("Query was cancelled by administrator")));
queryResponse.setProcessingDetails(processingDetails);
return queryResponse;
}
return input;
}
use of ddf.catalog.operation.impl.QueryResponseImpl in project ddf by codice.
the class CatalogFrameworkImplTest method testDelete.
/**
* Tests that the framework properly passes a delete request to the local provider.
*/
@Test
public void testDelete() throws Exception {
List<Metacard> metacards = new ArrayList<Metacard>();
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
metacards.add(newCard);
// create the entry manually in the provider
Metacard insertedCard = provider.create(new CreateRequestImpl(metacards, null)).getCreatedMetacards().iterator().next();
String[] ids = new String[1];
ids[0] = insertedCard.getId();
Result mockFederationResult = mock(Result.class);
MetacardImpl metacard = new MetacardImpl();
metacard.setId(ids[0]);
when(mockFederationResult.getMetacard()).thenReturn(metacard);
QueryResponseImpl queryResponse = new QueryResponseImpl(mock(QueryRequest.class), Collections.singletonList(mockFederationResult), 1);
when(mockFederationStrategy.federate(anyList(), anyObject())).thenReturn(queryResponse);
when(mockRemoteDeleteOperations.performRemoteDelete(any(), any())).then(returnsSecondArg());
deleteOperations.setRemoteDeleteOperations(mockRemoteDeleteOperations);
// send delete to framework
List<Metacard> returnedCards = framework.delete(new DeleteRequestImpl(ids)).getDeletedMetacards();
assertEquals(ids.length, returnedCards.size());
// make sure that the event was posted correctly
Metacard[] array = {};
array = returnedCards.toArray(array);
assertTrue(eventAdmin.wasEventPosted());
assertEquals(eventAdmin.getLastEvent(), array[array.length - 1]);
}
use of ddf.catalog.operation.impl.QueryResponseImpl in project ddf by codice.
the class SolrCacheTest method query.
@Test
public void query() throws UnsupportedQueryException {
QueryRequest mockQuery = mock(QueryRequest.class);
SourceResponse expectedResponse = new QueryResponseImpl(mockQuery);
when(mockCacheSolrMetacardClient.query(mockQuery)).thenReturn(expectedResponse);
SourceResponse actualResponse = solrCache.query(mockQuery);
assertThat(actualResponse, is(expectedResponse));
verify(mockSolrClientAdaptor).getSolrMetacardClient();
verify(mockCacheSolrMetacardClient).query(mockQuery);
}
use of ddf.catalog.operation.impl.QueryResponseImpl in project ddf by codice.
the class FilterPluginTest method testNoRequestSubject.
@Test(expected = StopProcessingException.class)
public void testNoRequestSubject() throws Exception {
QueryResponseImpl response = new QueryResponseImpl(null);
plugin.processPostQuery(response);
fail("Plugin should have thrown exception when no subject was sent in.");
}
use of ddf.catalog.operation.impl.QueryResponseImpl in project ddf by codice.
the class FilterPluginTest method testNoRequestSubjectNoStrategies.
@Test(expected = StopProcessingException.class)
public void testNoRequestSubjectNoStrategies() throws Exception {
QueryResponseImpl response = new QueryResponseImpl(null);
plugin = new FilterPlugin();
plugin.processPostQuery(response);
fail("Plugin should have thrown exception when no subject was sent in.");
}
Aggregations