use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.
the class CatalogComponentFrameworkTest method testCreateWithSingleMetacard.
@Test
public /**
* Operation: CREATE Body contains: Metacard
*/
void testCreateWithSingleMetacard() throws Exception {
resetMocks();
// Setup expectations to verify
final MockEndpoint mockVerifierEndpoint = getMockEndpoint("mock:result");
mockVerifierEndpoint.expectedMessageCount(1);
final List<Metacard> metacards = new ArrayList<Metacard>();
metacards.add(metacard1);
// Mock catalog framework
final CreateRequest createRequest = new CreateRequestImpl(metacards);
final CreateResponse createResponse = new CreateResponseImpl(createRequest, new HashMap(), metacards);
when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
// Exercise the route with a CREATE operation
template.sendBodyAndHeader("direct:sampleInput", metacard1, "Operation", "CREATE");
// Verify that the number of metacards in the exchange after the records
// is identical to the input
assertListSize(mockVerifierEndpoint.getExchanges(), 1);
final Exchange exchange = mockVerifierEndpoint.getExchanges().get(0);
final List<Metacard> cardsCreated = (List<Metacard>) exchange.getIn().getBody();
assertListSize(cardsCreated, 1);
mockVerifierEndpoint.assertIsSatisfied();
}
use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.
the class RESTEndpointTest method givenCatalogFramework.
private CatalogFramework givenCatalogFramework() throws IngestException, SourceUnavailableException {
CatalogFramework framework = mock(CatalogFramework.class);
Metacard returnMetacard = mock(Metacard.class);
when(returnMetacard.getId()).thenReturn(RESTEndpointTest.SAMPLE_ID);
when(framework.create(isA(CreateRequest.class))).thenReturn(new CreateResponseImpl(null, null, Collections.singletonList(returnMetacard)));
when(framework.create(isA(CreateStorageRequest.class))).thenReturn(new CreateResponseImpl(null, null, Collections.singletonList(returnMetacard)));
return framework;
}
use of ddf.catalog.operation.impl.CreateResponseImpl 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.impl.CreateResponseImpl 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.impl.CreateResponseImpl 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