@Test public void testSplitCaseFiles() throws Exception { expect(mockAuthentication.getName()).andReturn("user").times(2); SplitCaseOptions options = new SplitCaseOptions(); options.setCaseFileId(1l); Capture<SplitCaseOptions> capture = new Capture<>(); EasyMock.expect(splitCaseService.splitCase(eq(mockAuthentication), eq("127.0.0.1"), EasyMock.capture(capture))) .andAnswer(new IAnswer<CaseFile>() { @Override public CaseFile answer() throws Throwable { CaseFile caseFile = new CaseFile(); caseFile.setId(capture.getValue().getCaseFileId()); return caseFile; } }); session.setAttribute("acm_ip_address", "127.0.0.1"); replayAll(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String content = objectMapper.writeValueAsString(options); MvcResult result = mockMvc.perform( post("/api/latest/plugin/copyCaseFile") .session(session) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) .principal(mockAuthentication) .content(content)) .andExpect(status().isOk()) .andReturn(); CaseFile item = objectMapper.readValue(result.getResponse().getContentAsString(), CaseFile.class); assertEquals(item.getId().longValue(), options.getCaseFileId().longValue()); }
@RequestMapping(method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody public CaseFile splitCaseFiles( @RequestBody SplitCaseOptions splitCaseOptions, HttpSession session, Authentication auth) throws MuleException, AcmCreateObjectFailedException, AcmUserActionFailedException, SplitCaseFileException, AcmFolderException, AcmObjectNotFoundException, PipelineProcessException { Objects.requireNonNull(splitCaseOptions.getCaseFileId(), "Case file for splitting should not be null"); String ipAddress = (String) session.getAttribute("acm_ip_address"); CaseFile copyCaseFile = splitCaseService.splitCase(auth, ipAddress, splitCaseOptions); return copyCaseFile; }
SplitCaseFilesAPIController { @RequestMapping(method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody public CaseFile splitCaseFiles( @RequestBody SplitCaseOptions splitCaseOptions, HttpSession session, Authentication auth) throws MuleException, AcmCreateObjectFailedException, AcmUserActionFailedException, SplitCaseFileException, AcmFolderException, AcmObjectNotFoundException, PipelineProcessException { Objects.requireNonNull(splitCaseOptions.getCaseFileId(), "Case file for splitting should not be null"); String ipAddress = (String) session.getAttribute("acm_ip_address"); CaseFile copyCaseFile = splitCaseService.splitCase(auth, ipAddress, splitCaseOptions); return copyCaseFile; } }
SplitCaseFilesAPIController { @RequestMapping(method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody public CaseFile splitCaseFiles( @RequestBody SplitCaseOptions splitCaseOptions, HttpSession session, Authentication auth) throws MuleException, AcmCreateObjectFailedException, AcmUserActionFailedException, SplitCaseFileException, AcmFolderException, AcmObjectNotFoundException, PipelineProcessException { Objects.requireNonNull(splitCaseOptions.getCaseFileId(), "Case file for splitting should not be null"); String ipAddress = (String) session.getAttribute("acm_ip_address"); CaseFile copyCaseFile = splitCaseService.splitCase(auth, ipAddress, splitCaseOptions); return copyCaseFile; }  }
SplitCaseFilesAPIController { @RequestMapping(method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody public CaseFile splitCaseFiles( @RequestBody SplitCaseOptions splitCaseOptions, HttpSession session, Authentication auth) throws MuleException, AcmCreateObjectFailedException, AcmUserActionFailedException, SplitCaseFileException, AcmFolderException, AcmObjectNotFoundException, PipelineProcessException { Objects.requireNonNull(splitCaseOptions.getCaseFileId(), "Case file for splitting should not be null"); String ipAddress = (String) session.getAttribute("acm_ip_address"); CaseFile copyCaseFile = splitCaseService.splitCase(auth, ipAddress, splitCaseOptions); return copyCaseFile; }  @RequestMapping(method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody CaseFile splitCaseFiles(
            @RequestBody SplitCaseOptions splitCaseOptions,
            HttpSession session,
            Authentication auth); void setSplitCaseService(SplitCaseService splitCaseService); }
SplitCaseFilesAPIController { @RequestMapping(method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody public CaseFile splitCaseFiles( @RequestBody SplitCaseOptions splitCaseOptions, HttpSession session, Authentication auth) throws MuleException, AcmCreateObjectFailedException, AcmUserActionFailedException, SplitCaseFileException, AcmFolderException, AcmObjectNotFoundException, PipelineProcessException { Objects.requireNonNull(splitCaseOptions.getCaseFileId(), "Case file for splitting should not be null"); String ipAddress = (String) session.getAttribute("acm_ip_address"); CaseFile copyCaseFile = splitCaseService.splitCase(auth, ipAddress, splitCaseOptions); return copyCaseFile; }  @RequestMapping(method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE }) @ResponseBody CaseFile splitCaseFiles(
            @RequestBody SplitCaseOptions splitCaseOptions,
            HttpSession session,
            Authentication auth); void setSplitCaseService(SplitCaseService splitCaseService);  }