Search in sources :

Example 1 with Visitor

use of org.junit.platform.engine.TestDescriptor.Visitor in project junit5 by junit-team.

the class TestPlan method from.

/**
 * Construct a new {@code TestPlan} from the supplied collection of
 * {@link TestDescriptor TestDescriptors}.
 *
 * <p>Each supplied {@code TestDescriptor} is expected to be a descriptor
 * for a {@link org.junit.platform.engine.TestEngine TestEngine}.
 *
 * @param engineDescriptors the engine test descriptors from which the test
 * plan should be created; never {@code null}
 * @return a new test plan
 */
@API(status = INTERNAL, since = "1.0")
public static TestPlan from(Collection<TestDescriptor> engineDescriptors) {
    Preconditions.notNull(engineDescriptors, "Cannot create TestPlan from a null collection of TestDescriptors");
    TestPlan testPlan = new TestPlan(engineDescriptors.stream().anyMatch(TestDescriptor::containsTests));
    Visitor visitor = descriptor -> testPlan.add(TestIdentifier.from(descriptor));
    engineDescriptors.forEach(engineDescriptor -> engineDescriptor.accept(visitor));
    return testPlan;
}
Also used : Preconditions(org.junit.platform.commons.util.Preconditions) Collections.emptySet(java.util.Collections.emptySet) Visitor(org.junit.platform.engine.TestDescriptor.Visitor) Predicate(java.util.function.Predicate) Collection(java.util.Collection) STABLE(org.apiguardian.api.API.Status.STABLE) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) API(org.apiguardian.api.API) INTERNAL(org.apiguardian.api.API.Status.INTERNAL) PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Collections.unmodifiableSet(java.util.Collections.unmodifiableSet) Map(java.util.Map) Optional(java.util.Optional) TestDescriptor(org.junit.platform.engine.TestDescriptor) Collections(java.util.Collections) LinkedHashSet(java.util.LinkedHashSet) Visitor(org.junit.platform.engine.TestDescriptor.Visitor) API(org.apiguardian.api.API)

Aggregations

Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.emptySet (java.util.Collections.emptySet)1 Collections.unmodifiableSet (java.util.Collections.unmodifiableSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Predicate (java.util.function.Predicate)1 API (org.apiguardian.api.API)1 INTERNAL (org.apiguardian.api.API.Status.INTERNAL)1 STABLE (org.apiguardian.api.API.Status.STABLE)1 PreconditionViolationException (org.junit.platform.commons.util.PreconditionViolationException)1 Preconditions (org.junit.platform.commons.util.Preconditions)1 TestDescriptor (org.junit.platform.engine.TestDescriptor)1 Visitor (org.junit.platform.engine.TestDescriptor.Visitor)1