JSONApiConverter { public String toJson(Resource resource) { JSONObject json = toJsonObject(resource); if (json != null) return json.toString(); return null; } JSONApiConverter(Class<? extends Resource>... classes);  JSONApiConverter(HashMap<String, Class<? extends Resource>> classesIndex); JSONApiConverter withDateFormat(SimpleDateFormat dateFormat); JSONApiConverter withDateFormat(String format); String toJson(Resource resource); String toJson(List<? extends Resource> resources); JSONApiObject<T> fromJson(String jsonObject);  }
@Test public void toJson_withResource_shouldSucceed() { String expectedResult = fileLoader.getContent("jsons/person.json"); Person p = new Person(); p.setId("id-01"); p.setName("Gustavo"); p.setFirstName("Gustavo"); p.setPseudo("faogustavo"); p.setCity("Santa Maria - RS, Brazil"); p.setEmail("faogustavo@gmail.com"); String result = subject.toJson(p); assertEquals(expectedResult, result); }