@Test
public void writesFileToOutputStream() throws Exception {

    ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(testContent, TEXT_PLAIN);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    MultivaluedHashMap<String, Object> headers = new MultivaluedHashMap<>();
    dataSourceEntityProvider.writeTo(byteArrayDataSource, DataSource.class, null, null, null, headers, out);
    assertArrayEquals(testContent, out.toByteArray());
    assertEquals(TEXT_PLAIN, headers.getFirst(CONTENT_TYPE));
}