Search in sources :

Example 1 with Type

use of org.junit.platform.engine.TestDescriptor.Type 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)

Aggregations

Serializable (java.io.Serializable)1 Collections.unmodifiableSet (java.util.Collections.unmodifiableSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 API (org.apiguardian.api.API)1 INTERNAL (org.apiguardian.api.API.Status.INTERNAL)1 STABLE (org.apiguardian.api.API.Status.STABLE)1 Preconditions (org.junit.platform.commons.util.Preconditions)1 ToStringBuilder (org.junit.platform.commons.util.ToStringBuilder)1 TestDescriptor (org.junit.platform.engine.TestDescriptor)1 Type (org.junit.platform.engine.TestDescriptor.Type)1 TestSource (org.junit.platform.engine.TestSource)1 TestTag (org.junit.platform.engine.TestTag)1