use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class TestGeoJsonMetacardTransformer method testwithPolygonGeoNoHole.
@Test
public void testwithPolygonGeoNoHole() throws CatalogTransformerException, IOException, ParseException {
Date now = new Date();
MetacardImpl metacard = new MetacardImpl();
metacard.setLocation("POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))");
setupBasicMetacard(now, metacard);
GeoJsonMetacardTransformer transformer = new GeoJsonMetacardTransformer();
BinaryContent content = transformer.transform(metacard, null);
assertEquals(content.getMimeTypeValue(), GeoJsonMetacardTransformer.DEFAULT_MIME_TYPE.getBaseType());
String jsonText = new String(content.getByteArray());
LOGGER.debug(jsonText);
Object object = PARSER.parse(jsonText);
JSONObject obj2 = (JSONObject) object;
Map geometryMap = (Map) obj2.get("geometry");
assertThat(geometryMap.get(CompositeGeometry.TYPE_KEY).toString(), is(Polygon.TYPE));
List<List> listOfRings = (List<List>) geometryMap.get(CompositeGeometry.COORDINATES_KEY);
assertThat(listOfRings.size(), is(1));
List<List> exteriorRing = listOfRings.get(0);
testPopularPolygon(exteriorRing);
verifyBasicMetacardJson(now, obj2);
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class ConfigurationStore method getDocument.
@GET
@Path("/config")
public Response getDocument(@Context UriInfo uriInfo, @Context HttpServletRequest httpRequest) {
Response response;
Map<String, Object> config = new HashMap<>();
config.put("branding", getProductName());
config.put("version", getProductVersion());
config.put("showWelcome", isSignIn);
config.put("showTask", isTask);
config.put("format", format);
config.put("timeout", timeout);
config.put("resultCount", resultCount);
config.put("typeNameMapping", typeNameMapping);
config.put("terrainProvider", proxiedTerrainProvider);
config.put("imageryProviders", getProxiedImageryProviders());
config.put("gazetteer", isGazetteer);
config.put("showIngest", isIngest);
config.put("projection", projection);
config.put("helpUrl", helpUrl);
config.put("bingKey", bingKey);
config.put("externalAuthentication", isExternalAuthentication);
String configJson = toJson(config);
BinaryContent content = new BinaryContentImpl(new ByteArrayInputStream(configJson.getBytes(StandardCharsets.UTF_8)), jsonMimeType);
response = Response.ok(content.getInputStream(), content.getMimeTypeValue()).build();
return response;
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class TestXmlResponseQueueTransformer method testEmptySourceResponse.
/**
* @throws CatalogTransformerException
*/
@Test
public void testEmptySourceResponse() throws CatalogTransformerException, IOException, XpathException, SAXException {
// given
transformer.setThreshold(-1);
SourceResponse response = new SourceResponseImpl(null, Collections.<Result>emptyList());
// when
BinaryContent binaryContent = transformer.transform(response, null);
// then
String output = new String(binaryContent.getByteArray());
LOGGER.info(output);
assertXpathEvaluatesTo("", "/mc:metacards", output);
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class TestXmlResponseQueueTransformer method testNoId.
@Test
public void testNoId() throws CatalogTransformerException, IOException, XpathException, SAXException {
// given
transformer.setThreshold(2);
SourceResponse response = givenSourceResponse(DEFAULT_SOURCE_ID, null);
// when
BinaryContent binaryContent = transformer.transform(response, null);
// then
assertThat(binaryContent.getMimeType(), is(mimeType));
byte[] bytes = binaryContent.getByteArray();
String output = new String(bytes);
print(output, verboseDebug);
assertXpathEvaluatesTo(DEFAULT_SOURCE_ID, "/mc:metacards/mc:metacard/mc:source", output);
assertXpathNotExists("/mc:metacards/mc:metacard/@gml:id", output);
verifyDefaults("1", output);
}
use of ddf.catalog.data.BinaryContent in project ddf by codice.
the class TestXmlResponseQueueTransformer method testMetacardTypeNameNull.
/**
* No {@link MetacardType} name should use the default name.
*
* @throws CatalogTransformerException
* @throws IOException
* @throws SAXException
* @throws XpathException
*/
@Test
public void testMetacardTypeNameNull() throws CatalogTransformerException, IOException, XpathException, SAXException {
// given
transformer.setThreshold(2);
SourceResponse response = givenMetacardTypeName(null);
// when
BinaryContent binaryContent = transformer.transform(response, null);
// then
assertThat(binaryContent.getMimeType(), is(mimeType));
byte[] bytes = binaryContent.getByteArray();
String output = new String(bytes);
print(output, verboseDebug);
assertXpathEvaluatesTo(DEFAULT_TYPE_NAME, "/mc:metacards/mc:metacard/mc:type", output);
}
Aggregations