BroadcastingController extends BaseController implements CrudController<BroadcastingMessageResource, BroadcastingMessageResource> { @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) public BroadcastingMessageResource getResource(@PathVariable("id") final Long id) { LOG.info("Getting Broadcast message by id : {}", id); return facade.getResource(id); }  @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(method = RequestMethod.GET) PagedResultResource<BroadcastingMessageResource> getPagedResource(final PagedRequest<BroadcastingMessageResource> request); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.GET) BroadcastingMessageResource getResource(@PathVariable("id") final Long id); @Override @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) BroadcastingMessageResource createResource(@Valid @RequestBody final BroadcastingMessageResource resource); @Override @ResponseStatus(HttpStatus.OK) @RequestMapping(value = Request.ID, method = RequestMethod.PUT) MessageResource updateResource(@PathVariable("id") final Long id, 
			@Valid @RequestBody final BroadcastingMessageResource resource); @Override @ResponseStatus(HttpStatus.NO_CONTENT) @RequestMapping(value = Request.ID, method = RequestMethod.DELETE) MessageResource removeResource(@PathVariable("id") final Long id);  }
@Test public void testGetSpecoffer() throws Exception { Long id = 1L; Long group1 = 1L; Long group2 = 2L; List<Long> groups = Arrays.asList(group1, group2); String recipient1 = "recipient1@edu.lviv.ua"; String recipient2 = "recipient2@edu.lviv.ua"; List<String> recipient = Arrays.asList(recipient1, recipient2); String content = "content"; String topic = "topic"; BroadcastingMessageResource resource = new BroadcastingMessageResource(); resource.setContent(content); resource.setTopic(topic); resource.setRecipients(recipient); resource.setGroups(groups); resource.setId(id); String response = getJson(resource, false); when(facade.getResource(anyLong())).thenReturn(resource); mockMvc.perform(get("/broadcastings/{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("/broadcastings/{id}", id)); verify(facade).getResource(id); }