@Test public void overlappingWidgets() throws ConfigException { final String firstWidgetName = "First Widget"; final String secondWidgetName = "Second Widget"; try { Dashboard.builder() .dashboardName("My First Dashboard") .enabled(true) .width(5) .height(5) .widget(SimpleWidget.builder() .name(firstWidgetName) .x(0) .y(0) .width(2) .height(2) .build()) .widget(SimpleWidget.builder() .name(secondWidgetName) .x(1) .y(1) .width(2) .height(2) .build()) .build() .basicValidate(null); fail("Exception should have been thrown"); } catch(final ConfigException e) { assertThat("Exception has the correct message", e.getMessage(), allOf(containsString(firstWidgetName), containsString(secondWidgetName), containsString("overlap"))); } }
@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);  }