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