EnrolmentStatusTypeController extends BaseController implements PagedController<EnrolmentStatusTypeResource, EnrolmentStatusTypeResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get enrolment status type controller by id") public EnrolmentStatusTypeResource getResource(@PathVariable("id") final Long id) { return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Get All Enrolment Status Types") PagedResultResource<EnrolmentStatusTypeResource> getPagedResource(final PagedRequest<EnrolmentStatusTypeResource> request); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) @ApiOperation(value = "Get enrolment status type controller by id") EnrolmentStatusTypeResource getResource(@PathVariable("id") final Long id);  }
@Test public void testGetResource() throws Exception { Long id = 1L; String name = "all difficult"; String abbrName = "ad"; EnrolmentStatusTypeResource expected = new EnrolmentStatusTypeResource(); expected.setName(name); expected.setAbbrName(abbrName); expected.setId(id); when(facade.getResource(anyLong())).thenReturn(expected); String response = getJson(expected, false); mockMvc.perform(get("/enrolments/statustypes/{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("/enrolments/statustypes/{id}", id)); verify(facade).getResource(id); }