use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class JavaElementsResolver method resolveAllSegments.
/**
* Attempt to resolve all segments for the supplied unique ID.
*/
private Deque<TestDescriptor> resolveAllSegments(UniqueId uniqueId) {
List<Segment> segments = uniqueId.getSegments();
Deque<TestDescriptor> resolvedDescriptors = new LinkedList<>();
resolvedDescriptors.addFirst(this.engineDescriptor);
for (int index = 1; index < segments.size() && resolvedDescriptors.size() == index; index++) {
Segment segment = segments.get(index);
TestDescriptor parent = resolvedDescriptors.getLast();
UniqueId partialUniqueId = parent.getUniqueId().append(segment);
Optional<TestDescriptor> resolvedDescriptor = findTestDescriptorByUniqueId(partialUniqueId);
if (!resolvedDescriptor.isPresent()) {
// @formatter:off
resolvedDescriptor = this.resolvers.stream().map(resolver -> resolver.resolveUniqueId(segment, parent)).filter(Optional::isPresent).map(Optional::get).findFirst();
// @formatter:on
resolvedDescriptor.ifPresent(parent::addChild);
}
resolvedDescriptor.ifPresent(resolvedDescriptors::addLast);
}
return resolvedDescriptors;
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class TestContainerResolver method resolveElement.
@Override
public Set<TestDescriptor> resolveElement(AnnotatedElement element, TestDescriptor parent) {
if (!(element instanceof Class)) {
return Collections.emptySet();
}
Class<?> clazz = (Class<?>) element;
if (!isPotentialCandidate(clazz)) {
return Collections.emptySet();
}
UniqueId uniqueId = createUniqueId(clazz, parent);
return Collections.singleton(resolveClass(clazz, uniqueId));
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class UniqueIdSelectorResolverTests method logsWarningOnUnexpectedTestDescriptor.
@Test
void logsWarningOnUnexpectedTestDescriptor(LogRecordListener listener) {
UniqueId uniqueId = UniqueId.forEngine(ENGINE_ID).append("wrong-type", "foo:bar");
EngineDiscoveryRequest request = requestWithSelector(selectUniqueId(uniqueId));
new UniqueIdSelectorResolver().resolve(request, allClassesPredicate, collector);
assertNoRequests();
assertLoggedWarning(listener, "Unresolvable Unique ID (" + uniqueId + "): Unique ID segment after engine segment must be of type \"runner\"");
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class UniqueIdSelectorResolverTests method ignoresUniqueIdsOfOtherEngines.
@Test
void ignoresUniqueIdsOfOtherEngines(LogRecordListener listener) {
UniqueId uniqueId = UniqueId.forEngine("someEngine");
EngineDiscoveryRequest request = requestWithSelector(selectUniqueId(uniqueId));
new UniqueIdSelectorResolver().resolve(request, allClassesPredicate, collector);
assertNoRequests();
assertThat(listener.stream(UniqueIdSelectorResolver.class)).isEmpty();
}
use of org.junit.platform.engine.UniqueId in project junit5 by junit-team.
the class UniqueIdSelectorResolverTests method logsWarningOnUnloadableTestClass.
@Test
void logsWarningOnUnloadableTestClass(LogRecordListener listener) {
UniqueId uniqueId = VintageUniqueIdBuilder.uniqueIdForClass("foo.bar.UnknownClass");
EngineDiscoveryRequest request = requestWithSelector(selectUniqueId(uniqueId));
new UniqueIdSelectorResolver().resolve(request, allClassesPredicate, collector);
assertNoRequests();
assertLoggedWarning(listener, "Unresolvable Unique ID (" + uniqueId + "): Unknown class foo.bar.UnknownClass");
}
Aggregations