TimePeriodController extends BaseController implements CrudController<TimePeriodResource, TimePeriodResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get TimePeriod by id") public TimePeriodResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving timePeriod with id: {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create Person") TimePeriodResource createResource(@Valid @RequestBody final TimePeriodResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.PUT) @ApiOperation(value = "Update TimePeriod") MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final TimePeriodResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get TimePeriod by id") TimePeriodResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = Request.ID, method = RequestMethod.DELETE) @ApiOperation(value = "Delete TimePeriod") MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Get Time Periods") PagedResultResource<TimePeriodResource> getPagedResource(@Limit(defaultValue = "38") final PagedRequest<TimePeriodResource> request);  }
@Test public void testGetSpecoffer() throws Exception { Long id = 1L; TimePeriodResource timePeriodResource = new TimePeriodResource(); timePeriodResource.setId(id); timePeriodResource.setBegDate(new Date()); String response = getJson(timePeriodResource, false); when(facade.getResource(anyLong())).thenReturn(timePeriodResource); mockMvc.perform(get("/timeperiods/{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("/timeperiods/{id}", id)); verify(facade).getResource(id); }