### Question:
JSONConverter { public <T> T fromJSON(Class<T> clazz, String jSON) throws JSONConverterException { if (clazz == null) { throw new IllegalStateException("clazz may not be null!"); } String string = jSON; if (jSON == null) { string = ""; } try { byte[] bytes = string.getBytes(); return mapper.readValue(bytes, clazz); } catch (IOException e) { LOG.debug("JSON conversion failed, origin JSON:\n{}", jSON); String truncatedJSON = SimpleStringUtils.truncateWhenTooLong(jSON, 300); throw new JSONConverterException("Was not able to convert JSON string to " + clazz + " object\nContent was:\n" + truncatedJSON, e); } } JSONConverter(); static JSONConverter get(); String toJSON(Object object); String toJSON(Object object, boolean prettyPrinted); T fromJSON(Class<T> clazz, String jSON);  }### Answer:
@Test public void fromJSON_correct_json_with_double_quotes_results_in_expected_object() throws Exception { String json = "{\"info\":\"test1\"}"; JSONConverterTestObject result = converterToTest.fromJSON(JSONConverterTestObject.class, json); assertEquals("test1", result.getInfo()); }
@Test public void fromJSON_correct_json_with_single_quotes_results_in_expected_object() throws Exception { String json = "{'info':'info1'}"; JSONConverterTestObject result = converterToTest.fromJSON(JSONConverterTestObject.class, json); assertNotNull(result); assertEquals("info1", result.getInfo()); }
@Test public void fromJSON_when_string_null_throws_JSONConverterException() throws Exception { expected.expect(JSONConverterException.class); converterToTest.fromJSON(JSONConverterTestObject.class, null); }
@Test public void fromJSON_comments_are_allowed() throws Exception { String json = " JSONConverterTestObject result = converterToTest.fromJSON(JSONConverterTestObject.class, json); assertNotNull(result); assertEquals("info1", result.getInfo()); }