use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class TestRegistryStore method testCreateWithExistingMetacard.
@Test
public void testCreateWithExistingMetacard() throws Exception {
Metacard mcard = getDefaultMetacard();
queryResults.add(new ResultImpl(mcard));
CreateRequest request = new CreateRequestImpl(mcard);
CreateResponse response = registryStore.create(request);
assertThat(response.getCreatedMetacards().get(0), is(mcard));
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class FederationAdminServiceImplTest method testAddRegistryEntryString.
@Test
public void testAddRegistryEntryString() throws Exception {
Metacard metacard = testMetacard;
metacard.setAttribute(new AttributeImpl(Metacard.TAGS, Collections.singletonList(RegistryConstants.REGISTRY_TAG)));
Metacard createdMetacard = testMetacard;
Subject systemSubject = security.getSystemSubject();
Map<String, Serializable> properties = new HashMap<>();
properties.put(SecurityConstants.SECURITY_SUBJECT, systemSubject);
CreateRequest request = new CreateRequestImpl(Collections.singletonList(metacard), properties, null);
CreateResponse response = new CreateResponseImpl(request, null, Collections.singletonList(createdMetacard));
when(registryTransformer.transform(any(InputStream.class))).thenReturn(metacard);
when(catalogFramework.create(any(CreateRequest.class))).thenReturn(response);
String createdMetacardId = federationAdminServiceImpl.addRegistryEntry(TEST_XML_STRING);
assertThat(createdMetacardId, is(equalTo(RegistryObjectMetacardType.REGISTRY_ID)));
verify(registryTransformer).transform(any(InputStream.class));
verify(catalogFramework).create(any(CreateRequest.class));
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class IdentificationPluginTest method testIdsAlreadySet.
//test both ids are already set
@Test
public void testIdsAlreadySet() throws Exception {
//unmarshal metacard.metadata and confirm only local ext id are set to metacard.getId()
String xml = convert("/registry-both-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.getId(), is(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN));
assertThat(singleExtId.getValue(), is("registryPresetOriginValue"));
}
}
}
use of ddf.catalog.operation.impl.CreateRequestImpl 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.impl.CreateRequestImpl 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));
}
Aggregations