EmployeeController extends BaseController implements CrudController<EmployeeResource, EmployeeResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ApiOperation(value = "Get Employee by id", position = 3) public EmployeeResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving employee with id: {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create Employee", position = 1) EmployeeResource createResource(@Valid @RequestBody final EmployeeResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{id}", method = RequestMethod.PUT) @ApiOperation(value = "Update Employee", position = 2) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final EmployeeResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ApiOperation(value = "Get Employee by id", position = 3) EmployeeResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ApiOperation(value = "Delete Employee", position = 4) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Get Employees", position = 5) PagedResultResource<EmployeeResource> getPagedResource(final PagedRequest<EmployeeResource> request);  }
@Test public void testGetSpecoffer() throws Exception { Long id = 1L; String docNum = "docNum"; EmployeeResource personResource = new EmployeeResource(); personResource.setId(id); personResource.setBegDate(new Date()); personResource.setDocNum(docNum); String response = getJson(personResource, false); when(facade.getResource(anyLong())).thenReturn(personResource); mockMvc.perform(get("/employees/{id}", id)) .andExpect(status().isOk()) .andExpect(content().string(response)); verify(facade).getResource(id); }
@Test(expected = AccessDeniedException.class) public void testGetResourceWithAccessDeniedException() throws Exception { Long id = 1L; doThrow(AccessDeniedException.class).when(facade).getResource(anyLong()); mockMvc.perform(get("/employees/{id}", id)); verify(facade).getResource(id); }