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