@SuppressWarnings("unchecked") @Test public void getsBodyAsCustomType() throws Exception { Class<List> type = List.class; ParameterizedType genericType = newParameterizedType(List.class, String.class); Annotation[] annotations = new Annotation[0]; InputStream in = mock(InputStream.class); when(fileItem.getInputStream()).thenReturn(in); when(fileItem.getContentType()).thenReturn(TEXT_PLAIN_TYPE.toString()); MessageBodyReader reader = mock(MessageBodyReader.class); ArrayList<String> bodyAsList = newArrayList("to", "be", "or", "not", "to", "be"); when(reader.readFrom(eq(type), eq(genericType), aryEq(annotations), eq(TEXT_PLAIN_TYPE), any(), eq(in))).thenReturn(bodyAsList); when(providers.getMessageBodyReader(eq(type), eq(genericType), aryEq(annotations), eq(TEXT_PLAIN_TYPE))).thenReturn(reader); assertEquals(bodyAsList, inputItem.getBody(type, genericType)); }
@Override public InputStream getBody() throws IOException { return fileItem.getInputStream(); }
DefaultInputItem implements InputItem { @Override public InputStream getBody() throws IOException { return fileItem.getInputStream(); } }
DefaultInputItem implements InputItem { @Override public InputStream getBody() throws IOException { return fileItem.getInputStream(); } DefaultInputItem(FileItem fileItem, Providers providers); }
DefaultInputItem implements InputItem { @Override public InputStream getBody() throws IOException { return fileItem.getInputStream(); } DefaultInputItem(FileItem fileItem, Providers providers); @Override String getName(); @Override String getFilename(); @Override MediaType getMediaType(); @Override MultivaluedMap<String, String> getHeaders(); @Override InputStream getBody(); @Override T getBody(Class<T> type, Type genericType); @Override String getBodyAsString(); }
DefaultInputItem implements InputItem { @Override public InputStream getBody() throws IOException { return fileItem.getInputStream(); } DefaultInputItem(FileItem fileItem, Providers providers); @Override String getName(); @Override String getFilename(); @Override MediaType getMediaType(); @Override MultivaluedMap<String, String> getHeaders(); @Override InputStream getBody(); @Override T getBody(Class<T> type, Type genericType); @Override String getBodyAsString();  }