### Question:
EntityUtils { @SuppressWarnings("unchecked") public static <T> T readEntity( final Class<T> entityClass, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MinijaxRequestContext context, final InputStream entityStream) throws IOException { if (entityClass == InputStream.class) { return (T) entityStream; } if (entityClass == String.class) { return (T) IOUtils.toString(entityStream, StandardCharsets.UTF_8); } if (context != null) { final MinijaxApplicationContext appCtx = context.getApplicationContext(); final MessageBodyReader<T> reader = appCtx.getProviders().getMessageBodyReader( entityClass, genericType, annotations, mediaType); if (reader != null) { return reader.readFrom( entityClass, genericType, annotations, mediaType, context.getHeaders(), entityStream); } } throw new MinijaxException("Unknown entity type (" + entityClass + ")"); } EntityUtils(); @SuppressWarnings("unchecked") static T readEntity(
            final Class<T> entityClass,
            final Type genericType,
            final Annotation[] annotations,
            final MediaType mediaType,
            final MinijaxRequestContext context,
            final InputStream entityStream); @SuppressWarnings({ "rawtypes", "unchecked" }) static void writeEntity(
            final Object entity,
            final MediaType mediaType,
            final MinijaxApplicationContext context,
            final OutputStream outputStream); static InputStream writeEntity(
            final Entity<T> entity,
            final MinijaxApplicationContext context);  }### Answer:
@Test(expected = MinijaxException.class) public void testReadUnknownType() throws IOException { final InputStream input = new ByteArrayInputStream("hello".getBytes()); EntityUtils.readEntity(Minijax.class, null, null, null, null, input); }
@Test public void testReadInputStream() throws IOException { final InputStream input = new ByteArrayInputStream(new byte[1]); final InputStream result = EntityUtils.readEntity(InputStream.class, null, null, null, null, input); assertEquals(input, result); }
@Test public void testReadCustomType() throws IOException { final InputStream input = new ByteArrayInputStream(new byte[1]); final InputStream result = EntityUtils.readEntity(InputStream.class, null, null, null, null, input); assertEquals(input, result); }
@Test public void testReadString() throws IOException { final InputStream input = new ByteArrayInputStream("hello".getBytes()); final String result = EntityUtils.readEntity(String.class, null, null, null, null, input); assertEquals("hello", result); }