SnapshotController { @RequestMapping(value = "/spaces/snapshot", method = RequestMethod.POST) @ResponseBody public String create(HttpServletRequest request, HttpServletResponse response, @RequestParam String spaceId, @RequestParam String storeId, @RequestParam String description) throws Exception { ContentStore store = getContentStore(storeId); response.setHeader("Content-Type", MediaType.APPLICATION_JSON); if (isSnapshotInProgress(store, spaceId)) { response.setStatus(HttpStatus.SC_METHOD_FAILURE); return "{\"result\":\"Snapshot already in progress.\"}"; } else { String username = getUsername(request); String userEmail = getUserEmail(username); SnapshotTaskClient taskClient = getTaskClient(storeId); try { CreateSnapshotTaskResult result = taskClient.createSnapshot(spaceId, description, userEmail); response.setStatus(HttpStatus.SC_ACCEPTED); return result.serialize(); } catch (ContentStateException ex) { response.setStatus(HttpStatus.SC_CONFLICT); return ex.getMessage(); } } } @Autowired(required = true)  SnapshotController(@Qualifier("contentStoreManager") ContentStoreManager contentStoreManager,
                              @Qualifier("userDetailsSvc") DuracloudUserDetailsService userDetailsService,
                              SnapshotTaskClientManager snapshotTaskClientManager); @RequestMapping(value = "/spaces/snapshot", method = RequestMethod.POST) @ResponseBody String create(HttpServletRequest request,
                         HttpServletResponse response,
                         @RequestParam String spaceId,
                         @RequestParam String storeId,
                         @RequestParam String description); @RequestMapping(value = "/spaces/snapshot", method = RequestMethod.GET) ModelAndView get(@RequestParam String storeId,
                            @RequestParam String spaceId); @RequestMapping(value = "/spaces/snapshots/{storeId}", method = RequestMethod.GET) @ResponseBody String getSnapshotList(@PathVariable("storeId") String storeId); @RequestMapping(value = "/spaces/snapshots/{storeId}/{snapshotId:.+}", method = RequestMethod.GET) @ResponseBody String getSnapshot(@PathVariable("storeId") String storeId,
                              @PathVariable("snapshotId") String snapshotId); @RequestMapping(value = "/spaces/snapshots/{storeId}/{snapshotId}/history", method = RequestMethod.GET) ModelAndView getHistory(@PathVariable("storeId") String storeId,
                                   @PathVariable("snapshotId") String snapshotId,
                                   @RequestParam(value = "page", required = false) Integer page,
                                   @RequestParam(value = "attachment", required = false, defaultValue = "false")
                                       Boolean attachment,
                                   HttpServletResponse response); @RequestMapping(value = "/spaces/snapshots/{storeId}/{snapshotId}/content", method = RequestMethod.GET) ModelAndView getContent(@PathVariable("storeId") String storeId,
                                   @PathVariable("snapshotId") String snapshotId,
                                   @RequestParam(value = "page", required = false) Integer page,
                                   @RequestParam(value = "prefix", required = false) String prefix); @RequestMapping(value = "/spaces/snapshots/{storeId}/{snapshotId}/restore-space-id", method = RequestMethod.GET) @ResponseBody String restoreSpaceId(HttpServletRequest request,
                                 @PathVariable("storeId") String storeId,
                                 @PathVariable("snapshotId") String snapshotId); @RequestMapping(value = "/spaces/restores/{storeId}/by-snapshot/{snapshotId:.+}", method = RequestMethod.GET) @ResponseBody String getRestore(@PathVariable("storeId") String storeId,
                             @PathVariable("snapshotId") String snapshotId); @RequestMapping(value = "/spaces/restores/{storeId}/{restoreId:.+}", method = RequestMethod.GET) @ResponseBody String getRestoreByRestoreId(@PathVariable("storeId") String storeId,
                                        @PathVariable("restoreId") String restoreId); @RequestMapping(value = "/spaces/restores", method = RequestMethod.POST) @ResponseBody String restore(HttpServletRequest request,
                          @RequestParam String storeId,
                          @RequestParam String snapshotId); @RequestMapping(value = "/spaces/restores/request", method = RequestMethod.POST) @ResponseBody String requestRestore(HttpServletRequest request,
                                 @RequestParam String storeId,
                                 @RequestParam String snapshotId);  }
@Test public void testCreateSnapshot() throws Exception { String spaceId = "spaceId"; String description = "description"; setupGetContentStore(); setupGetTaskClient(storeId); EasyMock.expect(store.getSpaceProperties(EasyMock.isA(String.class))) .andReturn(new HashMap<String, String>()); EasyMock.expect(taskClient.createSnapshot(spaceId, description, userEmail)) .andReturn(new CreateSnapshotTaskResult()); response.setStatus(HttpStatus.SC_ACCEPTED); EasyMock.expectLastCall().once(); response.setHeader("Content-Type", "application/json"); setupUserDetails(); replayAll(); SnapshotController controller = createController(); Assert.assertNotNull(controller.create(request, response, "spaceId", storeId, "description")); }