WidgetController { @RequestMapping( value = "/{widgetId}/data", method = GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<SourceDataResource> getData( @PathVariable String slug, @PathVariable String widgetId) { SourceDataResourceAssembler assembler = new SourceDataResourceAssembler(slug, widgetId); List<SourceData> data = widgetService.getData(widgetId); SourceDataResource resource = assembler.toResource(data); return new ResponseEntity<>(resource, OK); } @Autowired  WidgetController(
      WidgetConfigService widgetService,
      WidgetConfigRepository widgetConfigRepository,
      DashboardService dashboardService); @RequestMapping(value = "/{widgetId}", method = GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<WidgetConfigResource> getWidget(
      @PathVariable String slug, @PathVariable String widgetId); @RequestMapping( value = "/{widgetId}", method = DELETE, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Void> deleteWidget(@PathVariable String widgetId); @RequestMapping( method = POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<WidgetConfigResource> createWidget(
      @PathVariable String slug, @RequestBody WidgetConfigResource widgetConfigResource); @RequestMapping( value = "/{widgetId}/data", method = GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<SourceDataResource> getData(
      @PathVariable String slug, @PathVariable String widgetId); @SuppressWarnings("unchecked") @RequestMapping(method = GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<PagedResources<WidgetConfigResource>> getWidgets(
      @PathVariable String slug,
      @PageableDefault Pageable pageable,
      PagedResourcesAssembler pagedResourcesAssembler); @RequestMapping(value = "/all", method = GET, produces = MediaType.APPLICATION_JSON_VALUE) Resources<WidgetConfigResource> getAllWidgets(@PathVariable String slug);  }
@Test public void getData() throws Exception { when(widgetService.getData(eq("my_little_widget"))).thenReturn(sourceDataList()); MvcResult result = mvc() .perform(get("/api/dashboards/test/widgets/my_little_widget/data")) .andExpect(status().isOk()) .andExpect(containsResource(SourceDataResource.class)) .andDo(document("widgets/data/list")) .andReturn(); SourceDataResource resource = fromJson(result.getResponse().getContentAsString(), SourceDataResource.class); assertThat(resource.getSourceData()).hasSize(3); }