use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class CatalogFrameworkImplTest method testCreate.
// Start testing MetacardWriter
/**
* Tests that the framework properly passes a create request to the local provider.
*/
@Test
public void testCreate() throws Exception {
List<Metacard> metacards = new ArrayList<>();
MetacardImpl newCard = new MetacardImpl();
newCard.setId(null);
metacards.add(newCard);
CreateResponse response = framework.create(new CreateRequestImpl(metacards, null));
assertEquals(response.getCreatedMetacards().size(), provider.size());
for (Metacard curCard : response.getCreatedMetacards()) {
assertNotNull(curCard.getId());
}
// make sure that the event was posted correctly
assertTrue(eventAdmin.wasEventPosted());
Metacard[] array = {};
array = response.getCreatedMetacards().toArray(array);
assertTrue(eventAdmin.wasEventPosted());
assertEquals(eventAdmin.getLastEvent(), array[array.length - 1]);
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class CatalogFrameworkImplTest method testCreateWithDefaultValues.
@Test
public void testCreateWithDefaultValues() throws IngestException, SourceUnavailableException {
registerDefaults();
final String title = "some title";
final Date expiration = new Date();
CreateRequest createRequest = new CreateRequestImpl(getMetacards(title, expiration));
CreateResponse createResponse = framework.create(createRequest);
verifyDefaults(createResponse.getCreatedMetacards(), title, expiration, DEFAULT_TITLE, DEFAULT_EXPIRATION, DEFAULT_TITLE_CUSTOM, DEFAULT_EXPIRATION_CUSTOM);
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class RestReplicatorPlugin method process.
@Override
public CreateResponse process(CreateResponse input) throws PluginExecutionException {
if (Requests.isLocal(input.getRequest()) && client != null && transformer != null) {
for (Metacard m : input.getCreatedMetacards()) {
String data = transform(m, client);
Response r = client.post(data);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Posted the following GeoJSON: {}\n", data);
LOGGER.debug(RESPONSE, ToStringBuilder.reflectionToString(r));
}
}
}
return input;
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class PluginTest method testCreateNullTransformer.
@Test
@Ignore
public void testCreateNullTransformer() throws PluginExecutionException, IngestException, SourceUnavailableException {
// given
plugin = new RestReplicatorPlugin(null);
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));
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class DuplicateCommands method ingestSingly.
private List<Metacard> ingestSingly(CatalogFacade provider, List<Metacard> metacards) {
if (metacards.isEmpty()) {
return Collections.emptyList();
}
List<Metacard> createdMetacards = new ArrayList<>();
LOGGER.debug("Preparing to ingest {} records one at time.", metacards.size());
for (Metacard metacard : metacards) {
CreateRequest createRequest = new CreateRequestImpl(Arrays.asList(metacard));
CreateResponse createResponse;
try {
createResponse = provider.create(createRequest);
createdMetacards.addAll(createResponse.getCreatedMetacards());
} catch (IngestException | SourceUnavailableException e) {
LOGGER.debug("Error during ingest:", e);
} catch (Exception e) {
LOGGER.debug("Unexpected Exception during ingest:", e);
}
}
return createdMetacards;
}
Aggregations