AssetAddressController extends BaseController implements CrudController<AssetAddressResource, AssetAddressResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{assetId}/addresses/{id}", method = RequestMethod.GET) public AssetAddressResource getResource(@PathVariable("id") final Long id) { LOG.info("Retrieving asset address with id: {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(value = "/{assetId}/addresses", method = RequestMethod.POST) AssetAddressResource createResource(@Valid @RequestBody final AssetAddressResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{assetId}/addresses/{id}", method = RequestMethod.PUT) MessageResource updateResource(@PathVariable("id") final Long id,
			@Valid @RequestBody final AssetAddressResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{assetId}/addresses/{id}", method = RequestMethod.GET) AssetAddressResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = "/{assetId}/addresses/{id}", method = RequestMethod.DELETE) MessageResource removeResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/{assetId}/addresses", method = RequestMethod.GET) PagedResultResource<AssetAddressResource> getPagedResource(final PagedRequest<AssetAddressResource> request);  }
@Test public void testGetSpecoffer() throws Exception { Long id = 1L; AssetAddressResource assetResource = new AssetAddressResource(); assetResource.setId(id); String response = getJson(assetResource, false); when(facade.getResource(anyLong())).thenReturn(assetResource); mockMvc.perform(get("/assets/1/addresses/{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("/assets/1/addresses/{id}", id)); verify(facade).getResource(id); }