use of org.alfresco.rest.framework.jacksonextensions.JacksonHelper.ReturnAllBeanProperties in project alfresco-remote-api by Alfresco.
the class JsonJacksonTests method testSerializeMultipleObjects.
@Test
public void testSerializeMultipleObjects() throws IOException {
final Collection<Comment> allComments = new ArrayList<Comment>();
Comment aComment = new Comment();
aComment.setContent("<b>There it is</b>");
allComments.add(aComment);
aComment = new Comment();
aComment.setContent("<p>I agree with the author</p>");
allComments.add(aComment);
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, allComments);
}
});
assertTrue(out.toString().contains("content\":\"<b>There it is</b>"));
assertTrue(out.toString().contains("content\":\"<p>I agree with the author</p>"));
}
use of org.alfresco.rest.framework.jacksonextensions.JacksonHelper.ReturnAllBeanProperties 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.framework.jacksonextensions.JacksonHelper.ReturnAllBeanProperties 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