Search in sources :

Example 36 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class TestCswFilterDelegate method testAfter.

@Test
public void testAfter() throws Exception {
    // Setup
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, modifiedDateMapping, CswConstants.CSW_IDENTIFIER);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    String dateStr = fmt.print(testStartDate);
    String controlFilterAsXml = afterXml.replace(REPLACE_TEMPORAL_PROPERTY, createdDateMapping).replace(REPLACE_DATE, dateStr);
    CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration);
    // Perform Test
    FilterType filterType = localCswFilterDelegate.after(propertyNameCreated, testStartDate.toDate());
    // Verify
    assertXMLEqual(controlFilterAsXml, getXmlFromMarshaller(filterType));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) FilterType(net.opengis.filter.v_1_1_0.FilterType) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) Test(org.junit.Test)

Example 37 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class TestCswCqlFilter method testPropertyIsEqualToStringLiteralAlternateIdMapping.

/**
     * Property is equal to with alternate id property
     *
     * @throws UnsupportedQueryException
     */
@Test
public void testPropertyIsEqualToStringLiteralAlternateIdMapping() throws UnsupportedQueryException {
    String replacedIdentifierProperty = propertyName;
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, modifiedDateMapping, replacedIdentifierProperty);
    CswFilterDelegate cswFilterDelegate = initDefaultCswFilterDelegate(cswSourceConfiguration);
    FilterType filterType = cswFilterDelegate.propertyIsEqualTo(propertyName, stringLiteral, isCaseSensitive);
    String cqlText = CswCqlTextFilter.getInstance().getCqlText(filterType);
    assertThat(propertyIsEqualTo, is(cqlText));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) FilterType(net.opengis.filter.v_1_1_0.FilterType) Test(org.junit.Test)

Example 38 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class TestCswCqlFilter method testRelative.

@Test
public void testRelative() throws UnsupportedQueryException {
    long duration = 92000000000L;
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, modifiedDateMapping, CswConstants.CSW_IDENTIFIER);
    CswFilterDelegate localCswFilterDelegate = initDefaultCswFilterDelegate(cswSourceConfiguration);
    FilterType filterType = localCswFilterDelegate.relative(propertyNameModified, duration);
    String cqlText = CswCqlTextFilter.getInstance().getCqlText(filterType);
    String durationCompare = during.replace(REPLACE_START_DATE, "").replace(REPLACE_END_DATE, "").replace(REPLACE_TEMPORAL_PROPERTY, modifiedDateMapping);
    String pattern = "(?i)(')(.+?)(')";
    String compareXml = cqlText.replaceAll(pattern, "''");
    assertThat(durationCompare, is(compareXml));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) FilterType(net.opengis.filter.v_1_1_0.FilterType) Test(org.junit.Test)

Example 39 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class TestCswCqlFilter method testDuringAlteredModifiedDateMapping.

@Test
public void testDuringAlteredModifiedDateMapping() throws UnsupportedQueryException {
    DateTime startDate = new DateTime(2013, 5, 1, 0, 0, 0, 0);
    DateTime endDate = new DateTime(2013, 12, 31, 0, 0, 0, 0);
    String replacedTemporalProperty = "myModifiedDate";
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, replacedTemporalProperty, CswConstants.CSW_IDENTIFIER);
    CswFilterDelegate localCswFilterDelegate = initDefaultCswFilterDelegate(cswSourceConfiguration);
    FilterType filterType = localCswFilterDelegate.during(propertyNameModified, startDate.toCalendar(null).getTime(), endDate.toCalendar(null).getTime());
    String cqlText = CswCqlTextFilter.getInstance().getCqlText(filterType);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    String startDateStr = fmt.print(startDate);
    String endDateStr = fmt.print(endDate);
    String testResponse = during.replace(REPLACE_START_DATE, startDateStr).replace(REPLACE_END_DATE, endDateStr).replace(REPLACE_TEMPORAL_PROPERTY, replacedTemporalProperty);
    assertThat(testResponse, is(cqlText));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) FilterType(net.opengis.filter.v_1_1_0.FilterType) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 40 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class TestCswSource method getCswSource.

private AbstractCswSource getCswSource(Csw csw, BundleContext context, String contentMapping, String queryTypeQName, String queryTypePrefix, EncryptionService encryptionService) {
    CswSourceConfiguration cswSourceConfiguration = getStandardCswSourceConfiguration(contentMapping, queryTypeQName, queryTypePrefix, encryptionService);
    cswSourceConfiguration.putMetacardCswMapping(Metacard.CONTENT_TYPE, contentMapping);
    SecureCxfClientFactory mockFactory = mock(SecureCxfClientFactory.class);
    doReturn(csw).when(mockFactory).getClient();
    doReturn(csw).when(mockFactory).getClientForSubject(any(Subject.class));
    CswSourceStub cswSource = new CswSourceStub(mockContext, cswSourceConfiguration, mockProvider, mockFactory, encryptionService);
    setMetacardType(cswSource);
    cswSource.setFilterAdapter(new GeotoolsFilterAdapterImpl());
    cswSource.setFilterBuilder(builder);
    cswSource.setContext(context);
    cswSource.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
    cswSource.setAvailabilityTask(mockAvailabilityTask);
    cswSource.setMetacardTypes(mockRegistry);
    cswSource.configureCswSource();
    return cswSource;
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) SecureCxfClientFactory(org.codice.ddf.cxf.SecureCxfClientFactory) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) Subject(org.apache.shiro.subject.Subject)

Aggregations

CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)70 Test (org.junit.Test)60 FilterType (net.opengis.filter.v_1_1_0.FilterType)24 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)20 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)15 ByteArrayInputStream (java.io.ByteArrayInputStream)14 Matchers.anyString (org.mockito.Matchers.anyString)14 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)11 Matchers.containsString (org.hamcrest.Matchers.containsString)9 InputStream (java.io.InputStream)8 HashMap (java.util.HashMap)8 DateTime (org.joda.time.DateTime)8 ResourceResponse (ddf.catalog.operation.ResourceResponse)6 SourceResponse (ddf.catalog.operation.SourceResponse)6 Resource (ddf.catalog.resource.Resource)6 MediaType (javax.ws.rs.core.MediaType)6 Response (javax.ws.rs.core.Response)6 AcknowledgementType (net.opengis.cat.csw.v_2_0_2.AcknowledgementType)6 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)6 CswSubscribe (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSubscribe)6