PersonContactController extends BaseController implements CrudController<PersonContactResource, PersonContactResource> { @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{personId}/contacts", method = RequestMethod.POST) public PersonContactResource createResource(@Valid @RequestBody final PersonContactResource resource) { LOG.info("Creating person contact: {}", resource); return facade.createResource(resource); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{personId}/contacts", method = RequestMethod.POST) PersonContactResource createResource(@Valid @RequestBody final PersonContactResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/contacts/{id}", method = RequestMethod.PUT) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final PersonContactResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/contacts/{id}", method = RequestMethod.GET) PersonContactResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{personId}/contacts/{id}", method = RequestMethod.DELETE) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/contacts", method = RequestMethod.GET) PagedResultResource<PersonContactResource> getPagedResource(final PagedRequest<PersonContactResource> request);  }
@Test public void testCreatePersonContact() throws Exception { Long personId = 1L; Long id = 2L; PersonContactResource personContactResource = new PersonContactResource(); personContactResource.setId(id); String request = getJson(personContactResource, true); String response = getJson(personContactResource, false); when(facade.createResource(any(PersonContactResource.class))) .thenReturn(personContactResource); mockMvc.perform( post("/persons/{personId}/contacts", personId).contentType( MediaType.APPLICATION_JSON).content(request)) .andExpect(status().isCreated()) .andExpect(content().string(response)); verify(facade).createResource(personContactResource); }