PersonNameController extends BaseController implements CrudController<PersonNameResource, PersonNameResource> { @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{personId}/names", method = RequestMethod.POST) @ApiOperation(value = "Create PersonName", position = 1) public PersonNameResource createResource(@Valid @RequestBody final PersonNameResource resource) { LOG.info("Creating personName: {}", resource); return facade.createResource(resource); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{personId}/names", method = RequestMethod.POST) @ApiOperation(value = "Create PersonName", position = 1) PersonNameResource createResource(@Valid @RequestBody final PersonNameResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/names/{personNameId}", method = RequestMethod.PUT) @ApiOperation(value = "Update PersonName", position = 2) MessageResource updateResource(@PathVariable("personNameId") final Long personNameId,
 			@Valid @RequestBody final PersonNameResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/names/{personNameId}", method = RequestMethod.GET) @ApiOperation(value = "Get PersonName by id", position = 3) PersonNameResource getResource(@PathVariable("personNameId") final Long personNameId); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{personId}/names/{personNameId}", method = RequestMethod.DELETE) @ApiOperation(value = "Delete PersonName") MessageResource removeResource(@PathVariable("personNameId") final Long personNameId); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{personId}/names", method = RequestMethod.GET) @ApiOperation(value = "Get PersonNames") PagedResultResource<PersonNameResource> getPagedResource(final PagedRequest<PersonNameResource> request);  }
@Test public void testCreatePersonName() throws Exception { Long personId = 1L; PersonNameResource personNameResource = new PersonNameResource(); personNameResource.setPersonId(personId); String request = getJson(personNameResource, true); String response = getJson(personNameResource, false); when(facade.createResource(any(PersonNameResource.class))).thenReturn(personNameResource); mockMvc.perform(post("/persons/{0}/names", personId) .contentType(MediaType.APPLICATION_JSON) .content(request)) .andExpect(status().isCreated()) .andExpect(content().string(response)); verify(facade).createResource(personNameResource); }