Neo4jStatement { public static String toJson(List<Neo4jStatement> queries, ObjectMapper mapper) throws SQLException { StringBuilder sb = new StringBuilder(); try { sb.append("{\"statements\":"); sb.append(mapper.writeValueAsString(queries)); sb.append("}"); } catch (JsonProcessingException e) { throw new SQLException("Can't convert Cypher statement(s) into JSON", e); } return sb.toString(); } Neo4jStatement(String statement, Map<String, Object> parameters, Boolean includeStats); static String escapeQuery(String query); static String toJson(List<Neo4jStatement> queries, ObjectMapper mapper); String getStatement(); final String statement; final Map<String, Object> parameters; final Boolean includeStats; }
@Test public void toJsonShouldSucceed() throws Exception { ObjectMapper mapper = new ObjectMapper(); Map<String, List> queries = getRandomNeo4jStatementFromCSV("data/queries.csv", -1); assertCSVQueryEqual(queries.get("source"), Neo4jStatement.toJson(queries.get("object"), mapper)); queries = getRandomNeo4jStatementFromCSV("data/queries.csv", 1); assertCSVQueryEqual(queries.get("source"), Neo4jStatement.toJson(queries.get("object"), mapper)); }