0

I'm built REST services using JAXRS. I'd like to test how JAXRS implementation serializes the body content of each request, and be able to provide some test examples in order to check the body content is serialized correctly.

For example:

public void createOrUpdate(FollowUpActivityDTO dto) throws RepositorySystemException
{

}

I'm using jackson provider in order to do that:

compile group: 'com.fasterxml.jackson.jaxrs',
        name: 'jackson-jaxrs-json-provider',
        version: '2.5.3'

I'd like to provide some json examples, and see what's the serialzed result, so which the content of dto parameter.

Any ideas? I've took a look on Rest-Assured, but I don't whether it's exactly for checking my affair.

Example

public class FollowUpActivityDTOSerializationTest
{

  private ObjectMapper mapper;

  @Before
  public void initialize()
  {
    this.mapper = new ObjectMapper();
  }

  @Test
  public void emptyJSON()
  { 
    String emptyJSON = "{\"id\": \"id\"}";

    try {
      FollowUpActivityDTO dto = this.mapper.readValue(emptyJSON, FollowUpActivityDTO.class);
      assertNotNull(dto);
      assertEquals(dto.getId(), "id");
    } catch (IOException e) {
      fail(e.getMessage());
    }
  }

}

It works now, However, how I know what's the configuration of the internal jackson-provider. By now, my configuration is a single sentence like: this.mapper = new ObjectMapper();. However, I don't know how jackson-provider initializes its internal ObjectMapper?

Jordi
  • 20,868
  • 39
  • 149
  • 333

0 Answers0