use of org.alfresco.rest.api.model.Comment in project alfresco-remote-api by Alfresco.
the class JsonJacksonTests method testSerializeComment.
@Test
public void testSerializeComment() throws IOException {
final Comment aComment = new Comment();
aComment.setContent("<b>There it is</b>");
ByteArrayOutputStream out = new ByteArrayOutputStream();
jsonHelper.withWriter(out, new Writer() {
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper) throws JsonGenerationException, JsonMappingException, IOException {
FilterProvider fp = new SimpleFilterProvider().addFilter(JacksonHelper.DEFAULT_FILTER_NAME, new ReturnAllBeanProperties());
objectMapper.writer(fp).writeValue(generator, aComment);
}
});
assertTrue(out.toString().contains("{\"content\":\"<b>There it is</b>\""));
}
use of org.alfresco.rest.api.model.Comment in project alfresco-remote-api by Alfresco.
the class JsonJacksonTests method testNullInComment.
@Test
public void testNullInComment() throws IOException {
final Comment aComment = new Comment();
aComment.setContent(null);
ByteArrayOutputStream out = new ByteArrayOutputStream();
jsonHelper.withWriter(out, new Writer() {
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper) throws JsonGenerationException, JsonMappingException, IOException {
FilterProvider fp = new SimpleFilterProvider().addFilter(JacksonHelper.DEFAULT_FILTER_NAME, new ReturnAllBeanProperties());
objectMapper.writer(fp).writeValue(generator, aComment);
}
});
assertEquals("Null values should not be output.", "{\"canEdit\":false,\"canDelete\":false}", out.toString());
}
Aggregations