### Question:
FindTaskByIdAPIController { @RequestMapping(value = "/byId/{taskId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @DecoratedAssignedObjectParticipants @ResponseBody public AcmTask findTaskById( @PathVariable("taskId") Long taskId, Authentication authentication, HttpSession session) throws AcmObjectNotFoundException { log.info("Finding task with id:'{}'", taskId); AcmTask task = getTaskService().retrieveTask(taskId); if (task != null) { raiseEvent(authentication, session, task, true); return task; } log.error("Could not find task with id:'{}'", taskId); raiseFakeEvent(taskId, authentication, session); throw new AcmObjectNotFoundException("task", taskId, null); }  @RequestMapping(value = "/byId/{taskId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @DecoratedAssignedObjectParticipants @ResponseBody AcmTask findTaskById(
            @PathVariable("taskId") Long taskId,
            Authentication authentication,
            HttpSession session); TaskEventPublisher getTaskEventPublisher(); void setTaskEventPublisher(TaskEventPublisher taskEventPublisher); AcmTaskService getTaskService(); void setTaskService(AcmTaskService taskService);  }### Answer:
@Test public void findTaskById() throws Exception { String ipAddress = "ipAddress"; String title = "The Test Title"; Long taskId = 500L; Long docUnderReviewId = 250L; AcmTask returned = new AcmTask(); returned.setTaskId(taskId); returned.setTitle(title); returned.setReviewDocumentPdfRenditionId(docUnderReviewId); returned.setChildObjects(new ArrayList<>()); returned.setDocumentUnderReview(new EcmFile()); mockHttpSession.setAttribute("acm_ip_address", ipAddress); expect(mockTaskService.retrieveTask(taskId)).andReturn(returned); Capture<AcmApplicationTaskEvent> eventRaised = Capture.newInstance(); mockTaskEventPublisher.publishTaskEvent(capture(eventRaised)); expect(mockAuthentication.getName()).andReturn("user").atLeastOnce(); replayAll(); MvcResult result = mockMvc.perform( get("/api/v1/plugin/task/byId/{taskId}", taskId) .accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .session(mockHttpSession) .principal(mockAuthentication)) .andReturn(); verifyAll(); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); assertTrue(result.getResponse().getContentType().startsWith(MediaType.APPLICATION_JSON_VALUE)); String json = result.getResponse().getContentAsString(); log.info("results: {}", json); AcmTask fromJson = new ObjectMapper().readValue(json, AcmTask.class); assertNotNull(fromJson); assertEquals(returned.getTitle(), fromJson.getTitle()); AcmApplicationTaskEvent event = eventRaised.getValue(); assertTrue(event.isSucceeded()); assertEquals(taskId, event.getObjectId()); assertTrue(fromJson.getChildObjects().isEmpty()); assertNotNull(fromJson.getDocumentUnderReview()); }