@Override
    public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
        ResourceConverter converter = new ResourceConverter(dataFormatTypeClasses);
        byte[] objectAsBytes = converter.writeDocument(new JSONAPIDocument<>(graph));
        stream.write(objectAsBytes);
    }
@Test
    public void testJsonApiMarshal() throws Exception {
        Class<?>[] formats = { MyBook.class, MyAuthor.class };
        JsonApiDataFormat jsonApiDataFormat = new JsonApiDataFormat(formats);

        MyBook book = this.generateTestDataAsObject();

        Exchange exchange = new DefaultExchange(context);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        jsonApiDataFormat.marshal(exchange, book, baos);

        String jsonApiOutput = baos.toString();
        assertNotNull(jsonApiOutput);
        assertEquals(this.generateTestDataAsString(), jsonApiOutput);
    }