Search in sources :

Example 6 with MetacardMarshaller

use of org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller in project ddf by codice.

the class IdentificationPluginTest method setUp.

@Before
public void setUp() {
    UuidGenerator uuidGenerator = mock(UuidGenerator.class);
    when(uuidGenerator.generateUuid()).thenReturn(UUID.randomUUID().toString());
    parser = new XmlParser();
    identificationPlugin = new IdentificationPlugin(uuidGenerator);
    identificationPlugin.setMetacardMarshaller(new MetacardMarshaller(parser));
    identificationPlugin.setRegistryIdPostIngestPlugin(new RegistryIdPostIngestPlugin());
    setParser(parser);
    sampleData = new MetacardImpl();
    sampleData.setId("testNewMetacardId");
    sampleData.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "testNewRegistryId");
    sampleData.setAttribute(Metacard.MODIFIED, new Date().from(Instant.now()));
    Set<String> tags = new HashSet<>();
    tags.add("registry");
    sampleData.setTags(tags);
    System.setProperty(RegistryConstants.REGISTRY_ID_PROPERTY, "systemRegistryId");
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) UuidGenerator(org.codice.ddf.platform.util.uuidgenerator.UuidGenerator) MetacardMarshaller(org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Date(java.util.Date) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 7 with MetacardMarshaller

use of org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller in project ddf by codice.

the class TestRegistryStore method setup.

@Before
public void setup() throws Exception {
    parser = new XmlParser();
    marshaller = new MetacardMarshaller(new XmlParser());
    context = mock(BundleContext.class);
    provider = mock(Converter.class);
    cswSourceConfiguration = new CswSourceConfiguration();
    factory = mock(SecureCxfClientFactory.class);
    transformer = mock(TransformerManager.class);
    encryptionService = mock(EncryptionService.class);
    configAdmin = mock(ConfigurationAdmin.class);
    configuration = mock(Configuration.class);
    subject = mock(Subject.class);
    queryResults = new ArrayList<>();
    registryStore = spy(new RegistryStoreImpl(context, cswSourceConfiguration, provider, factory, encryptionService) {

        @Override
        protected void validateOperation() {
        }

        @Override
        public boolean isAvailable() {
            return availability;
        }

        @Override
        protected SourceResponse query(QueryRequest queryRequest, ElementSetType elementSetName, List<QName> elementNames, Csw csw) throws UnsupportedQueryException {
            if (queryResults == null) {
                throw new UnsupportedQueryException("Test - Bad Query");
            }
            return new SourceResponseImpl(queryRequest, queryResults);
        }

        @Override
        protected CapabilitiesType getCapabilities() {
            return mock(CapabilitiesType.class);
        }

        @Override
        public void configureCswSource() {
        }

        ;

        @Override
        protected Subject getSystemSubject() {
            return subject;
        }

        @Override
        BundleContext getBundleContext() {
            return context;
        }
    });
    registryStore.setFilterBuilder(filterBuilder);
    registryStore.setFilterAdapter(filterAdapter);
    registryStore.setConfigAdmin(configAdmin);
    registryStore.setMetacardMarshaller(new MetacardMarshaller(parser));
    registryStore.setSchemaTransformerManager(transformer);
    registryStore.setAutoPush(true);
    registryStore.setRegistryUrl("http://test.url:0101/example");
    properties = new Hashtable<>();
    properties.put(RegistryStoreImpl.ID, "registryId");
    registryStore.setMetacardMarshaller(marshaller);
    when(configAdmin.getConfiguration(any())).thenReturn(configuration);
    when(configuration.getProperties()).thenReturn(properties);
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) XmlParser(org.codice.ddf.parser.xml.XmlParser) TransformerManager(org.codice.ddf.spatial.ogc.csw.catalog.common.transformer.TransformerManager) Configuration(org.osgi.service.cm.Configuration) CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) QueryRequest(ddf.catalog.operation.QueryRequest) SecureCxfClientFactory(org.codice.ddf.cxf.SecureCxfClientFactory) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) MetacardMarshaller(org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) Subject(ddf.security.Subject) EncryptionService(ddf.security.encryption.EncryptionService) ElementSetType(net.opengis.cat.csw.v_2_0_2.ElementSetType) Converter(com.thoughtworks.xstream.converters.Converter) List(java.util.List) ArrayList(java.util.ArrayList) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) BundleContext(org.osgi.framework.BundleContext) Before(org.junit.Before)

Aggregations

MetacardMarshaller (org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller)7 Before (org.junit.Before)6 XmlParser (org.codice.ddf.parser.xml.XmlParser)5 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)4 BundleContext (org.osgi.framework.BundleContext)4 QueryRequest (ddf.catalog.operation.QueryRequest)3 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)3 RegistryObjectMetacardType (org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType)3 ResultImpl (ddf.catalog.data.impl.ResultImpl)2 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)2 Subject (ddf.security.Subject)2 ArrayList (java.util.ArrayList)2 ElementSetType (net.opengis.cat.csw.v_2_0_2.ElementSetType)2 SlotTypeHelper (org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper)2 Csw (org.codice.ddf.spatial.ogc.csw.catalog.common.Csw)2 Configuration (org.osgi.service.cm.Configuration)2 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)2 Converter (com.thoughtworks.xstream.converters.Converter)1 Metacard (ddf.catalog.data.Metacard)1 Result (ddf.catalog.data.Result)1