EnrolmentEnrolmentSubjectController extends BaseController implements CrudController<EnrolmentEnrolmentSubjectResource, EnrolmentEnrolmentSubjectResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{enrolmentId}/enrolmentsubjects/{id}", method = RequestMethod.GET) public EnrolmentEnrolmentSubjectResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving enrolment enrolment subject with id : {} ", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{enrolmentId}/enrolmentsubjects", method = RequestMethod.POST) EnrolmentEnrolmentSubjectResource createResource(@Valid @RequestBody final  EnrolmentEnrolmentSubjectResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{enrolmentId}/enrolmentsubjects/{id}", method = RequestMethod.PUT) MessageResource updateResource(@PathVariable("id") final Long id, 
		@Valid @RequestBody final EnrolmentEnrolmentSubjectResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{enrolmentId}/enrolmentsubjects/{id}", method = RequestMethod.GET) EnrolmentEnrolmentSubjectResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{enrolmentId}/enrolmentsubjects/{id}", method = RequestMethod.DELETE) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = { "/{enrolmentId}/enrolmentsubjects" }, method = RequestMethod.GET) PagedResultResource<EnrolmentEnrolmentSubjectResource> getPagedResource(final PagedRequest<EnrolmentEnrolmentSubjectResource> request);  }
@Test public void testGetPersonEnrolmentSubjects() throws Exception { Long enrolmentId = 2L; Long id = 5L; EnrolmentEnrolmentSubjectResource enrolmentEnrolmentSubjectResource = new EnrolmentEnrolmentSubjectResource(); enrolmentEnrolmentSubjectResource.setId(id); enrolmentEnrolmentSubjectResource.setEnrolmentId(enrolmentId); String response = getJson(enrolmentEnrolmentSubjectResource, false); when(facade.getResource(anyLong())).thenReturn( enrolmentEnrolmentSubjectResource); mockMvc.perform( get("/enrolments/{enrolmentId}/enrolmentsubjects/{enrolmentEnrolmentSubjectId}", enrolmentId, id)).andExpect(status().isOk()) .andExpect(content().string(response)); verify(facade).getResource(id); }
@Test(expected = AccessDeniedException.class) public void testGetResourceWithAccessDeniedException() throws Exception { Long id = 5L; Long enrolmentId = 2L; doThrow(AccessDeniedException.class).when(facade) .getResource(anyLong()); mockMvc.perform(get("/enrolments/{enrolmentId}/enrolmentsubjects/{id}", enrolmentId, id)); verify(facade).getResource(id); }