DashboardController { @RequestMapping(value = "/{slug}", method = GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<DashboardResource> getDashboard(@PathVariable String slug) { Dashboard dashboard = service.load(slug); DashboardResource resource = dashboardResourceAssembler.toResource(dashboard); return new ResponseEntity<>(resource, OK); } @Autowired  DashboardController(
      DashboardService service, DashboardResourceAssembler dashboardResourceAssembler); @RequestMapping( method = POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<ResourceSupport> create(
      @RequestBody @Valid DashboardResource dashboardResource, Errors errors); @SuppressWarnings("unchecked") @RequestMapping(method = GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<PagedResources<DashboardResource>> getAllDashboards(
      @PageableDefault Pageable pageable, PagedResourcesAssembler pagedResourcesAssembler); @RequestMapping(value = "/{slug}", method = GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<DashboardResource> getDashboard(@PathVariable String slug);  }
@Test public void getDashboard() throws Exception { when(dashboardService.load("1")).thenReturn(dashboard()); MvcResult result = mvc() .perform(get("/api/dashboards/1")) .andExpect(status().isOk()) .andExpect(containsResource(DashboardResource.class)) .andDo( document( "dashboards/get", links( halLinks(), linkWithRel("self").description("Link to the dashboard itself."), linkWithRel("widgets") .description( "Link to the paged collection of widgets configured for this dashboard."), linkWithRel("all-widgets") .description( "Link to the unpaged collection of widgets configured for this dashboard.")))) .andReturn(); DashboardResource resource = fromJson(result.getResponse().getContentAsString(), DashboardResource.class); assertThat(resource).isNotNull(); }