SpecOfferBenefitController extends BaseController implements CrudController<SpecOfferBenefitResource, SpecOfferBenefitResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{specOfferId}/benefits/{specOfferBenefitId}", method = RequestMethod.GET) @ApiOperation(value = "Get Spec Offer Benefits by spec offer id", position = 3) public SpecOfferBenefitResource getResource(@PathVariable("specOfferBenefitId") final Long specOfferBenefitId) { LOG.info("Retrieving Spec Offer Subject with id: {}", specOfferBenefitId); return facade.getResource(specOfferBenefitId); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{specOfferId}/benefits", method = RequestMethod.POST) @ApiOperation(value = "Method for creating Spec Offer Benefit") SpecOfferBenefitResource createResource(@Valid @RequestBody final SpecOfferBenefitResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{specOfferId}/benefits/{specOfferBenefitId}", method = RequestMethod.PUT) @ApiOperation(value = "Update Spec Offer Benefit", position = 2) MessageResource updateResource(@PathVariable("specOfferBenefitId") final Long specOfferBenefitId,
 			@RequestBody final SpecOfferBenefitResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{specOfferId}/benefits/{specOfferBenefitId}", method = RequestMethod.GET) @ApiOperation(value = "Get Spec Offer Benefits by spec offer id", position = 3) SpecOfferBenefitResource getResource(@PathVariable("specOfferBenefitId") final Long specOfferBenefitId); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{specOfferId}/benefits/{specOfferBenefitId}", method = RequestMethod.DELETE) @ApiOperation(value = "Delete Spec Offer Benefit", position = 4) MessageResource removeResource(@PathVariable("specOfferBenefitId") final Long specOfferBenefitId); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{specOfferId}/benefits", method = RequestMethod.GET) @ApiOperation(value = "Get Spec Offer Benefits", position = 5) PagedResultResource<SpecOfferBenefitResource> getPagedResource(final PagedRequest<SpecOfferBenefitResource> request);  }
@Test public void testGetSpecoffer() throws Exception { Long id = 1L; Long personId = 1L; SpecOfferBenefitResource specOfferBenefitResource = new SpecOfferBenefitResource(); String response = getJson(specOfferBenefitResource, false); when(facade.getResource(anyLong())).thenReturn(specOfferBenefitResource); mockMvc.perform(get("/specoffers/{0}/benefits/{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}/benefits/{id}", specOfferId, id)); verify(facade).getResource(id); }