Search in sources :

Example 1 with AttributeRegistry

use of ddf.catalog.data.AttributeRegistry in project ddf by codice.

the class CswQueryFactoryTest method setUp.

@org.junit.Before
public void setUp() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
    filterBuilder = new GeotoolsFilterBuilder();
    FilterAdapter filterAdapter = new GeotoolsFilterAdapterImpl();
    metacardTypeList = new ArrayList<>();
    queryFactory = new CswQueryFactory(filterBuilder, filterAdapter, getCswMetacardType(), metacardTypeList);
    AttributeRegistry mockAttributeRegistry = mock(AttributeRegistry.class);
    when(mockAttributeRegistry.lookup(TITLE_TEST_ATTRIBUTE)).thenReturn(Optional.of(mock(AttributeDescriptor.class)));
    queryFactory.setAttributeRegistry(mockAttributeRegistry);
    polygon = new WKTReader().read(POLYGON_STR);
    gmlObjectFactory = new net.opengis.gml.v_3_1_1.ObjectFactory();
    filterObjectFactory = new ObjectFactory();
}
Also used : ObjectFactory(net.opengis.filter.v_1_1_0.ObjectFactory) AttributeRegistry(ddf.catalog.data.AttributeRegistry) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) WKTReader(com.vividsolutions.jts.io.WKTReader)

Example 2 with AttributeRegistry

use of ddf.catalog.data.AttributeRegistry in project ddf by codice.

the class TestCatalog method testMetacardDefinitionJsonFile.

@Test
// DDF-2743
@ConditionalIgnore(condition = SkipUnstableTest.class)
public void testMetacardDefinitionJsonFile() throws Exception {
    final String newMetacardTypeName = "new.metacard.type";
    getServiceManager().stopFeature(true, "catalog-security-filter");
    File file = ingestDefinitionJsonWithWaitCondition("definitions.json", () -> {
        expect("Service to be available: " + MetacardType.class.getName()).within(30, TimeUnit.SECONDS).until(() -> getServiceManager().getServiceReferences(MetacardType.class, "(name=" + newMetacardTypeName + ")"), not(empty()));
        return null;
    });
    String ddfMetacardXml = getFileContent("metacard1.xml");
    String modifiedMetacardXml = ddfMetacardXml.replaceFirst("ddf\\.metacard", newMetacardTypeName).replaceFirst("resource-uri", "new-attribute-required-2");
    String id = ingest(modifiedMetacardXml, "text/xml");
    configureShowInvalidMetacards("true", "true", getAdminConfig());
    try {
        String newMetacardXpath = format("/metacards/metacard[@id=\"%s\"]", id);
        executeOpenSearch("xml", "q=*").log().all().assertThat().body(hasXPath(newMetacardXpath + "/type", is(newMetacardTypeName))).body(hasXPath("count(" + newMetacardXpath + "/string[@name=\"validation-errors\"]/value)", is("1"))).body(hasXPath(newMetacardXpath + "/string[@name=\"validation-errors\"]/value[text()=\"new-attribute-required-1 is required\"]")).body(hasXPath(newMetacardXpath + "/string[@name=\"new-attribute-required-2\"]/value", is("\" + uri + \"")));
    } finally {
        deleteMetacard(id);
        uninstallDefinitionJson(file, () -> {
            AttributeRegistry attributeRegistry = getServiceManager().getService(AttributeRegistry.class);
            expect("Attributes to be unregistered").within(10, TimeUnit.SECONDS).until(() -> !attributeRegistry.lookup("new-attribute-required-2").isPresent());
            return null;
        });
        getServiceManager().startFeature(true, "catalog-security-filter");
        configureShowInvalidMetacards("false", "false", getAdminConfig());
    }
}
Also used : AttributeRegistry(ddf.catalog.data.AttributeRegistry) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) MetacardType(ddf.catalog.data.MetacardType) ConditionalIgnore(org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 3 with AttributeRegistry

use of ddf.catalog.data.AttributeRegistry in project ddf by codice.

the class TestGeoJsonExtensible method setUp.

@Before
public void setUp() {
    transformer = new GeoJsonInputTransformer();
    transformer.setMetacardTypes(prepareMetacardTypes());
    AttributeRegistry attributeRegistry = new AttributeRegistryImpl();
    attributeRegistry.register(new AttributeDescriptorImpl(TEMPERATURE_KEY, true, true, true, true, DOUBLE_TYPE));
    transformer.setAttributeRegistry(attributeRegistry);
}
Also used : AttributeRegistry(ddf.catalog.data.AttributeRegistry) AttributeRegistryImpl(ddf.catalog.data.impl.AttributeRegistryImpl) AttributeDescriptorImpl(ddf.catalog.data.impl.AttributeDescriptorImpl) Before(org.junit.Before)

Example 4 with AttributeRegistry

use of ddf.catalog.data.AttributeRegistry in project ddf by codice.

the class AttributeInjectorImplTest method setUp.

@Before
public void setUp() {
    AttributeRegistry attributeRegistry = new AttributeRegistryImpl();
    attributeInjector = new AttributeInjectorImpl(attributeRegistry);
    attributeRegistry.register(globalAttribute);
    attributeRegistry.register(basicAttribute);
    attributeRegistry.register(basicAndNitfAttribute);
    attributeInjector.setInjectableAttributes(Lists.newArrayList(globalInjection, basicInjection, basicAndNitfInjection));
}
Also used : AttributeRegistry(ddf.catalog.data.AttributeRegistry) AttributeRegistryImpl(ddf.catalog.data.impl.AttributeRegistryImpl) Before(org.junit.Before)

Aggregations

AttributeRegistry (ddf.catalog.data.AttributeRegistry)4 AttributeRegistryImpl (ddf.catalog.data.impl.AttributeRegistryImpl)2 Before (org.junit.Before)2 WKTReader (com.vividsolutions.jts.io.WKTReader)1 MetacardType (ddf.catalog.data.MetacardType)1 AttributeDescriptorImpl (ddf.catalog.data.impl.AttributeDescriptorImpl)1 FilterAdapter (ddf.catalog.filter.FilterAdapter)1 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 File (java.io.File)1 ObjectFactory (net.opengis.filter.v_1_1_0.ObjectFactory)1 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)1 ConditionalIgnore (org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule.ConditionalIgnore)1 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1