SpecialtyController extends BaseController implements CrudController<SpecialtyResource, SpecialtyResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get Specailty by id", position = 3) public SpecialtyResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving specialty with id: {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create Specialty", position = 1) SpecialtyResource createResource(@Valid @RequestBody final SpecialtyResource specialtyResource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.PUT) @ApiOperation(value = "Update Specialty", position = 2) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final SpecialtyResource specialtyResource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get Specailty by id", position = 3) SpecialtyResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = Request.ID, method = RequestMethod.DELETE) @ApiOperation(value = "Delete Specialty", position = 4) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Get Specailties", position = 5) PagedResultResource<SpecialtyResource> getPagedResource(final PagedRequest<SpecialtyResource> request);  }
@Test public void testGetSpecoffer() throws Exception { Long id = 1L; String name = "fsd specialty"; Long specialtyTypeId = 25L; String abbrName = "fds"; String cipher = "534tgfds"; SpecialtyResource specialtyResource = new SpecialtyResource(); specialtyResource.setId(id); specialtyResource.setBegDate(new Date()); specialtyResource.setEndDate(new Date()); specialtyResource.setAbbrName(abbrName ); specialtyResource.setCipher(cipher); specialtyResource.setName(name); specialtyResource.setSpecialtyTypeId(specialtyTypeId); String response = getJson(specialtyResource, false); when(facade.getResource(anyLong())).thenReturn(specialtyResource); mockMvc.perform(get("/specialties/{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("/specialties/{id}", id)); verify(facade).getResource(id); }