@Override
    public T readFrom(
            Class<T> cls, Type type, Annotation[] anns, MediaType mt,
            MultivaluedMap<String, String> headers, InputStream is)
            throws IOException,
            WebApplicationException {
        DataFormat format = getValidDataFormat(mt);
        try {
            @SuppressWarnings("unchecked")
            T result = (T) format.unmarshal(null, is);
            return result;
        } catch (Exception ex) {
            throw new BadRequestException(ex);
        }
    }
@Test
    public void testReadFrom() throws Exception {
        DataFormatProvider<Book> p = new DataFormatProvider<>();
        p.setFormat("text/plain", new TestDataFormat());

        ByteArrayInputStream bis = new ByteArrayInputStream("dataformat".getBytes());
        Book b = p.readFrom(Book.class, Book.class, new Annotation[] {}, MediaType.TEXT_PLAIN_TYPE,
                new MetadataMap<String, String>(), bis);
        assertEquals("dataformat", b.getName());
    }