Search in sources :

Example 1 with INTERNAL

use of org.apiguardian.api.API.Status.INTERNAL in project junit5 by junit-team.

the class TestIdentifier method from.

/**
 * Factory for creating a new {@link TestIdentifier} from a {@link TestDescriptor}.
 */
@API(status = INTERNAL, since = "1.0")
public static TestIdentifier from(TestDescriptor testDescriptor) {
    Preconditions.notNull(testDescriptor, "TestDescriptor must not be null");
    String uniqueId = testDescriptor.getUniqueId().toString();
    String displayName = testDescriptor.getDisplayName();
    TestSource source = testDescriptor.getSource().orElse(null);
    Set<TestTag> tags = testDescriptor.getTags();
    Type type = testDescriptor.getType();
    String parentId = testDescriptor.getParent().map(parentDescriptor -> parentDescriptor.getUniqueId().toString()).orElse(null);
    String legacyReportingName = testDescriptor.getLegacyReportingName();
    return new TestIdentifier(uniqueId, displayName, source, tags, type, parentId, legacyReportingName);
}
Also used : Preconditions(org.junit.platform.commons.util.Preconditions) ToStringBuilder(org.junit.platform.commons.util.ToStringBuilder) STABLE(org.apiguardian.api.API.Status.STABLE) TestSource(org.junit.platform.engine.TestSource) Set(java.util.Set) API(org.apiguardian.api.API) INTERNAL(org.apiguardian.api.API.Status.INTERNAL) Serializable(java.io.Serializable) Objects(java.util.Objects) Collections.unmodifiableSet(java.util.Collections.unmodifiableSet) Type(org.junit.platform.engine.TestDescriptor.Type) Optional(java.util.Optional) TestTag(org.junit.platform.engine.TestTag) TestDescriptor(org.junit.platform.engine.TestDescriptor) LinkedHashSet(java.util.LinkedHashSet) Type(org.junit.platform.engine.TestDescriptor.Type) TestSource(org.junit.platform.engine.TestSource) TestTag(org.junit.platform.engine.TestTag) API(org.apiguardian.api.API)

Example 2 with INTERNAL

use of org.apiguardian.api.API.Status.INTERNAL 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

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