use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestCswFilterDelegate 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);
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestCswFilterDelegate method testIntersectsFallbackToNotDisjointPropertyOwsBoundingBox.
@Test
public void testIntersectsFallbackToNotDisjointPropertyOwsBoundingBox() throws JAXBException, SAXException, IOException {
String propName = CswConstants.BBOX_PROP;
CswSourceConfiguration cswSourceConfiguration = new CswSourceConfiguration();
cswSourceConfiguration.putMetacardCswMapping(Metacard.CONTENT_TYPE, CswConstants.CSW_TYPE);
CswFilterDelegate localCswFilterDelegate = initCswFilterDelegate(getMockFilterCapabilitiesForSpatialFallback(Arrays.asList(DISJOINT), Arrays.asList("Polygon")), initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE));
FilterType filterType = localCswFilterDelegate.intersects(propName, polygonWkt);
assertXMLEqual(notDisjointPolygonXmlPropertyOwsBoundingBox, getXmlFromMarshaller(filterType));
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestGetRecordsMessageBodyReader method testReadProductData.
@Test
public void testReadProductData() throws Exception {
CswSourceConfiguration config = new CswSourceConfiguration(encryptionService);
config.setMetacardCswMappings(DefaultCswRecordMap.getCswToMetacardAttributeNames());
config.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
GetRecordsMessageBodyReader reader = new GetRecordsMessageBodyReader(mockProvider, config);
String sampleData = "SampleData";
byte[] data = sampleData.getBytes();
ByteArrayInputStream dataInputStream = new ByteArrayInputStream(data);
MultivaluedMap<String, String> httpHeaders = new MultivaluedHashMap<>();
httpHeaders.add(CswConstants.PRODUCT_RETRIEVAL_HTTP_HEADER, "TRUE");
httpHeaders.add(HttpHeaders.CONTENT_DISPOSITION, String.format("inline; filename=ResourceName"));
MediaType mediaType = new MediaType("text", "plain");
CswRecordCollection cswRecords = reader.readFrom(CswRecordCollection.class, null, null, mediaType, httpHeaders, dataInputStream);
Resource resource = cswRecords.getResource();
assertThat(resource, notNullValue());
assertThat(resource.getName(), is("ResourceName"));
assertThat(resource.getMimeType().toString(), is(MediaType.TEXT_PLAIN));
assertThat(resource.getByteArray(), is(data));
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestGetRecordsMessageBodyReader method testPartialContentNotSupportedHandling.
@Test
public void testPartialContentNotSupportedHandling() throws Exception {
CswSourceConfiguration config = new CswSourceConfiguration(encryptionService);
config.setMetacardCswMappings(DefaultCswRecordMap.getCswToMetacardAttributeNames());
config.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
GetRecordsMessageBodyReader reader = new GetRecordsMessageBodyReader(mockProvider, config);
String sampleData = "SampleData";
byte[] data = sampleData.getBytes();
ByteArrayInputStream dataInputStream = new ByteArrayInputStream(data);
MultivaluedMap<String, String> httpHeaders = new MultivaluedHashMap<>();
httpHeaders.add(CswConstants.PRODUCT_RETRIEVAL_HTTP_HEADER, "TRUE");
httpHeaders.add(HttpHeaders.CONTENT_DISPOSITION, String.format("inline; filename=ResourceName"));
MediaType mediaType = new MediaType("text", "plain");
CswRecordCollection cswRecords = reader.readFrom(CswRecordCollection.class, null, null, mediaType, httpHeaders, dataInputStream);
Resource resource = cswRecords.getResource();
// assert that the CswRecordCollection property is not set if the server does not support Partial Content responses
assertThat(cswRecords.getResourceProperties().get(GetRecordsMessageBodyReader.BYTES_SKIPPED), nullValue());
// assert that the input stream has not been skipped at this stage. Since AbstractCswSource has the number
// of bytes that was attempted to be skipped, the stream must be aligned there instead.
assertThat(resource.getByteArray(), is(data));
}
use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.
the class TestGetRecordsMessageBodyReader method testFullThread.
@Test
public void testFullThread() throws Exception {
List<Metacard> inputMetacards = new ArrayList<>();
MetacardImpl metacard = new MetacardImpl(BasicTypes.BASIC_METACARD);
metacard.setId("metacard1");
metacard.setTitle("title1");
inputMetacards.add(metacard);
CswRecordCollection collection = new CswRecordCollection();
collection.setCswRecords(inputMetacards);
when(mockProvider.unmarshal(any(), any())).thenReturn(collection);
CswSourceConfiguration config = new CswSourceConfiguration(encryptionService);
Map<String, String> mappings = new HashMap<>();
mappings.put(Core.CREATED, "dateSubmitted");
mappings.put(Metacard.EFFECTIVE, "created");
mappings.put(Core.MODIFIED, "modified");
mappings.put(Metacard.CONTENT_TYPE, "type");
config.setMetacardCswMappings(mappings);
config.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
config.setCswAxisOrder(CswAxisOrder.LAT_LON);
config.putMetacardCswMapping(Core.THUMBNAIL, CswConstants.CSW_REFERENCES);
config.putMetacardCswMapping(Core.RESOURCE_URI, CswConstants.CSW_SOURCE);
GetRecordsMessageBodyReader reader = new GetRecordsMessageBodyReader(mockProvider, config);
InputStream is = TestGetRecordsMessageBodyReader.class.getResourceAsStream("/getRecordsResponse.xml");
MultivaluedMap<String, String> httpHeaders = new MultivaluedHashMap<>();
CswRecordCollection cswRecords = reader.readFrom(CswRecordCollection.class, null, null, null, httpHeaders, is);
List<Metacard> metacards = cswRecords.getCswRecords();
assertThat(metacards, contains(metacard));
}
Aggregations