SpecOfferController extends BaseController implements CrudController<SpecOfferResource, SpecOfferResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get's SpecOffer", position = 3) public SpecOfferResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving specoffer with id: {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create Specoffer", position = 1) SpecOfferResource createResource(@Valid @RequestBody final SpecOfferResource specOfferResource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.PUT) @ApiOperation(value = "Update SpecOffer", position = 2) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final SpecOfferResource specOfferResource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get's SpecOffer", position = 3) SpecOfferResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = Request.ID, method = RequestMethod.DELETE) @ApiOperation(value = "Remove Specoffer", position = 4) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Get's All SpecOffers", position = 5) PagedResultResource<SpecOfferResource> getPagedResource(final PagedRequest<SpecOfferResource> request);  }
@Test public void testGetSpecoffer() throws Exception { Long id = 1L; String note = "Note"; Integer licCount = 24; Long educationFormTypeId = 1L; String docNum = "docNum"; Long departmentId = 23L; SpecOfferResource specOfferResource = new SpecOfferResource(); specOfferResource.setId(id); specOfferResource.setBegDate(new Date()); specOfferResource.setEndDate(new Date()); specOfferResource.setDepartmentId(departmentId); specOfferResource.setDocNum(docNum); specOfferResource.setEducationFormTypeId(educationFormTypeId); specOfferResource.setLicCount(licCount); specOfferResource.setNote(note); String response = getJson(specOfferResource, false); when(facade.getResource(anyLong())).thenReturn(specOfferResource); mockMvc.perform(get("/specoffers/{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("/specoffers/{id}", id)); verify(facade).getResource(id); }