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));
}
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));
}
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));
}
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));
}
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;
}
Aggregations