use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class IdentificationPluginTest method testOtherExtIds.
//test ext IDs are not set to other items
@Test
public void testOtherExtIds() throws Exception {
//unmarshal metacard.metadata and confirm both origin and local ext id are set to metacard.getId()
String xml = convert("/registry-extra-extid.xml");
sampleData.setAttribute(Metacard.METADATA, xml);
CreateRequest result = identificationPlugin.process(new CreateRequestImpl(sampleData));
Metacard testMetacard = result.getMetacards().get(0);
String metadata = testMetacard.getMetadata();
InputStream inputStream = new ByteArrayInputStream(metadata.getBytes(Charsets.UTF_8));
JAXBElement<RegistryObjectType> registryObjectTypeJAXBElement = parser.unmarshal(configurator, JAXBElement.class, inputStream);
RegistryObjectType registryObjectType = registryObjectTypeJAXBElement.getValue();
List<ExternalIdentifierType> extIdList = registryObjectType.getExternalIdentifier();
for (ExternalIdentifierType singleExtId : extIdList) {
if (singleExtId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_LOCAL)) {
assertThat(singleExtId.getValue(), is(testMetacard.getId()));
} else if (singleExtId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN)) {
assertThat(singleExtId.getValue(), is(testMetacard.getId()));
}
}
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class IdentificationPluginTest method testRemoteRequest.
@Test
public void testRemoteRequest() throws Exception {
String xml = convert("/registry-no-extid.xml");
sampleData.setAttribute(Metacard.METADATA, xml);
Map<String, Serializable> props = new HashMap<>();
props.put(Constants.LOCAL_DESTINATION_KEY, false);
CreateRequest result = identificationPlugin.process(new CreateRequestImpl(Collections.singletonList(sampleData), props));
assertThat(result.getMetacards().get(0).getMetadata(), equalTo(xml));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class DummyPreIngestPlugin method process.
public CreateRequest process(CreateRequest input) throws PluginExecutionException {
String methodName = "process(CreateRequest)";
LOGGER.debug(ENTERING, methodName);
CreateRequest newRequest = input;
if (input != null) {
List<Metacard> filteredCards = filterOutMetacards(input.getMetacards());
newRequest = new CreateRequestImpl(filteredCards);
}
LOGGER.debug(EXITING, methodName);
return newRequest;
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class SecurityPluginTest method testNominalCaseCreateWithoutEmail.
@Test
public void testNominalCaseCreateWithoutEmail() throws Exception {
Subject mockSubject = mock(Subject.class);
ThreadContext.bind(mockSubject);
CreateRequest request = new MockCreateRequest();
SecurityPlugin plugin = new SecurityPlugin();
request = plugin.processPreCreate(request);
assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
assertThat(request.getMetacards().size(), is(2));
request.getMetacards().forEach(metacard -> assertThat(metacard.getAttribute(Metacard.POINT_OF_CONTACT), is(nullValue())));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class CatalogComponentFrameworkTest method testCreateWithWrongTypeOperation.
@Test
public /**
* Operation: CREATE Body contains: Metacard
*/
void testCreateWithWrongTypeOperation() 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", new Boolean("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, 0);
mockVerifierEndpoint.assertIsSatisfied();
}
Aggregations