@Test public void validConfig() throws IOException { final File tmpFile = File.createTempFile("temp", "pptx"); tmpFile.deleteOnExit(); assertTrue(validator.validate(PowerPointConfig.builder() .templateFile(tmpFile.getAbsolutePath()) .build()) .isValid()); }
@Override public ValidationResult<?> validate(final PowerPointConfig powerPointConfig) { try { powerPointConfig.basicValidate(null); } catch (final ConfigException ignored) { return new ValidationResult<>(false, Validation.CONFIGURATION_INVALID); } final String templateFile = powerPointConfig.getTemplateFile(); if (StringUtils.isNotBlank(templateFile)) { try { powerPointService.validateTemplate(); } catch (final TemplateLoadException ignored) { return new ValidationResult<>(false, Validation.TEMPLATE_INVALID); } } return new ValidationResult<>(true, null); }
PowerPointConfigValidator implements Validator<PowerPointConfig> { @Override public ValidationResult<?> validate(final PowerPointConfig powerPointConfig) { try { powerPointConfig.basicValidate(null); } catch (final ConfigException ignored) { return new ValidationResult<>(false, Validation.CONFIGURATION_INVALID); } final String templateFile = powerPointConfig.getTemplateFile(); if (StringUtils.isNotBlank(templateFile)) { try { powerPointService.validateTemplate(); } catch (final TemplateLoadException ignored) { return new ValidationResult<>(false, Validation.TEMPLATE_INVALID); } } return new ValidationResult<>(true, null); } }
PowerPointConfigValidator implements Validator<PowerPointConfig> { @Override public ValidationResult<?> validate(final PowerPointConfig powerPointConfig) { try { powerPointConfig.basicValidate(null); } catch (final ConfigException ignored) { return new ValidationResult<>(false, Validation.CONFIGURATION_INVALID); } final String templateFile = powerPointConfig.getTemplateFile(); if (StringUtils.isNotBlank(templateFile)) { try { powerPointService.validateTemplate(); } catch (final TemplateLoadException ignored) { return new ValidationResult<>(false, Validation.TEMPLATE_INVALID); } } return new ValidationResult<>(true, null); } @Autowired  PowerPointConfigValidator(final PowerPointService powerPointService); }
PowerPointConfigValidator implements Validator<PowerPointConfig> { @Override public ValidationResult<?> validate(final PowerPointConfig powerPointConfig) { try { powerPointConfig.basicValidate(null); } catch (final ConfigException ignored) { return new ValidationResult<>(false, Validation.CONFIGURATION_INVALID); } final String templateFile = powerPointConfig.getTemplateFile(); if (StringUtils.isNotBlank(templateFile)) { try { powerPointService.validateTemplate(); } catch (final TemplateLoadException ignored) { return new ValidationResult<>(false, Validation.TEMPLATE_INVALID); } } return new ValidationResult<>(true, null); } @Autowired  PowerPointConfigValidator(final PowerPointService powerPointService); @Override ValidationResult<?> validate(final PowerPointConfig powerPointConfig); @Override Class<PowerPointConfig> getSupportedClass(); }
PowerPointConfigValidator implements Validator<PowerPointConfig> { @Override public ValidationResult<?> validate(final PowerPointConfig powerPointConfig) { try { powerPointConfig.basicValidate(null); } catch (final ConfigException ignored) { return new ValidationResult<>(false, Validation.CONFIGURATION_INVALID); } final String templateFile = powerPointConfig.getTemplateFile(); if (StringUtils.isNotBlank(templateFile)) { try { powerPointService.validateTemplate(); } catch (final TemplateLoadException ignored) { return new ValidationResult<>(false, Validation.TEMPLATE_INVALID); } } return new ValidationResult<>(true, null); } @Autowired  PowerPointConfigValidator(final PowerPointService powerPointService); @Override ValidationResult<?> validate(final PowerPointConfig powerPointConfig); @Override Class<PowerPointConfig> getSupportedClass();  }