DashboardController { @SuppressWarnings("unchecked") @RequestMapping(method = GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<PagedResources<DashboardResource>> getAllDashboards( @PageableDefault Pageable pageable, PagedResourcesAssembler pagedResourcesAssembler) { Page<Dashboard> dashboardsPage = service.loadAll(pageable); PagedResources<DashboardResource> pagedResources = pagedResourcesAssembler.toResource(dashboardsPage, dashboardResourceAssembler); return new ResponseEntity<>(pagedResources, 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 getAllDashboards() throws Exception { when(dashboardService.loadAll(any(Pageable.class))) .thenReturn(new PageImpl<>(dashboardList(), new PageRequest(0, 1), 1)); MvcResult result = mvc() .perform(get("/api/dashboards")) .andExpect(status().isOk()) .andExpect(containsPagedResources(DashboardResource.class)) .andDo(document("dashboards/list")) .andReturn(); PagedResources<DashboardResource> pagedResources = fromPagedResourceJson(result.getResponse().getContentAsString(), DashboardResource.class); assertThat(pagedResources.getContent()).hasSize(1); }