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