### Question:
DashboardPropertyReader { public String removeWidgetFromDashboardConfig(String config, String widgetName) { try { JSONObject jsonConfig = new JSONObject(config); return DashboardService.removeWidgetsFromJson(jsonConfig, new HashSet<>(Arrays.asList(widgetName))); } catch (JSONException e) { log.warn("Not valid JSON format. {}", e.getMessage()); } return config; }  String removeWidgetFromDashboardConfig(String config, String widgetName); List<String> getModuleNameList(); void setModuleNameList(List<String> moduleNameList); List<Widget> getWidgetList(); void setWidgetList(List<Widget> widgetList); List<Widget> getDashboardWidgetsOnly(); void setDashboardWidgetsOnly(List<Widget> dashboardWidgetsOnly); ModuleDao getModuleDao(); void setModuleDao(ModuleDao moduleDao); WidgetDao getWidgetDao(); void setWidgetDao(WidgetDao widgetDao); ModuleEventPublisher getModuleEventPublisher(); void setModuleEventPublisher(ModuleEventPublisher moduleEventPublisher); UserDao getUserDao(); void setUserDao(UserDao userDao); UserPreferenceService getUserPreferenceService(); void setUserPreferenceService(UserPreferenceService userPreferenceService); DashboardDao getDashboardDao(); void setDashboardDao(DashboardDao dashboardDao); DashboardConfig getDashboardConfig(); void setDashboardConfig(DashboardConfig dashboardConfig);  }### Answer:
@Test public void testRemoveWidgetFromDashboardConfigWhenEmptyColumns() { JSONObject jsonConfig = new JSONObject(); JSONArray rows = new JSONArray(); JSONArray columns = new JSONArray(); JSONObject row1 = new JSONObject(); row1.put("columns", columns); JSONObject row2 = new JSONObject(); row2.put("columns", columns); rows.put(0, row1); rows.put(1, row2); jsonConfig.put("rows", rows); String updatedConfig = dashboardPropertyReader.removeWidgetFromDashboardConfig(jsonConfig.toString(), WIDGET_TO_REMOVE); testIfWidgetIsRemoved(updatedConfig); }
@Test public void testRemoveWidgetFromDashboardConfigWhenNoColumns() { JSONObject jsonConfig = new JSONObject(); JSONArray rows = new JSONArray(); JSONObject row1 = new JSONObject(); row1.put("style", ""); JSONObject row2 = new JSONObject(); row2.put("style", ""); rows.put(0, row1); rows.put(1, row2); jsonConfig.put("rows", rows); dashboardPropertyReader.removeWidgetFromDashboardConfig(jsonConfig.toString(), WIDGET_TO_REMOVE); }
@Test public void testRemoveWidgetFromDashboardConfig() { JSONArray widgets = new JSONArray(); JSONObject referenceWidget = new JSONObject(); referenceWidget.put("type", "references"); JSONObject correspondenceWidget = new JSONObject(); correspondenceWidget.put("type", WIDGET_TO_REMOVE); JSONObject costWidget = new JSONObject(); costWidget.put("type", "costsheet"); widgets.put(0, referenceWidget); widgets.put(1, correspondenceWidget); widgets.put(2, costWidget); JSONObject jsonConfig = new JSONObject(); JSONArray columns = new JSONArray(); JSONObject column1 = new JSONObject(); column1.put("widgets", widgets); columns.put(0, column1); JSONObject column2 = new JSONObject(); column2.put("widgets", widgets); columns.put(1, column2); JSONObject row1 = new JSONObject(); row1.put("columns", columns); JSONObject row2 = new JSONObject(); row2.put("columns", columns); JSONArray rows = new JSONArray(); rows.put(0, row1); rows.put(1, row2); jsonConfig.put("rows", rows); String updatedConfig = dashboardPropertyReader.removeWidgetFromDashboardConfig(jsonConfig.toString(), WIDGET_TO_REMOVE); testIfWidgetIsRemoved(updatedConfig); }