Search in sources :

Example 1 with RegistryPackageTypeConverter

use of org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter in project ddf by codice.

the class RegistryPackageWebConverterTest method testEmptyRegistryPackage.

@Test
public void testEmptyRegistryPackage() throws Exception {
    Map<String, Object> emptyRegistryMap = new HashMap<>();
    RegistryPackageTypeConverter rptConverter = new RegistryPackageTypeConverter();
    Optional<RegistryPackageType> optionalRegistryPackage = rptConverter.convert(emptyRegistryMap);
    RegistryPackageType registryPackage = optionalRegistryPackage.orElse(null);
    assertThat(registryPackage, nullValue());
}
Also used : HashMap(java.util.HashMap) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryPackageTypeConverter(org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter) Test(org.junit.Test)

Example 2 with RegistryPackageTypeConverter

use of org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter in project ddf by codice.

the class RegistryPackageWebConverterTest method testRoundTrip.

@Test
public void testRoundTrip() throws Exception {
    RegistryPackageWebConverter rpwConverter = new RegistryPackageWebConverter();
    RegistryPackageType testRegistryPackage = getTestRegistryPackage();
    Map<String, Object> testRegistryPackageMap = rpwConverter.convert(testRegistryPackage);
    RegistryPackageTypeConverter rptConverter = new RegistryPackageTypeConverter();
    Optional<RegistryPackageType> optionalRegistryPackage = rptConverter.convert(testRegistryPackageMap);
    RegistryPackageType convertedTestRegistryPackage = optionalRegistryPackage.get();
    assertThat(testRegistryPackage.getObjectType(), is(equalTo(convertedTestRegistryPackage.getObjectType())));
    assertThat(testRegistryPackage.getId(), is(equalTo(convertedTestRegistryPackage.getId())));
    assertThat(testRegistryPackage.getHome(), is(equalTo(convertedTestRegistryPackage.getHome())));
    assertThat(testRegistryPackage.getExternalIdentifier(), is(equalTo(convertedTestRegistryPackage.getExternalIdentifier())));
    assertThat((testRegistryPackage).getRegistryObjectList().getIdentifiable().size(), is(equalTo((convertedTestRegistryPackage).getRegistryObjectList().getIdentifiable().size())));
    assertThat(testRegistryPackage, is(equalTo(convertedTestRegistryPackage)));
}
Also used : RegistryPackageWebConverter(org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryPackageTypeConverter(org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter) Test(org.junit.Test)

Example 3 with RegistryPackageTypeConverter

use of org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter in project ddf by codice.

the class FederationAdminTest method setup.

@Before
public void setup() throws Exception {
    parser = new XmlParser();
    configurator = parser.configureParser(Arrays.asList(RegistryObjectType.class.getPackage().getName(), EbrimConstants.OGC_FACTORY.getClass().getPackage().getName(), EbrimConstants.GML_FACTORY.getClass().getPackage().getName()), this.getClass().getClassLoader());
    federationAdmin = new FederationAdmin(helper) {

        @Override
        public BundleContext getContext() {
            return context;
        }
    };
    federationAdmin.setFederationAdminService(federationAdminService);
    federationAdmin.setRegistryTransformer(registryTransformer);
    federationAdmin.setMetacardMarshaller(new MetacardMarshaller(parser));
    federationAdmin.setSlotHelper(new SlotTypeHelper());
    federationAdmin.setRegistryMapConverter(new RegistryPackageWebConverter());
    federationAdmin.setRegistryTypeConverter(new RegistryPackageTypeConverter());
    federationAdmin.setSourceConfigRefresh(sourceConfiguration);
    mcard = new MetacardImpl(new RegistryObjectMetacardType());
    mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "myId");
    mcard.setAttribute(RegistryObjectMetacardType.PUBLISHED_LOCATIONS, new ArrayList<>());
    mcard.setId("someUUID");
    when(queryResponse.getResults()).thenReturn(Collections.singletonList(new ResultImpl(mcard)));
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponse);
    catalogStoreMap.put("myDest", store);
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) QueryRequest(ddf.catalog.operation.QueryRequest) MetacardMarshaller(org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller) SlotTypeHelper(org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper) RegistryPackageWebConverter(org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter) ResultImpl(ddf.catalog.data.impl.ResultImpl) RegistryObjectMetacardType(org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) RegistryPackageTypeConverter(org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter) BundleContext(org.osgi.framework.BundleContext) Before(org.junit.Before)

Aggregations

RegistryPackageTypeConverter (org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)2 RegistryPackageWebConverter (org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter)2 Test (org.junit.Test)2 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 HashMap (java.util.HashMap)1 XmlParser (org.codice.ddf.parser.xml.XmlParser)1 RegistryObjectMetacardType (org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType)1 MetacardMarshaller (org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller)1 SlotTypeHelper (org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper)1 Before (org.junit.Before)1 BundleContext (org.osgi.framework.BundleContext)1