NoFileEntityProvider extends FileEntityProvider { @Override public void writeTo(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { throw new WebApplicationException(Response.status(BAD_REQUEST).entity( "File is not supported as method's parameter.").type(TEXT_PLAIN).build()); }  @Override long getSize(File file, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override File readFrom(Class<File> type,
                         Type genericType,
                         Annotation[] annotations,
                         MediaType mediaType,
                         MultivaluedMap<String, String> httpHeaders,
                         InputStream entityStream); @Override void writeTo(File file,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream);  }
@Test public void writesFileToOutputStream() throws Exception { thrown.expect(webApplicationExceptionBadRequestMatcher()); noFileEntityProvider.writeTo(null, null, null, null, null, null, null); }