### Question:
JsonHelper { public void setNodeValue(JsonNode rootNode, String jsonPtrExpr, String value) { if(StringUtils.isBlank(jsonPtrExpr) || StringUtils.equals(jsonPtrExpr,"/") || StringUtils.endsWith(jsonPtrExpr, "/")) { throw new JsonHelperException("jsonPtrExpr must be a subnode."); } JsonPointer valueNodePointer = JsonPointer.compile(jsonPtrExpr); JsonPointer containerPointer = valueNodePointer.head(); JsonNode parentJsonNode = rootNode.at(containerPointer); if (parentJsonNode.isMissingNode() || !parentJsonNode.isObject()) { throw new JsonHelperException(String.format("Failed to find node at ref %1$s", jsonPtrExpr)); } ((ObjectNode) parentJsonNode) .put( jsonPtrExpr.substring(jsonPtrExpr.lastIndexOf('/') + 1), value); } JsonHelper(); T getObjectFromRef(JsonNode rootNode, String ref, Class<T> clazz); Map<String, Object> getMapFromObject(Object object); T getObjectFromMap(Map<String, Object> map, Class<T> clazz); T getObjectFromString(String json, Class<T> clazz); String getJSONString(Object object); String getPrettyJSONString(Object object); void setNodeValue(JsonNode rootNode, String jsonPtrExpr, String value); ObjectMapper getObjectMapper();  }### Answer:
@Test (dataProvider = "invalidSetNodeJsonPointers", expectedExceptions = JsonHelperException.class, expectedExceptionsMessageRegExp = "jsonPtrExpr must be a subnode.+") public void testSetNodeValueInvalidInput(String jsonPtrExpr) { jsonHelper.setNodeValue(null, jsonPtrExpr, SUB_ID); }
@Test public void testSetNodeValue() throws Exception { SampleObject sampleObject = new SampleObject().setId(OBJ_ID); JsonNode jsonNode = objectMapper.valueToTree(sampleObject); jsonHelper.setNodeValue(jsonNode, "/id", SUB_ID); SampleObject adjustedObject = objectMapper.treeToValue(jsonNode, SampleObject.class); Assert.assertEquals(adjustedObject.getId(), SUB_ID); }