@Test public void invalidMarginDifference() throws Exception { try { PowerPointConfig.builder() .marginLeft(0.5) .marginRight(0.5) .build() .basicValidate(null); fail("Exception should have been thrown"); } catch(final ConfigException e) { assertThat("Exception has the correct message", e.getMessage(), containsString("Top/bottom and left/right margin setting pairs should sum to less than 1")); } }
@Override public void basicValidate(final String section) throws ConfigException { if (Stream.of(marginTop, marginLeft, marginRight, marginBottom).anyMatch(value -> value != null && (value >= 1 || value < 0))) { throw new ConfigException(SECTION, "All specified margin settings must be populated with values between 0 (inclusive) and 1 (exclusive)"); } if (differenceIsInvalid(marginLeft, marginRight) || differenceIsInvalid(marginTop, marginBottom)) { throw new ConfigException(SECTION, "Top/bottom and left/right margin setting pairs should sum to less than 1"); } if (StringUtils.isNotBlank(templateFile)) { final File file = new File(templateFile); if (!file.exists()) { throw new ConfigException(SECTION, "Template file does not exist"); } } }
PowerPointConfig extends SimpleComponent<PowerPointConfig> implements OptionalConfigurationComponent<PowerPointConfig> { @Override public void basicValidate(final String section) throws ConfigException { if (Stream.of(marginTop, marginLeft, marginRight, marginBottom).anyMatch(value -> value != null && (value >= 1 || value < 0))) { throw new ConfigException(SECTION, "All specified margin settings must be populated with values between 0 (inclusive) and 1 (exclusive)"); } if (differenceIsInvalid(marginLeft, marginRight) || differenceIsInvalid(marginTop, marginBottom)) { throw new ConfigException(SECTION, "Top/bottom and left/right margin setting pairs should sum to less than 1"); } if (StringUtils.isNotBlank(templateFile)) { final File file = new File(templateFile); if (!file.exists()) { throw new ConfigException(SECTION, "Template file does not exist"); } } } }
PowerPointConfig extends SimpleComponent<PowerPointConfig> implements OptionalConfigurationComponent<PowerPointConfig> { @Override public void basicValidate(final String section) throws ConfigException { if (Stream.of(marginTop, marginLeft, marginRight, marginBottom).anyMatch(value -> value != null && (value >= 1 || value < 0))) { throw new ConfigException(SECTION, "All specified margin settings must be populated with values between 0 (inclusive) and 1 (exclusive)"); } if (differenceIsInvalid(marginLeft, marginRight) || differenceIsInvalid(marginTop, marginBottom)) { throw new ConfigException(SECTION, "Top/bottom and left/right margin setting pairs should sum to less than 1"); } if (StringUtils.isNotBlank(templateFile)) { final File file = new File(templateFile); if (!file.exists()) { throw new ConfigException(SECTION, "Template file does not exist"); } } }  }
PowerPointConfig extends SimpleComponent<PowerPointConfig> implements OptionalConfigurationComponent<PowerPointConfig> { @Override public void basicValidate(final String section) throws ConfigException { if (Stream.of(marginTop, marginLeft, marginRight, marginBottom).anyMatch(value -> value != null && (value >= 1 || value < 0))) { throw new ConfigException(SECTION, "All specified margin settings must be populated with values between 0 (inclusive) and 1 (exclusive)"); } if (differenceIsInvalid(marginLeft, marginRight) || differenceIsInvalid(marginTop, marginBottom)) { throw new ConfigException(SECTION, "Top/bottom and left/right margin setting pairs should sum to less than 1"); } if (StringUtils.isNotBlank(templateFile)) { final File file = new File(templateFile); if (!file.exists()) { throw new ConfigException(SECTION, "Template file does not exist"); } } }  @Override void basicValidate(final String section); @Override Boolean getEnabled(); }
PowerPointConfig extends SimpleComponent<PowerPointConfig> implements OptionalConfigurationComponent<PowerPointConfig> { @Override public void basicValidate(final String section) throws ConfigException { if (Stream.of(marginTop, marginLeft, marginRight, marginBottom).anyMatch(value -> value != null && (value >= 1 || value < 0))) { throw new ConfigException(SECTION, "All specified margin settings must be populated with values between 0 (inclusive) and 1 (exclusive)"); } if (differenceIsInvalid(marginLeft, marginRight) || differenceIsInvalid(marginTop, marginBottom)) { throw new ConfigException(SECTION, "Top/bottom and left/right margin setting pairs should sum to less than 1"); } if (StringUtils.isNotBlank(templateFile)) { final File file = new File(templateFile); if (!file.exists()) { throw new ConfigException(SECTION, "Template file does not exist"); } } }  @Override void basicValidate(final String section); @Override Boolean getEnabled();  }