PersonFamilyController extends BaseController implements CrudController<PersonFamilyResource, PersonFamilyResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/families/{id}", method = RequestMethod.GET) public PersonFamilyResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving person family with id: {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{personId}/families", method = RequestMethod.POST) PersonFamilyResource createResource(@Valid @RequestBody final PersonFamilyResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/families/{id}", method = RequestMethod.PUT) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final PersonFamilyResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/families/{id}", method = RequestMethod.GET) PersonFamilyResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{personId}/families/{id}", method = RequestMethod.DELETE) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/families", method = RequestMethod.GET) PagedResultResource<PersonFamilyResource> getPagedResource(final PagedRequest<PersonFamilyResource> request);  }
@Test public void testGetFamily() throws Exception { Long personId = 1L; Long id = 2L; PersonFamilyResource personFamilyResource = new PersonFamilyResource(); personFamilyResource.setId(id); personFamilyResource.setPersonId(personId); String response = getJson(personFamilyResource, false); when(facade.getResource(anyLong())).thenReturn( personFamilyResource); mockMvc.perform( get("/persons/{personId}/families/{contactId}", 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 personId = 2L; doThrow(AccessDeniedException.class).when(facade) .getResource(anyLong()); mockMvc.perform(get("/persons/{personId}/families/{id}", personId, id)); verify(facade).getResource(id); }