Created
November 14, 2016 16:33
-
-
Save anonymous/821bbdc77e9ea746800fce1c9c31713c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testJobConfigurationValidity() { | |
final Reflections reflections = new Reflections(JobConfigurationBase.class.getPackage().getName()); | |
final Set<Class<? extends JobConfigurationBase>> configs = reflections.getSubTypesOf(JobConfigurationBase.class); | |
final List<String> errorList = new ArrayList<>(); | |
configs.stream() | |
.filter(config -> !Modifier.isAbstract(config.getModifiers()) && !config.isAnonymousClass()) | |
.forEach(config -> { | |
try { | |
final JobConfigurationBase jobConfig = config.newInstance(); | |
if (jobConfig.getRetries() < 0) { | |
errorList.add(String.format("Retries must be non negative for %s", jobConfig)); | |
} | |
if (jobConfig.getRunCommand() == null || jobConfig.getRunCommand().isEmpty()) { | |
errorList.add(String.format("Command must exist for %s", jobConfig)); | |
} | |
} catch (InstantiationException | IllegalAccessException e) { | |
errorList.add(String.format("%s cannot be instantiated", config)); | |
} | |
}); | |
assertTrue(errorList.stream().collect(Collectors.joining("\n")), errorList.isEmpty()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment