@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); }
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; }
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; } }
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; }  }
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); }
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);  }