Search in sources :

Example 46 with CswSourceConfiguration

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

the class TestCswSource method testRefreshWithEmptyConfiguration.

@Test
public void testRefreshWithEmptyConfiguration() throws SecurityServiceException {
    AbstractCswSource cswSource = getCswSource(null, null, "type", null, null, encryptionService);
    CswSourceConfiguration defaultCswSourceConfiguration = getStandardCswSourceConfiguration(null, null, null, encryptionService);
    Map<String, Object> configuration = new HashMap<>();
    // Assert that the default configuration is set
    assertDefaultCswSourceConfiguration(cswSource.cswSourceConfiguration, defaultCswSourceConfiguration);
    cswSource.refresh(configuration);
    // Assert that the configuration does not change with an empty map
    assertDefaultCswSourceConfiguration(cswSource.cswSourceConfiguration, defaultCswSourceConfiguration);
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 47 with CswSourceConfiguration

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

the class TestCswSource method testRefreshWithNullConfiguration.

@Test
public void testRefreshWithNullConfiguration() throws SecurityServiceException {
    AbstractCswSource cswSource = getCswSource(null, null, "type", null, null, encryptionService);
    CswSourceConfiguration defaultCswSourceConfiguration = getStandardCswSourceConfiguration(null, null, null, encryptionService);
    // Assert that the default configuration is set
    assertDefaultCswSourceConfiguration(cswSource.cswSourceConfiguration, defaultCswSourceConfiguration);
    cswSource.refresh(null);
    // Assert that the configuration does not change with a null map
    assertDefaultCswSourceConfiguration(cswSource.cswSourceConfiguration, defaultCswSourceConfiguration);
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) Test(org.junit.Test)

Example 48 with CswSourceConfiguration

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

the class CswFilterDelegateTest 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 49 with CswSourceConfiguration

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

the class CswFilterDelegateTest method testDuringAlteredModifiedDateMapping.

@Test
public void testDuringAlteredModifiedDateMapping() throws JAXBException, SAXException, IOException {
    String replacedTemporalProperty = "myModifiedDate";
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, replacedTemporalProperty, CswConstants.CSW_IDENTIFIER);
    CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration);
    String xml = getXmlProperty(localCswFilterDelegate, propertyNameModified, 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);
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) Test(org.junit.Test)

Example 50 with CswSourceConfiguration

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

the class CswSourceTest method testRefresh.

@Test
public void testRefresh() throws SecurityServiceException {
    AbstractCswSource cswSource = getCswSource(mockCsw, mockContext, "contentType");
    CswSourceConfiguration defaultCswSourceConfiguration = getStandardCswSourceConfiguration("contentType", "qname", "queryprefix", encryptionService, permissions);
    // 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);
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

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