@Test public void listFileInfos() { FileInfo file1 = new FileInfo(); FileInfo file2 = new FileInfo(); List<FileInfo> mockedFileInfos = new ArrayList<FileInfo>(); mockedFileInfos.add(file1); mockedFileInfos.add(file2); when(fileServiceMock.listFiles()).thenReturn(mockedFileInfos); List<FileInfo> responseFileInfos = resource().path("/api/files") .accept(MediaType.APPLICATION_JSON).get(new GenericType<List<FileInfo>>(){}); assertEquals("Response uploads should be equal to the mocked uploads", mockedFileInfos, responseFileInfos); verify(fileServiceMock).listFiles(); }
@GET @Produces(MediaType.APPLICATION_JSON) public Collection<FileInfo> listFiles() { return fileService.listFiles(); }
FileResource { @GET @Produces(MediaType.APPLICATION_JSON) public Collection<FileInfo> listFiles() { return fileService.listFiles(); } }
FileResource { @GET @Produces(MediaType.APPLICATION_JSON) public Collection<FileInfo> listFiles() { return fileService.listFiles(); } @Inject  FileResource(FileService fileService); }
FileResource { @GET @Produces(MediaType.APPLICATION_JSON) public Collection<FileInfo> listFiles() { return fileService.listFiles(); } @Inject  FileResource(FileService fileService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<FileInfo> listFiles(); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) FileInfo createFile(@FormDataParam("file") byte[] fileContent,
            @FormDataParam("file") FormDataContentDisposition fileDetail,
            @HeaderParam("Content-type") String contentType); @GET @Path("/{fileId}") @Produces(MediaType.APPLICATION_JSON) FileInfo getFile(@PathParam("fileId") String fileId); @PUT @Path("/{fileId}") @Consumes(MediaType.APPLICATION_JSON) Response updateFile(@PathParam("fileId") String fileId, FileInfo fileInfo); @DELETE @Path("/{fileId}") Response deleteFile(@PathParam("fileId") String fileId); @GET @Path("/{fileId}/content") Response getFileContent(@PathParam("fileId") String fileId); @POST @Path("/{fileId}/content") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) FileInfo updateFileContent(@PathParam("fileId") String fileId,
            @FormDataParam("file") byte[] fileContent,
            @FormDataParam("file") FormDataContentDisposition fileDetail,
            @HeaderParam("Content-type") String contentType); }
FileResource { @GET @Produces(MediaType.APPLICATION_JSON) public Collection<FileInfo> listFiles() { return fileService.listFiles(); } @Inject  FileResource(FileService fileService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<FileInfo> listFiles(); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) FileInfo createFile(@FormDataParam("file") byte[] fileContent,
            @FormDataParam("file") FormDataContentDisposition fileDetail,
            @HeaderParam("Content-type") String contentType); @GET @Path("/{fileId}") @Produces(MediaType.APPLICATION_JSON) FileInfo getFile(@PathParam("fileId") String fileId); @PUT @Path("/{fileId}") @Consumes(MediaType.APPLICATION_JSON) Response updateFile(@PathParam("fileId") String fileId, FileInfo fileInfo); @DELETE @Path("/{fileId}") Response deleteFile(@PathParam("fileId") String fileId); @GET @Path("/{fileId}/content") Response getFileContent(@PathParam("fileId") String fileId); @POST @Path("/{fileId}/content") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) FileInfo updateFileContent(@PathParam("fileId") String fileId,
            @FormDataParam("file") byte[] fileContent,
            @FormDataParam("file") FormDataContentDisposition fileDetail,
            @HeaderParam("Content-type") String contentType);  }