@Test public void testGetNode() { final String TEST_FIELD = "testField"; final String TEST_VALUE = "testValue"; final String TEST_PATH = "testLevel1.testLevel2"; final int TEST_VERSION = 1; JsonNode nodeToHistory = JsonHandler.createObjectNode().put(TEST_FIELD, TEST_VALUE); History history = new History(TEST_PATH, TEST_VERSION, nodeToHistory); JsonNode node = history.getNode(); Assert.assertTrue(node.isObject()); String arrayNodeString = node.toString(); JsonPath path = JsonPath.from(arrayNodeString); Assert.assertNotNull(path.get("ud")); Assert.assertNotNull(path.get("data")); Assert.assertEquals(TEST_VERSION, path.getInt("data._v")); Assert.assertEquals(TEST_VALUE, path.getString("data." + TEST_PATH + "." + TEST_FIELD)); }
public JsonNode getNode() { ObjectNode history = JsonHandler.createObjectNode(); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); createBranch(data).set(namePathForHistory, nodeToHistory); return history; }
History { public JsonNode getNode() { ObjectNode history = JsonHandler.createObjectNode(); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); createBranch(data).set(namePathForHistory, nodeToHistory); return history; } }
History { public JsonNode getNode() { ObjectNode history = JsonHandler.createObjectNode(); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); createBranch(data).set(namePathForHistory, nodeToHistory); return history; } History(String objectPathForHistory, long version, JsonNode nodeToHistory); }
History { public JsonNode getNode() { ObjectNode history = JsonHandler.createObjectNode(); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); createBranch(data).set(namePathForHistory, nodeToHistory); return history; } History(String objectPathForHistory, long version, JsonNode nodeToHistory); JsonNode getArrayNode(); JsonNode getNode(); }
History { public JsonNode getNode() { ObjectNode history = JsonHandler.createObjectNode(); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); createBranch(data).set(namePathForHistory, nodeToHistory); return history; } History(String objectPathForHistory, long version, JsonNode nodeToHistory); JsonNode getArrayNode(); JsonNode getNode();  }