From 85a300c29ec14bd239f1c474c2258aef3f7cfd47 Mon Sep 17 00:00:00 2001 From: Marc Philipp Date: Thu, 16 May 2024 17:19:36 +0200 Subject: [PATCH] Polish test --- .../launcher/TestIdentifierTests.java | 73 +++---------------- 1 file changed, 9 insertions(+), 64 deletions(-) diff --git a/platform-tests/src/test/java/org/junit/platform/launcher/TestIdentifierTests.java b/platform-tests/src/test/java/org/junit/platform/launcher/TestIdentifierTests.java index 3be24b6d02ea..7ba6716495e6 100644 --- a/platform-tests/src/test/java/org/junit/platform/launcher/TestIdentifierTests.java +++ b/platform-tests/src/test/java/org/junit/platform/launcher/TestIdentifierTests.java @@ -16,12 +16,10 @@ import static org.junit.platform.commons.util.SerializationUtils.deserialize; import static org.junit.platform.commons.util.SerializationUtils.serialize; -import java.util.Optional; import java.util.Set; import org.junit.jupiter.api.Test; import org.junit.platform.engine.TestDescriptor; -import org.junit.platform.engine.TestSource; import org.junit.platform.engine.TestTag; import org.junit.platform.engine.UniqueId; import org.junit.platform.engine.support.descriptor.AbstractTestDescriptor; @@ -76,70 +74,17 @@ void initialVersionCanBeDeserialized() throws Exception { @Test void identifierWithNoParentCanBeSerializedAndDeserialized() throws Exception { - TestIdentifier ti = TestIdentifier.from(new TestDescriptor() { - @Override - public UniqueId getUniqueId() { - return UniqueId.root("example", "id"); - } - - @Override - public String getDisplayName() { - return "displayName"; - } - - @Override - public Set getTags() { - return Set.of(); - } - - @Override - public Optional getSource() { - return Optional.empty(); - } - - @Override - public Optional getParent() { - return Optional.empty(); - } - - @Override - public void setParent(TestDescriptor parent) { - // ignore - } - - @Override - public Set getChildren() { - return Set.of(); - } - - @Override - public void addChild(TestDescriptor descriptor) { - // ignore - } + TestIdentifier originalIdentifier = TestIdentifier.from( + new AbstractTestDescriptor(UniqueId.root("example", "id"), "Example") { + @Override + public Type getType() { + return Type.CONTAINER; + } + }); - @Override - public void removeChild(TestDescriptor descriptor) { - // ignore - } - - @Override - public void removeFromHierarchy() { - // ignore - } - - @Override - public Type getType() { - return Type.TEST; - } + var deserializedIdentifier = (TestIdentifier) deserialize(serialize(originalIdentifier)); - @Override - public Optional findByUniqueId(UniqueId uniqueId) { - return Optional.empty(); - } - }); - byte[] bytes = serialize(ti); - TestIdentifier dti = (TestIdentifier) deserialize(bytes); - assertEquals(ti, dti); + assertDeepEquals(originalIdentifier, deserializedIdentifier); } private static void assertDeepEquals(TestIdentifier first, TestIdentifier second) {