@Test public void widgetWithoutCoordinates() throws ConfigException { final String widgetName = "Sample Widget"; try { Dashboard.builder() .dashboardName("My First Dashboard") .enabled(true) .width(5) .height(5) .widget(SimpleWidget.builder() .name(widgetName) .build()) .build() .basicValidate(null); fail("Exception should have been thrown"); } catch(final ConfigException e) { assertThat("Exception has the correct message", e.getMessage(), allOf(containsString(widgetName), containsString("does not have valid coordinates and dimensions"))); } }
@Override public void basicValidate(final String section) throws ConfigException { super.basicValidate(section); if (width == null || width <= 0 || height == null || height <= 0) { throw new ConfigException("Dashboard Config", "Dashboard with name " + dashboardName + " does not have valid dimensions"); } validateWidgets(section); }
Dashboard extends SimpleComponent<Dashboard> implements OptionalConfigurationComponent<Dashboard> { @Override public void basicValidate(final String section) throws ConfigException { super.basicValidate(section); if (width == null || width <= 0 || height == null || height <= 0) { throw new ConfigException("Dashboard Config", "Dashboard with name " + dashboardName + " does not have valid dimensions"); } validateWidgets(section); } }
Dashboard extends SimpleComponent<Dashboard> implements OptionalConfigurationComponent<Dashboard> { @Override public void basicValidate(final String section) throws ConfigException { super.basicValidate(section); if (width == null || width <= 0 || height == null || height <= 0) { throw new ConfigException("Dashboard Config", "Dashboard with name " + dashboardName + " does not have valid dimensions"); } validateWidgets(section); }  }
Dashboard extends SimpleComponent<Dashboard> implements OptionalConfigurationComponent<Dashboard> { @Override public void basicValidate(final String section) throws ConfigException { super.basicValidate(section); if (width == null || width <= 0 || height == null || height <= 0) { throw new ConfigException("Dashboard Config", "Dashboard with name " + dashboardName + " does not have valid dimensions"); } validateWidgets(section); }  @Override void basicValidate(final String section); }
Dashboard extends SimpleComponent<Dashboard> implements OptionalConfigurationComponent<Dashboard> { @Override public void basicValidate(final String section) throws ConfigException { super.basicValidate(section); if (width == null || width <= 0 || height == null || height <= 0) { throw new ConfigException("Dashboard Config", "Dashboard with name " + dashboardName + " does not have valid dimensions"); } validateWidgets(section); }  @Override void basicValidate(final String section);  }