JacksonUtils { public static JsonNode stringToJsonNode(String paramName, String val) { if (val == null) { return null; } try { return MAPPER.readTree(val); } catch (IOException e) { throw new SdkClientException(paramName + " must be a valid JSON document", e); } } private  JacksonUtils(); static String jsonToString(JsonNode node); static JsonNode stringToJsonNode(String paramName, String val); static JsonNode objectToJsonNode(Object val);  }
@Test public void stringToJsonNode_NullString_ReturnsNull() { assertNull(stringToJsonNode("Param", null)); }
@Test public void stringToJsonNode_ValidJson_ReturnsJsonNode() throws JsonProcessingException { String json = "[1, 2, 3]"; JsonNode actual = stringToJsonNode("Param", json); assertJsonEquals(json, MAPPER.writeValueAsString(actual)); }
@Test(expected = SdkClientException.class) public void stringToJsonNode_InvalidJson_ThrowsException() throws JsonProcessingException { stringToJsonNode("Param", "{"); }