@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 testJsonApiMarshalWrongType() {
        Class<?>[] formats = { MyBook.class, MyAuthor.class };
        JsonApiDataFormat jsonApiDataFormat = new JsonApiDataFormat(formats);

        Exchange exchange = new DefaultExchange(context);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        assertThrows(DocumentSerializationException.class,
                () -> jsonApiDataFormat.marshal(exchange, new MyFooBar("bar"), baos));
    }