use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class CatalogMetricsTest method catalogCreateMetric.
@Test
public void catalogCreateMetric() throws Exception {
CreateRequest request = mock(CreateRequest.class);
CreateResponse response = mock(CreateResponse.class);
List<Metacard> createdList = mock(List.class);
when(createdList.size()).thenReturn(100);
when(response.getRequest()).thenReturn(request);
when(response.getCreatedMetacards()).thenReturn(createdList);
catalogMetrics.process(response);
assertThat(meterRegistry.counter("ddf.catalog.create").count(), is(100.0));
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class ResponseMetacardActionSplitter method split.
public List<Metacard> split(Response response) {
List<Metacard> metacards = new ArrayList<>();
if (response instanceof CreateResponse) {
CreateResponse createResponse = (CreateResponse) response;
metacards.addAll(createResponse.getCreatedMetacards());
} else if (response instanceof UpdateResponse) {
UpdateResponse updateResponse = (UpdateResponse) response;
List<Update> updates = updateResponse.getUpdatedMetacards();
for (Update update : updates) {
metacards.add(update.getNewMetacard());
}
} else if (response instanceof DeleteResponse) {
DeleteResponse deleteResponse = (DeleteResponse) response;
metacards.addAll(deleteResponse.getDeletedMetacards());
}
return metacards;
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class PluginTest method testCreateBadTransform.
@Test(expected = PluginExecutionException.class)
public void testCreateBadTransform() throws PluginExecutionException, CatalogTransformerException, IOException, IngestException, SourceUnavailableException {
// given
when(transformer.transform(isA(Metacard.class), isA(Map.class))).thenThrow(CatalogTransformerException.class);
CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
// when
plugin.process(createResponse);
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class PluginTest method testCreate.
@Test
@Ignore
public void testCreate() throws PluginExecutionException, CatalogTransformerException, IOException, IngestException, SourceUnavailableException {
// given
CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
// when
CreateResponse response = plugin.process(createResponse);
// then
verify(endpoint).addDocument(isA(HttpHeaders.class), isA(UriInfo.class), isA(InputStream.class));
assertThat(response, sameInstance(createResponse));
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class PluginTest method testCreateNullParent.
@Test
@Ignore
public void testCreateNullParent() throws PluginExecutionException, IngestException, SourceUnavailableException {
// given
CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
// when
plugin.process(createResponse);
// then
verify(endpoint, never()).addDocument(isA(HttpHeaders.class), isA(UriInfo.class), isA(InputStream.class));
}
Aggregations