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