@Test public void testGetArrayNode() { 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 arrayNode = history.getArrayNode(); Assert.assertTrue(arrayNode.isArray()); String arrayNodeString = arrayNode.toString(); JsonPath path = JsonPath.from(arrayNodeString); Assert.assertNotNull(path.get("[0].ud")); Assert.assertNotNull(path.get("[0].data")); Assert.assertEquals(TEST_VERSION, path.getInt("[0].data._v")); Assert.assertEquals(TEST_VALUE, path.getString("[0].data." + TEST_PATH + "." + TEST_FIELD)); }
public JsonNode getArrayNode() { final ArrayNode historyArray = JsonHandler.createArrayNode(); ObjectNode history = JsonHandler.createObjectNode(); historyArray.add(history); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); if(nodeToHistory.isMissingNode()) { createBranch(data); } else { createBranch(data).set(namePathForHistory, nodeToHistory); } return historyArray; }
History { public JsonNode getArrayNode() { final ArrayNode historyArray = JsonHandler.createArrayNode(); ObjectNode history = JsonHandler.createObjectNode(); historyArray.add(history); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); if(nodeToHistory.isMissingNode()) { createBranch(data); } else { createBranch(data).set(namePathForHistory, nodeToHistory); } return historyArray; } }
History { public JsonNode getArrayNode() { final ArrayNode historyArray = JsonHandler.createArrayNode(); ObjectNode history = JsonHandler.createObjectNode(); historyArray.add(history); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); if(nodeToHistory.isMissingNode()) { createBranch(data); } else { createBranch(data).set(namePathForHistory, nodeToHistory); } return historyArray; } History(String objectPathForHistory, long version, JsonNode nodeToHistory); }
History { public JsonNode getArrayNode() { final ArrayNode historyArray = JsonHandler.createArrayNode(); ObjectNode history = JsonHandler.createObjectNode(); historyArray.add(history); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); if(nodeToHistory.isMissingNode()) { createBranch(data); } else { createBranch(data).set(namePathForHistory, nodeToHistory); } return historyArray; } History(String objectPathForHistory, long version, JsonNode nodeToHistory); JsonNode getArrayNode(); JsonNode getNode(); }
History { public JsonNode getArrayNode() { final ArrayNode historyArray = JsonHandler.createArrayNode(); ObjectNode history = JsonHandler.createObjectNode(); historyArray.add(history); history.put(UD, LocalDateUtil.getFormattedDateForMongo(LocalDateUtil.now())); ObjectNode data = history.putObject(DATA); data.put(_V, version); if(nodeToHistory.isMissingNode()) { createBranch(data); } else { createBranch(data).set(namePathForHistory, nodeToHistory); } return historyArray; } History(String objectPathForHistory, long version, JsonNode nodeToHistory); JsonNode getArrayNode(); JsonNode getNode();  }