@Test public void formatSingleResult() throws IOException { ObjectMapper mapper = new ObjectMapper(); String format = new ResultFormatterJSONv2().format(CypherTestUtil.CYPHER_RESULT); JsonNode jsonNode = mapper.readTree(format); assertThat(jsonNode.isArray(), is(true)); for (JsonNode interaction : jsonNode) { assertThat(interaction.get("type").getTextValue(), is("preyedUponBy")); JsonNode taxon = interaction.get("source"); assertThat(taxon.get("name").getTextValue(), is("Ariopsis felis")); taxon = interaction.get("target"); assertThat(taxon.get("name").getTextValue(), anyOf(is("Pomatomus saltatrix"), is("Lagodon rhomboides"), is("Centropomus undecimalis"))); assertThat(interaction.get("latitude").getDoubleValue(), is(notNullValue())); assertThat(interaction.get("longitude").getDoubleValue(), is(notNullValue())); if (interaction.has("altitude")) { assertThat(interaction.get("altitude").getDoubleValue(), is(notNullValue())); } if (interaction.has("time")) { assertThat(interaction.get("time").getLongValue() > 0, is(true)); } assertThat(interaction.get("study").getTextValue(), anyOf(is("SPIRE"), is("Akin et al 2006"), is("Blewett 2006"))); assertThat(interaction.get("study_title").asText(), anyOf(is("SPIRE"), is("Blewett 2006"), is("Akin et al 2006"))); assertThat(interaction.get("source_taxon_name").asText(), is("Ariopsis felis")); assertThat(interaction.get("latitude").asText(), is(notNullValue())); assertThat(interaction.get("longitude").asText(), is(notNullValue())); assertThat(interaction.get("interaction_type").asText(), is("preyedUponBy")); } }
@Override public String format(String result) throws ResultFormattingException { try { JsonNode jsonNode = RequestHelper.parse(result); return format(jsonNode); } catch (IOException e) { throw new ResultFormattingException("failed to format result", e); } }
ResultFormatterJSONv2 implements ResultFormatter { @Override public String format(String result) throws ResultFormattingException { try { JsonNode jsonNode = RequestHelper.parse(result); return format(jsonNode); } catch (IOException e) { throw new ResultFormattingException("failed to format result", e); } } }
ResultFormatterJSONv2 implements ResultFormatter { @Override public String format(String result) throws ResultFormattingException { try { JsonNode jsonNode = RequestHelper.parse(result); return format(jsonNode); } catch (IOException e) { throw new ResultFormattingException("failed to format result", e); } }  }
ResultFormatterJSONv2 implements ResultFormatter { @Override public String format(String result) throws ResultFormattingException { try { JsonNode jsonNode = RequestHelper.parse(result); return format(jsonNode); } catch (IOException e) { throw new ResultFormattingException("failed to format result", e); } }  @Override String format(String result); }
ResultFormatterJSONv2 implements ResultFormatter { @Override public String format(String result) throws ResultFormattingException { try { JsonNode jsonNode = RequestHelper.parse(result); return format(jsonNode); } catch (IOException e) { throw new ResultFormattingException("failed to format result", e); } }  @Override String format(String result);  }