use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestCswFilterDelegate method testBefore.
@Test
public void testBefore() 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 = beforeXml.replace(REPLACE_TEMPORAL_PROPERTY, createdDateMapping).replace(REPLACE_DATE, dateStr);
CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration);
// Perform Test
FilterType filterType = localCswFilterDelegate.before(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 TestCswFilterDelegate method testDuringAlteredEffectiveDateMapping.
@Test
public void testDuringAlteredEffectiveDateMapping() throws JAXBException, SAXException, IOException {
String replacedTemporalProperty = "myEffectiveDate";
CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE, replacedTemporalProperty, createdDateMapping, modifiedDateMapping, CswConstants.CSW_IDENTIFIER);
CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration);
String xml = getXmlProperty(localCswFilterDelegate, propertyNameEffective, BETWEEN, testStartDate.toCalendar(null).getTime(), testEndDate.toCalendar(null).getTime());
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
String startDateStr = fmt.print(testStartDate);
String endDateStr = fmt.print(testEndDate);
String testResponse = duringXml.replace(REPLACE_START_DATE, startDateStr).replace(REPLACE_END_DATE, endDateStr).replace(REPLACE_TEMPORAL_PROPERTY, replacedTemporalProperty);
assertXMLEqual(testResponse, xml);
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestCswSource method testRefreshWithRegisterForEvents.
@Test
public void testRefreshWithRegisterForEvents() throws Exception {
String subscriptionId = "subscriptionid";
String eventEndpoint = "https://ddf/services/csw/subscriptions";
CswSourceStub cswSource = (CswSourceStub) getCswSource(mockCsw, mockContext, "contentType");
CswSubscribe client = mock(CswSubscribe.class);
Response response = mock(Response.class);
AcknowledgementType ack = mock(AcknowledgementType.class);
when(client.createRecordsSubscription(any(GetRecordsType.class))).thenReturn(response);
when(response.getStatus()).thenReturn(200);
when(response.readEntity(any(Class.class))).thenReturn(ack);
when(ack.getRequestId()).thenReturn(subscriptionId);
when(cswSource.getSubscriberClientFactory().getClientForSubject(cswSource.getSubject())).thenReturn(client);
// Set Configuration Map
Map<String, Object> configuration = getConfigurationMap(cswSource);
configuration.put(cswSource.REGISTER_FOR_EVENTS, true);
configuration.put(cswSource.EVENT_SERVICE_ADDRESS, eventEndpoint);
// Call Refresh
cswSource.refresh(configuration);
// Get Configuration
CswSourceConfiguration cswSourceConfiguration = cswSource.cswSourceConfiguration;
// Assert Refresh Changes
Assert.assertTrue(cswSourceConfiguration.isRegisterForEvents());
Assert.assertEquals(cswSourceConfiguration.getEventServiceAddress(), eventEndpoint);
verify(ack).getRequestId();
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestCswSource method testRefresh.
@Test
public void testRefresh() throws SecurityServiceException {
AbstractCswSource cswSource = getCswSource(mockCsw, mockContext, "contentType");
CswSourceConfiguration defaultCswSourceConfiguration = getStandardCswSourceConfiguration("contentType", "qname", "queryprefix", encryptionService);
// Assert Defaults
assertDefaultCswSourceConfiguration(cswSource.cswSourceConfiguration, defaultCswSourceConfiguration);
// Set Configuration Map
Map<String, Object> configuration = getConfigurationMap(cswSource);
when(encryptionService.decryptValue(PASSWORD)).thenReturn(PASSWORD);
// Call Refresh
cswSource.refresh(configuration);
// Get Configuration
CswSourceConfiguration cswSourceConfiguration = cswSource.cswSourceConfiguration;
// Assert Refresh Changes
assertConfigurationAfterRefresh(cswSourceConfiguration);
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestCswSource method getStandardCswSourceConfiguration.
private CswSourceConfiguration getStandardCswSourceConfiguration(String contentTypeMapping, String queryTypeQName, String queryTypePrefix, EncryptionService encryptionService) {
CswSourceConfiguration cswSourceConfiguration = new CswSourceConfiguration(encryptionService);
if (encryptionService != null) {
when(encryptionService.decryptValue("pass")).thenReturn("pass");
}
if (contentTypeMapping == null) {
cswSourceConfiguration.putMetacardCswMapping(Metacard.CONTENT_TYPE, CswConstants.CSW_TYPE);
} else {
cswSourceConfiguration.putMetacardCswMapping(Metacard.CONTENT_TYPE, contentTypeMapping);
}
cswSourceConfiguration.setQueryTypeNamespace(queryTypePrefix);
cswSourceConfiguration.setQueryTypeName(queryTypeQName);
cswSourceConfiguration.setId(ID);
cswSourceConfiguration.setCswUrl(URL);
cswSourceConfiguration.putMetacardCswMapping(Core.MODIFIED, Core.MODIFIED);
cswSourceConfiguration.putMetacardCswMapping(Core.ID, CswConstants.CSW_IDENTIFIER);
cswSourceConfiguration.setCswAxisOrder(CswAxisOrder.LON_LAT);
cswSourceConfiguration.setUsername("user");
cswSourceConfiguration.setPassword("pass");
return cswSourceConfiguration;
}
Aggregations