DepartmentController extends BaseController implements CrudController<DepartmentResource, DepartmentResource> { @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create Department") public DepartmentResource createResource(@RequestBody final DepartmentResource departmentResource) { LOG.info("Creating department: {}", departmentResource); return facade.createResource(departmentResource); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create Department") DepartmentResource createResource(@RequestBody final DepartmentResource departmentResource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.PUT) @ApiOperation(value = "Update Department") MessageResource updateResource(@PathVariable("id") final Long id,
			@RequestBody final DepartmentResource departmentResource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get Department by id") DepartmentResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = Request.ID, method = RequestMethod.DELETE) @ApiOperation(value = "Delete Department by id") MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Get Departments") PagedResultResource<DepartmentResource> getPagedResource(final PagedRequest<DepartmentResource> request); @RequestMapping(value = "/timeperiods/{timePeriodId}/specoffers", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) List<DepartmentSpecofferResource> getDepartmentSpecoffers(@PathVariable("timePeriodId") long timePeriodId);  }
@Test public void testCreateDepartment() throws Exception { String name = "fsd department"; String abbrName = "fds"; String manager = "manager"; DepartmentResource departmentResource = new DepartmentResource(); departmentResource.setBegDate(new Date()); departmentResource.setEndDate(new Date()); departmentResource.setAbbrName(abbrName ); departmentResource.setName(name); departmentResource.setManager(manager); String request = getJson(departmentResource, true); String response = getJson(departmentResource, false); when(facade.createResource(any(DepartmentResource.class))).thenReturn(departmentResource); mockMvc.perform(post("/departments") .contentType(MediaType.APPLICATION_JSON) .content(request)) .andExpect(status().isCreated()) .andExpect(content().string(response)); verify(facade).createResource(departmentResource); }