WidgetController { @RequestMapping( value = "/{widgetId}", method = DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Void> deleteWidget(@PathVariable String widgetId) { boolean exists = widgetService.exists(widgetId); if (!exists) { return new ResponseEntity<>(NOT_FOUND); } widgetService.deleteWidget(widgetId); return new ResponseEntity<>(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 deleteWidget() throws Exception { when(widgetService.exists("2")).thenReturn(true); mvc() .perform(delete("/api/dashboards/test/widgets/2").contentType("application/json")) .andExpect(status().isOk()) .andDo(document("widgets/delete")) .andReturn(); }