### Question:
ClaimTaskAPIController { @RequestMapping(value = "/unclaim/{taskId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public AcmTask unclaimTask( @PathVariable("taskId") Long taskId, Authentication authentication, HttpSession httpSession) throws AcmUserActionFailedException { log.info("User [{}] is unclaiming workflow task with ID [{}]", authentication.getName(), taskId); try { getTaskDao().unclaimTask(taskId); AcmTask unclaimedTask = getTaskDao().findById(taskId); publishTaskClaimEvent(authentication, httpSession, unclaimedTask, "unclaim", true); return getTaskDao().save(unclaimedTask); } catch (AcmTaskException e) { AcmTask fakeTask = new AcmTask(); fakeTask.setTaskId(taskId); publishTaskClaimEvent(authentication, httpSession, fakeTask, "unclaim", false); throw new AcmUserActionFailedException("unclaim", "task", taskId, e.getMessage(), e); } }  @RequestMapping(value = "/claim/{taskId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody AcmTask claimTask(
            @PathVariable("taskId") Long taskId,
            Authentication authentication,
            HttpSession httpSession); @RequestMapping(value = "/unclaim/{taskId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody AcmTask unclaimTask(
            @PathVariable("taskId") Long taskId,
            Authentication authentication,
            HttpSession httpSession); TaskDao getTaskDao(); void setTaskDao(TaskDao taskDao); TaskEventPublisher getTaskEventPublisher(); void setTaskEventPublisher(TaskEventPublisher taskEventPublisher);  }### Answer:
@Test public void unclaimTask() throws Exception { Long taskId = 500L; String userId = "user"; AcmTask testTask = new AcmTask(); testTask.setTaskId(taskId); Capture<AcmApplicationTaskEvent> capturedEvent = new Capture<>(); mockTaskDao.unclaimTask(eq(taskId)); expect(mockTaskDao.findById(taskId)).andReturn(testTask); mockTaskEventPublisher.publishTaskEvent(capture(capturedEvent)); expect(mockAuthentication.getName()).andReturn(userId).atLeastOnce(); expect(mockTaskDao.save(testTask)).andReturn(testTask); replayAll(); MvcResult result = mockMvc.perform( post("/api/v1/plugin/task/unclaim/{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 returned = result.getResponse().getContentAsString(); log.info("results: " + returned); ObjectMapper objectMapper = new ObjectMapper(); AcmTask unclaimedTask = objectMapper.readValue(returned, AcmTask.class); assertNotNull(unclaimedTask); assertEquals(unclaimedTask.getTaskId(), taskId); AcmApplicationTaskEvent event = capturedEvent.getValue(); assertEquals(taskId, event.getObjectId()); assertEquals("TASK", event.getObjectType()); assertTrue(event.isSucceeded()); }