Search in sources :

Example 1 with RegistryPackageWebConverter

use of org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter in project ddf by codice.

the class FederationAdminTest method testGetLocalNodes.

@Test
public void testGetLocalNodes() throws Exception {
    RegistryPackageType registryObject = getRegistryObjectFromResource("/csw-registry-package-smaller.xml");
    Map<String, Object> registryObjectMap = new RegistryPackageWebConverter().convert(registryObject);
    List<RegistryPackageType> registryPackages = new ArrayList<>();
    registryPackages.add((RegistryPackageType) registryObject);
    when(federationAdminService.getLocalRegistryObjects()).thenReturn(registryPackages);
    Map<String, Object> localNodes = federationAdmin.getLocalNodes();
    Map<String, Object> localNode = ((List<Map<String, Object>>) localNodes.get(LOCAL_NODE_KEY)).get(0);
    verify(federationAdminService).getLocalRegistryObjects();
    assertThat(localNode, is(equalTo(registryObjectMap)));
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryPackageWebConverter(org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Matchers.anyList(org.mockito.Matchers.anyList) Test(org.junit.Test)

Example 2 with RegistryPackageWebConverter

use of org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter 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 RegistryPackageWebConverter

use of org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter 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

RegistryPackageWebConverter (org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)2 RegistryPackageTypeConverter (org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter)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 ArrayList (java.util.ArrayList)1 List (java.util.List)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 Matchers.anyList (org.mockito.Matchers.anyList)1 BundleContext (org.osgi.framework.BundleContext)1