### Question:
FindComplaintByIdAPIController { @RequestMapping(value = "/byId/{complaintId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @DecoratedAssignedObjectParticipants @ResponseBody public Complaint findComplaintById( @PathVariable("complaintId") Long complaintId, Authentication authentication, HttpSession session, HttpServletResponse response) throws AcmObjectNotFoundException, AcmUserActionFailedException { if (log.isInfoEnabled()) { log.info("Finding complaint by id '" + complaintId + "'"); } try { Complaint found = getComplaintDao().find(complaintId); if (found == null) { throw new AcmObjectNotFoundException("complaint", complaintId, "Object Not Found", null); } raiseEvent(authentication, session, found, true); return found; } catch (PersistenceException | TransactionException e) { Complaint fakeComplaint = new Complaint(); fakeComplaint.setComplaintId(complaintId); raiseEvent(authentication, session, fakeComplaint, false); throw new AcmUserActionFailedException("find", "complaint", complaintId, e.getMessage(), e); } }  @RequestMapping(value = "/byId/{complaintId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @DecoratedAssignedObjectParticipants @ResponseBody Complaint findComplaintById(
            @PathVariable("complaintId") Long complaintId,
            Authentication authentication,
            HttpSession session,
            HttpServletResponse response); ComplaintDao getComplaintDao(); void setComplaintDao(ComplaintDao complaintDao); ComplaintEventPublisher getEventPublisher(); void setEventPublisher(ComplaintEventPublisher eventPublisher);  }### Answer:
@Test public void findComplaintById() throws Exception { String ipAddress = "ipAddress"; String title = "The Test Title"; Long complaintId = 500L; Complaint returned = new Complaint(); returned.setComplaintId(complaintId); returned.setComplaintTitle(title); mockHttpSession.setAttribute("acm_ip_address", ipAddress); expect(mockComplaintDao.find(complaintId)).andReturn(returned); mockComplaintEventPublisher.publishFindComplaintByIdEvent( eq(returned), eq(mockAuthentication), eq(ipAddress), eq(true)); expect(mockAuthentication.getName()).andReturn("user"); replayAll(); MvcResult result = mockMvc.perform( get("/api/v1/plugin/complaint/byId/{complaintId}", complaintId) .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); Complaint fromJson = new ObjectMapper().readValue(json, Complaint.class); assertNotNull(fromJson); assertEquals(returned.getComplaintTitle(), fromJson.getComplaintTitle()); }