PersonFamilyController extends BaseController implements CrudController<PersonFamilyResource, PersonFamilyResource> { @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{personId}/families", method = RequestMethod.POST) public PersonFamilyResource createResource(@Valid @RequestBody final PersonFamilyResource resource) { LOG.info("Creating person family: {}", resource); return facade.createResource(resource); }  @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 testCreatePersonFamily() throws Exception { Long personId = 1L; Long id = 2L; PersonFamilyResource personFamilyResource = new PersonFamilyResource(); personFamilyResource.setId(id); String request = getJson(personFamilyResource, true); String response = getJson(personFamilyResource, false); when(facade.createResource(any(PersonFamilyResource.class))) .thenReturn(personFamilyResource); mockMvc.perform( post("/persons/{personId}/families", personId).contentType( MediaType.APPLICATION_JSON).content(request)) .andExpect(status().isCreated()) .andExpect(content().string(response)); verify(facade).createResource(personFamilyResource); }