PublicActivityAwardController extends BaseController implements CrudController<PublicActivityAwardResource, PublicActivityAwardResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{publicActivityId}/awards/{id}", method = RequestMethod.GET) public PublicActivityAwardResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving PublicActivityAward with id: {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{publicActivityId}/awards", method = RequestMethod.POST) PublicActivityAwardResource createResource(@Valid @RequestBody final PublicActivityAwardResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{publicActivityId}/awards/{id}", method = RequestMethod.PUT) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final PublicActivityAwardResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{publicActivityId}/awards/{id}", method = RequestMethod.GET) PublicActivityAwardResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{publicActivityId}/awards/{id}", method = RequestMethod.DELETE) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{publicActivityId}/awards", method = RequestMethod.GET) PagedResultResource<PublicActivityAwardResource> getPagedResource(final PagedRequest<PublicActivityAwardResource> request); @Resource(name = "publicActivityAwardFacade")
	private Facade<PublicActivityAwardResource, PublicActivityAwardResource, Long> facade; }
@Test public void testGetResource() throws Exception { Long id = 1L; Long publicActivityId = 1L; PublicActivityAwardResource resource = new PublicActivityAwardResource(); resource.setPublicActivityId(publicActivityId); resource.setBegDate(new Date()); resource.setId(id); String response = getJson(resource, false); when(facade.getResource(anyLong())).thenReturn(resource); mockMvc.perform( get("/publicactivities/{publicActivityId}/awards/{id}", publicActivityId, 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 publicActivityId = 2L; doThrow(AccessDeniedException.class).when(facade) .getResource(anyLong()); mockMvc.perform(get("/publicactivities/{publicActivityId}/awards/{id}", publicActivityId, id)); verify(facade).getResource(id); }