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