Search in sources :

Example 6 with Comment

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>\""));
}
Also used : Comment(org.alfresco.rest.api.model.Comment) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) ReturnAllBeanProperties(org.alfresco.rest.framework.jacksonextensions.JacksonHelper.ReturnAllBeanProperties) Writer(org.alfresco.rest.framework.jacksonextensions.JacksonHelper.Writer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FilterProvider(com.fasterxml.jackson.databind.ser.FilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) Test(org.junit.Test)

Example 7 with Comment

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());
}
Also used : Comment(org.alfresco.rest.api.model.Comment) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) ReturnAllBeanProperties(org.alfresco.rest.framework.jacksonextensions.JacksonHelper.ReturnAllBeanProperties) Writer(org.alfresco.rest.framework.jacksonextensions.JacksonHelper.Writer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FilterProvider(com.fasterxml.jackson.databind.ser.FilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) Test(org.junit.Test)

Aggregations

Comment (org.alfresco.rest.api.model.Comment)7 Test (org.junit.Test)5 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)3 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)3 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 FilterProvider (com.fasterxml.jackson.databind.ser.FilterProvider)3 SimpleFilterProvider (com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 ReturnAllBeanProperties (org.alfresco.rest.framework.jacksonextensions.JacksonHelper.ReturnAllBeanProperties)3 Writer (org.alfresco.rest.framework.jacksonextensions.JacksonHelper.Writer)3 QName (org.alfresco.service.namespace.QName)2 Serializable (java.io.Serializable)1 StringReader (java.io.StringReader)1 AbstractList (java.util.AbstractList)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 PagingRequest (org.alfresco.query.PagingRequest)1 Person (org.alfresco.rest.api.model.Person)1