use of org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor in project graylog2-server by Graylog2.
the class ContainerMatrixClassSelectorResolver method resolve.
@Override
public Resolution resolve(UniqueIdSelector selector, Context context) {
UniqueId uniqueId = selector.getUniqueId();
UniqueId.Segment lastSegment = uniqueId.getLastSegment();
if (ContainerMatrixTestClassDescriptor.SEGMENT_TYPE.equals(lastSegment.getType())) {
String className = lastSegment.getValue();
return ReflectionUtils.tryToLoadClass(className).toOptional().filter(isTestClassWithTests).map(testClass -> toResolution(context.addToParent(parent -> Optional.of(newClassTestDescriptor(parent, testClass))))).orElse(unresolved());
}
if (NestedClassTestDescriptor.SEGMENT_TYPE.equals(lastSegment.getType())) {
String simpleClassName = lastSegment.getValue();
return toResolution(context.addToParent(() -> selectUniqueId(uniqueId.removeLastSegment()), parent -> {
if (parent instanceof ClassBasedTestDescriptor) {
Class<?> parentTestClass = ((ClassBasedTestDescriptor) parent).getTestClass();
return ReflectionUtils.findNestedClasses(parentTestClass, isNestedTestClass.and(where(Class::getSimpleName, isEqual(simpleClassName)))).stream().findFirst().flatMap(testClass -> Optional.of(newNestedClassTestDescriptor(parent, testClass)));
}
return Optional.empty();
}));
}
return unresolved();
}
Aggregations