use of com.github.qzagarese.dockerunit.internal.TestDescriptor in project dockerunit by qzagarese.
the class DefaultServiceBuilder method executeOptionBuilders.
private CreateContainerCmd executeOptionBuilders(TestDescriptor descriptor, CreateContainerCmd cmd) {
for (Annotation a : descriptor.getOptions()) {
Class<? extends ExtensionInterpreter<?>> builderType = a.annotationType().getAnnotation(ExtensionMarker.class).value();
ExtensionInterpreter<?> builder = null;
Method buildMethod = null;
try {
builder = builderType.newInstance();
} catch (Exception e) {
throw new RuntimeException("Cannot instantiate " + ExtensionInterpreter.class.getSimpleName() + " of type " + builderType.getSimpleName() + " to handle annotation " + a.annotationType().getSimpleName() + " that has been detected on class " + descriptor.getInstance().getClass().getName(), e);
}
try {
buildMethod = builderType.getDeclaredMethod("build", new Class<?>[] { TestDescriptor.class, CreateContainerCmd.class, a.annotationType() });
cmd = (CreateContainerCmd) buildMethod.invoke(builder, descriptor, cmd, a);
} catch (Exception e) {
throw new RuntimeException("An error occurred while invoking the build method on builder class " + builderType.getName(), e);
}
}
return cmd;
}
Aggregations