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