RemoteNeo4jTransformer implements DocumentTransformer<String> { @Override public String transform(String documentKey, String documentType, String jsonDocument) { String returnMessage = "JSON successfully transformed"; try { transformJson2Cypher(documentKey, documentType, jsonDocument); } catch (IOException e) { returnMessage = "Error during JSON transformation"; LOGGER.error("Error during JSON transformation: " + e.getMessage()); } return returnMessage; }  @Override String transform(String documentKey, String documentType, String jsonDocument);  }
@Test public void shouldRemoteTransformJson2CypherTest() { DocumentTransformer<String> remoteNeo4jTransformer = new RemoteNeo4jTransformer(); String jsonToConvert = "{\"firstname\": \"Lorenzo\", \"lastname\": \"Speranzoni\", \"age\": 41, \"job\": \"CEO @ LARUS Business Automation\"}"; String transformerResponse = remoteNeo4jTransformer.transform(null, "person", jsonToConvert); System.out.println(transformerResponse); }
@Test public void shouldTransformNestedJson2CypherTest() { DocumentTransformer<String> remoteNeo4jTransformer = new RemoteNeo4jTransformer(); String jsonAddressDocument = "{\"street\": \"Via B. Maderna, 7\", \"zipCode\": 30174, \"city\": \"Mestre\", \"province\": \"Venice\", \"country\": \"Italy\"}"; String jsonCompanyDocument = "{\"name\": \"LARUS Business Automation\", \"vat\": \"03540680273\", \"address\": " + jsonAddressDocument + "}"; String jsonJobDocument = "{\"role\": \"CEO\", \"company\": " + jsonCompanyDocument + "}"; String jsonPersonDocument = "{\"firstname\": \"Lorenzo\", \"lastname\": \"Speranzoni\", \"age\": 41, \"job\": " + jsonJobDocument + "}"; String trasnsformerResponese = remoteNeo4jTransformer.transform(null, "person", jsonPersonDocument); System.out.println(trasnsformerResponese); }