@Test public void reviewDocuments() throws Exception { String businessProcessName = "acmDocumentWorkflow"; String attachedToObjectType = "COMPLAINT"; String attachedToObjectName = "20140827_202"; Long attachedToObjectId = 202L; Long taskId = 500L; String ipAddress = "ipAddress"; ArrayList<EcmFile> documentsToReview = new ArrayList<>(); AcmTask reviewTask = new AcmTask(); reviewTask.setAssignee("assignee"); reviewTask.setAttachedToObjectType(attachedToObjectType); reviewTask.setTaskStartDate(new Date()); reviewTask.setTitle("title"); reviewTask.setStatus("ASSIGNED"); reviewTask.setAttachedToObjectName(attachedToObjectName); reviewTask.setAttachedToObjectId(attachedToObjectId); reviewTask.setDocumentsToReview(documentsToReview); reviewTask.setDueDate(new Date()); reviewTask.setPercentComplete(0); AcmTask createdAcmTask = new AcmTask(); createdAcmTask.setAssignee(reviewTask.getAssignee()); createdAcmTask.setTaskId(taskId); List<AcmTask> createdAcmTasks = new ArrayList<>(); createdAcmTasks.add(createdAcmTask); ObjectMapper objectMapper = new ObjectMapper(); String inJson = objectMapper.writeValueAsString(reviewTask); mockHttpSession.setAttribute("acm_ip_address", ipAddress); Capture<AcmTask> capturedAcmTask = EasyMock.newCapture(); expect(mockAuthentication.getName()).andReturn("user").atLeastOnce(); expect(mockTaskService.startReviewDocumentsWorkflow(capture(capturedAcmTask), EasyMock.eq(businessProcessName), EasyMock.eq(mockAuthentication))).andReturn(createdAcmTasks); replayAll(); MvcResult result = mockMvc .perform(post("/api/v1/plugin/tasks/documents/review?businessProcessName=acmDocumentWorkflow") .accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .session(mockHttpSession) .principal(mockAuthentication) .contentType(MediaType.APPLICATION_JSON) .content(inJson)) .andReturn(); verifyAll(); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); assertTrue(result.getResponse().getContentType().startsWith(MediaType.APPLICATION_JSON_VALUE)); }
@RequestMapping(value = "/documents/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<AcmTask> reviewDocuments(@RequestBody AcmTask in, @RequestParam(value = "businessProcessName", defaultValue = "acmDocumentWorkflow") String businessProcessName, Authentication authentication, HttpSession httpSession) throws AcmCreateObjectFailedException { try { List<AcmTask> acmTasks = getTaskService().startReviewDocumentsWorkflow(in, businessProcessName, authentication); return acmTasks; } catch (AcmTaskException e) { AcmTask fakeTask = new AcmTask(); fakeTask.setTaskId(-1L); publishTaskCreatedEvent(authentication, httpSession, fakeTask, false); throw new AcmCreateObjectFailedException("task", e.getMessage(), e); } }
CreateBusinessProcessTasksAPIController { @RequestMapping(value = "/documents/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<AcmTask> reviewDocuments(@RequestBody AcmTask in, @RequestParam(value = "businessProcessName", defaultValue = "acmDocumentWorkflow") String businessProcessName, Authentication authentication, HttpSession httpSession) throws AcmCreateObjectFailedException { try { List<AcmTask> acmTasks = getTaskService().startReviewDocumentsWorkflow(in, businessProcessName, authentication); return acmTasks; } catch (AcmTaskException e) { AcmTask fakeTask = new AcmTask(); fakeTask.setTaskId(-1L); publishTaskCreatedEvent(authentication, httpSession, fakeTask, false); throw new AcmCreateObjectFailedException("task", e.getMessage(), e); } } }
CreateBusinessProcessTasksAPIController { @RequestMapping(value = "/documents/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<AcmTask> reviewDocuments(@RequestBody AcmTask in, @RequestParam(value = "businessProcessName", defaultValue = "acmDocumentWorkflow") String businessProcessName, Authentication authentication, HttpSession httpSession) throws AcmCreateObjectFailedException { try { List<AcmTask> acmTasks = getTaskService().startReviewDocumentsWorkflow(in, businessProcessName, authentication); return acmTasks; } catch (AcmTaskException e) { AcmTask fakeTask = new AcmTask(); fakeTask.setTaskId(-1L); publishTaskCreatedEvent(authentication, httpSession, fakeTask, false); throw new AcmCreateObjectFailedException("task", e.getMessage(), e); } }  }
CreateBusinessProcessTasksAPIController { @RequestMapping(value = "/documents/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<AcmTask> reviewDocuments(@RequestBody AcmTask in, @RequestParam(value = "businessProcessName", defaultValue = "acmDocumentWorkflow") String businessProcessName, Authentication authentication, HttpSession httpSession) throws AcmCreateObjectFailedException { try { List<AcmTask> acmTasks = getTaskService().startReviewDocumentsWorkflow(in, businessProcessName, authentication); return acmTasks; } catch (AcmTaskException e) { AcmTask fakeTask = new AcmTask(); fakeTask.setTaskId(-1L); publishTaskCreatedEvent(authentication, httpSession, fakeTask, false); throw new AcmCreateObjectFailedException("task", e.getMessage(), e); } }  @RequestMapping(value = "/documents/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<AcmTask> reviewDocuments(@RequestBody AcmTask in,
            @RequestParam(value = "businessProcessName", defaultValue = "acmDocumentWorkflow") String businessProcessName,
            Authentication authentication, HttpSession httpSession); @RequestMapping(value = "/newdocuments/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @ResponseBody List<AcmTask> reviewNewDocuments(@RequestPart (name = "task")AcmTask task,
                                         @RequestParam(name = "businessProcessName") String businessProcessType,
                                         @RequestPart(name = "files") List<MultipartFile> filesToUpload,
                                         Authentication authentication, HttpSession httpSession); TaskEventPublisher getTaskEventPublisher(); void setTaskEventPublisher(TaskEventPublisher taskEventPublisher); AcmTaskService getTaskService(); void setTaskService(AcmTaskService taskService); }
CreateBusinessProcessTasksAPIController { @RequestMapping(value = "/documents/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List<AcmTask> reviewDocuments(@RequestBody AcmTask in, @RequestParam(value = "businessProcessName", defaultValue = "acmDocumentWorkflow") String businessProcessName, Authentication authentication, HttpSession httpSession) throws AcmCreateObjectFailedException { try { List<AcmTask> acmTasks = getTaskService().startReviewDocumentsWorkflow(in, businessProcessName, authentication); return acmTasks; } catch (AcmTaskException e) { AcmTask fakeTask = new AcmTask(); fakeTask.setTaskId(-1L); publishTaskCreatedEvent(authentication, httpSession, fakeTask, false); throw new AcmCreateObjectFailedException("task", e.getMessage(), e); } }  @RequestMapping(value = "/documents/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody List<AcmTask> reviewDocuments(@RequestBody AcmTask in,
            @RequestParam(value = "businessProcessName", defaultValue = "acmDocumentWorkflow") String businessProcessName,
            Authentication authentication, HttpSession httpSession); @RequestMapping(value = "/newdocuments/review", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @ResponseBody List<AcmTask> reviewNewDocuments(@RequestPart (name = "task")AcmTask task,
                                         @RequestParam(name = "businessProcessName") String businessProcessType,
                                         @RequestPart(name = "files") List<MultipartFile> filesToUpload,
                                         Authentication authentication, HttpSession httpSession); TaskEventPublisher getTaskEventPublisher(); void setTaskEventPublisher(TaskEventPublisher taskEventPublisher); AcmTaskService getTaskService(); void setTaskService(AcmTaskService taskService);  }