@Test public void testCompressFolder() throws Exception { long folderId = 101l; String fileName = "path/tocompressed_folder.zip"; expect(mockedFolderCompressor.compressFolder(folderId)).andReturn(fileName); replayAll(); MvcResult result = mockMvc.perform( get("/api/v1/service/compressor/{folderId}", folderId).accept(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andReturn(); verifyAll(); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); assertTrue(result.getResponse().getContentType().startsWith(MediaType.APPLICATION_JSON_VALUE)); String responseString = result.getResponse().getContentAsString(); log.info("results: " + responseString); ObjectMapper objectMapper = new ObjectMapper(); FolderCompressorResponse response = objectMapper.readValue(responseString, objectMapper.getTypeFactory().constructType(FolderCompressorResponse.class)); assertEquals(response.getFileName(), fileName); }
@RequestMapping(value = "/{folderId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody public FolderCompressorResponse compressFolder(@PathVariable(value = "folderId") long folderId) throws AcmFolderException { String fileName = folderCompressor.compressFolder(folderId); return new FolderCompressorResponse(fileName); }
FolderCompressorAPIController { @RequestMapping(value = "/{folderId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody public FolderCompressorResponse compressFolder(@PathVariable(value = "folderId") long folderId) throws AcmFolderException { String fileName = folderCompressor.compressFolder(folderId); return new FolderCompressorResponse(fileName); } }
FolderCompressorAPIController { @RequestMapping(value = "/{folderId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody public FolderCompressorResponse compressFolder(@PathVariable(value = "folderId") long folderId) throws AcmFolderException { String fileName = folderCompressor.compressFolder(folderId); return new FolderCompressorResponse(fileName); }  }
FolderCompressorAPIController { @RequestMapping(value = "/{folderId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody public FolderCompressorResponse compressFolder(@PathVariable(value = "folderId") long folderId) throws AcmFolderException { String fileName = folderCompressor.compressFolder(folderId); return new FolderCompressorResponse(fileName); }  @RequestMapping(value = "/{folderId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody FolderCompressorResponse compressFolder(@PathVariable(value = "folderId") long folderId); @RequestMapping(value = "/download/{folderId}", method = RequestMethod.GET) @ResponseBody void getCompressedFolder(@PathVariable(value = "folderId") long folderId, HttpServletResponse response); @RequestMapping(value = "/download", method = RequestMethod.POST) @ResponseBody void getCompressedSelectedFolderAndFiles(@RequestBody CompressNode compressNode, HttpServletResponse response); void downloadCompressedFolder(String filePath, String fileName, HttpServletResponse response); void setFolderCompressor(FolderCompressor folderCompressor); }
FolderCompressorAPIController { @RequestMapping(value = "/{folderId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody public FolderCompressorResponse compressFolder(@PathVariable(value = "folderId") long folderId) throws AcmFolderException { String fileName = folderCompressor.compressFolder(folderId); return new FolderCompressorResponse(fileName); }  @RequestMapping(value = "/{folderId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE }) @ResponseBody FolderCompressorResponse compressFolder(@PathVariable(value = "folderId") long folderId); @RequestMapping(value = "/download/{folderId}", method = RequestMethod.GET) @ResponseBody void getCompressedFolder(@PathVariable(value = "folderId") long folderId, HttpServletResponse response); @RequestMapping(value = "/download", method = RequestMethod.POST) @ResponseBody void getCompressedSelectedFolderAndFiles(@RequestBody CompressNode compressNode, HttpServletResponse response); void downloadCompressedFolder(String filePath, String fileName, HttpServletResponse response); void setFolderCompressor(FolderCompressor folderCompressor);  }