MarkScaleController extends BaseController implements CrudController<MarkScaleResource, MarkScaleResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ApiOperation(value = "Get MarkScale by id", position = 3) public MarkScaleResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving markScale with id: {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "Create MarkScale", position = 1) MarkScaleResource createResource(@Valid @RequestBody final MarkScaleResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{id}", method = RequestMethod.PUT) @ApiOperation(value = "Update MarkScale", position = 2) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final MarkScaleResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ApiOperation(value = "Get MarkScale by id", position = 3) MarkScaleResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ApiOperation(value = "Delete MarkScale", position = 4) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) @ApiOperation(value = "Get MarkScales", position = 5) PagedResultResource<MarkScaleResource> getPagedResource(final PagedRequest<MarkScaleResource> request);  }
@Test public void testGetMarkScale() throws Exception { Long id = 1L; String abbrName = "abbrName"; String name = "name"; MarkScaleResource markScaleResource = new MarkScaleResource(); markScaleResource.setId(id); markScaleResource.setAbbrName(abbrName); markScaleResource.setName(name); String response = getJson(markScaleResource, false); when(facade.getResource(anyLong())).thenReturn(markScaleResource); mockMvc.perform(get("/marks/scales/{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("/marks/scales/{id}", id)); verify(facade).getResource(id); }