JSONBoundingBoxInputOutputHandler implements InputHandler, OutputHandler { @Override public Data<?> parse(TypedProcessInputDescription<?> description, InputStream input, Format format) throws IOException, DecodingException { JsonNode bboxNode = objectMapper.readTree(input); ArrayNode arrayNode = (ArrayNode) bboxNode.get(BBOX); JsonNode crsNode = bboxNode.path(CRS_KEY); OwsBoundingBox boundingBox = null; try { boundingBox = createOWSBoundingbox(crsNode.asText(), arrayNode.get(0).asDouble(), arrayNode.get(1).asDouble(), arrayNode.get(2).asDouble(), arrayNode.get(3).asDouble()); } catch (URISyntaxException e) { throw new DecodingException(e); } return new BoundingBoxData(boundingBox); } @Autowired  JSONBoundingBoxInputOutputHandler(ObjectMapper objectMapper, JsonNodeFactory jsonNodeFactory); @Override Set<Format> getSupportedFormats(); @Override Set<Class<? extends Data<?>>> getSupportedBindings(); @Override InputStream generate(TypedProcessOutputDescription<?> description, Data<?> data, Format format); @Override Data<?> parse(TypedProcessInputDescription<?> description, InputStream input, Format format);  }
@Test public void testJSONBBoxDeserializer() throws IOException, DecodingException { try (ByteArrayInputStream input = new ByteArrayInputStream(BBOX_JSON.getBytes(StandardCharsets.UTF_8))) { Data<?> data = handler.parse(null, input, FORMAT); assertThat(data, is(instanceOf(BoundingBoxData.class))); OwsBoundingBox bbox = ((BoundingBoxData) data).getPayload(); assertThat(bbox.getCRS().orElse(null), is(equalTo(EPSG_4326))); assertThat(Doubles.asList(bbox.getLowerCorner()), contains(is(closeTo(X_MIN, DELTA)), is(closeTo(Y_MIN, DELTA)))); assertThat(Doubles.asList(bbox.getUpperCorner()), contains(is(closeTo(X_MAX, DELTA)), is(closeTo(Y_MAX, DELTA)))); } }