Search in sources :

Example 11 with ExternalIdentifierType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType 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()));
        }
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) ByteArrayInputStream(java.io.ByteArrayInputStream) CreateRequest(ddf.catalog.operation.CreateRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) Test(org.junit.Test)

Aggregations

ExternalIdentifierType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)11 Metacard (ddf.catalog.data.Metacard)3 CreateRequest (ddf.catalog.operation.CreateRequest)3 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)2 DefaultXdmXdsTransformer (org.nhindirect.xd.transform.impl.DefaultXdmXdsTransformer)2 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1 StopProcessingException (ddf.catalog.plugin.StopProcessingException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 SubmitObjectsRequest (oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest)1 ClassificationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)1