use of org.talend.sdk.component.junit.environment.BaseEnvironmentProvider in project component-runtime by Talend.
the class Generator method generatedJUnitEnvironment.
private static void generatedJUnitEnvironment(final File generatedDir) throws MalformedURLException {
final File file = new File(generatedDir, "generated_junit-environments.adoc");
try (final PrintStream stream = new PrintStream(new WriteIfDifferentStream(file))) {
stream.println("");
stream.println("NOTE: the configuration is read from system properties, environment variables, ....");
stream.println("");
stream.println("[role=\"table-striped table-hover table-ordered\",options=\"header,autowidth\"]");
stream.println("|====");
stream.println("|Class|Name|Description");
final File api = jarLocation(BaseEnvironmentProvider.class);
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final AnnotationFinder finder = new AnnotationFinder(api.isDirectory() ? new FileArchive(loader, api) : new JarArchive(loader, api.toURI().toURL()));
finder.link().findSubclasses(BaseEnvironmentProvider.class).stream().filter(c -> !Modifier.isAbstract(c.getModifiers())).sorted(Comparator.comparing(Class::getName)).forEach(type -> {
final BaseEnvironmentProvider environment;
try {
environment = BaseEnvironmentProvider.class.cast(type.getConstructor().newInstance());
} catch (final InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalStateException(e);
}
stream.println("|" + type.getSimpleName() + "|" + environment.getName() + "|" + environment.getName() + " runner");
});
stream.println("|====");
stream.println();
}
}
Aggregations