SpecOfferSubjectController extends BaseController implements CrudController<SpecOfferSubjectResource, SpecOfferSubjectResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{specOfferId}/subjects/{specOfferSubjectId}", method = RequestMethod.GET) @ApiOperation(value = "Get Spec Offer Subjects by spec offer id", position = 3) public SpecOfferSubjectResource getResource(@PathVariable("specOfferSubjectId") final Long specOfferSubjectId) { LOG.info("Retrieving Spec Offer Subject with id: {}", specOfferSubjectId); return facade.getResource(specOfferSubjectId); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{specOfferId}/subjects", method = RequestMethod.POST) @ApiOperation(value = "Method for creating Spec Offer Subject") SpecOfferSubjectResource createResource(@Valid @RequestBody final SpecOfferSubjectResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{specOfferId}/subjects/{specOfferSubjectId}", method = RequestMethod.PUT) @ApiOperation(value = "Update Spec Offer Subject", position = 2) MessageResource updateResource(@PathVariable("specOfferSubjectId") final Long specOfferSubjectId,
 			@RequestBody final SpecOfferSubjectResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{specOfferId}/subjects/{specOfferSubjectId}", method = RequestMethod.GET) @ApiOperation(value = "Get Spec Offer Subjects by spec offer id", position = 3) SpecOfferSubjectResource getResource(@PathVariable("specOfferSubjectId") final Long specOfferSubjectId); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{specOfferId}/subjects/{specOfferSubjectId}", method = RequestMethod.DELETE) @ApiOperation(value = "Delete Spec Offer Subject", position = 4) MessageResource removeResource(@PathVariable("specOfferSubjectId") final Long specOfferSubjectId); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{specOfferId}/subjects", method = RequestMethod.GET) @ApiOperation(value = "Get Spec Offer Subjects") PagedResultResource<SpecOfferSubjectResource> getPagedResource(final PagedRequest<SpecOfferSubjectResource> request);  }
@Test public void testGetSpecoffer() throws Exception { Long id = 1L; Long personId = 1L; SpecOfferSubjectResource specOfferSubjectResource = new SpecOfferSubjectResource(); String response = getJson(specOfferSubjectResource, false); when(facade.getResource(anyLong())).thenReturn(specOfferSubjectResource); mockMvc.perform(get("/specoffers/{0}/subjects/{id}", personId, id)) .andExpect(status().isOk()) .andExpect(content().string(response)); verify(facade).getResource(id); }
@Test(expected = AccessDeniedException.class) public void testGetResourceWithAccessDeniedException() throws Exception { Long id = 1L; Long specOfferId = 2L; doThrow(AccessDeniedException.class).when(facade).getResource(anyLong()); mockMvc.perform(get("/specoffers/{specOfferId}/subjects/{id}", specOfferId, id)); verify(facade).getResource(id); }