Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that children of engine descriptors are runner descriptors
Fixes #337.
- Loading branch information
1 parent
b496fe4
commit 42d9dab
Showing
2 changed files
with
48 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -11,14 +11,16 @@ | ||
package org.junit.vintage.engine.discovery; | package org.junit.vintage.engine.discovery; | ||
|
|
||
import static java.lang.String.format; | import static java.lang.String.format; | ||
import static java.util.function.Predicate.isEqual; | |||
import static org.junit.vintage.engine.descriptor.VintageTestDescriptor.ENGINE_ID; | import static org.junit.vintage.engine.descriptor.VintageTestDescriptor.ENGINE_ID; | ||
import static org.junit.vintage.engine.descriptor.VintageTestDescriptor.SEGMENT_TYPE_RUNNER; | |||
|
|
||
import java.util.List; | |||
import java.util.Optional; | import java.util.Optional; | ||
import java.util.logging.Logger; | import java.util.logging.Logger; | ||
|
|
||
import org.junit.platform.commons.util.ReflectionUtils; | import org.junit.platform.commons.util.ReflectionUtils; | ||
import org.junit.platform.engine.UniqueId; | import org.junit.platform.engine.UniqueId; | ||
import org.junit.platform.engine.UniqueId.Segment; | |||
import org.junit.platform.engine.discovery.UniqueIdSelector; | import org.junit.platform.engine.discovery.UniqueIdSelector; | ||
|
|
||
/** | /** | ||
|
@@ -41,12 +43,9 @@ void resolve(UniqueIdSelector selector, TestClassCollector collector) { | ||
() -> format("Unresolvable Unique ID (%s): Cannot resolve the engine's unique ID", uniqueId)); | () -> format("Unresolvable Unique ID (%s): Cannot resolve the engine's unique ID", uniqueId)); | ||
} | } | ||
else { | else { | ||
uniqueId.getEngineId().ifPresent(engineId -> { | uniqueId.getEngineId().filter(isEqual(ENGINE_ID)).ifPresent( | ||
if (engineId.equals(ENGINE_ID)) { | engineId -> determineTestClassName(uniqueId).ifPresent( | ||
String testClassName = determineTestClassName(uniqueId); | testClassName -> resolveIntoFilteredTestClass(testClassName, uniqueId, collector))); | ||
resolveIntoFilteredTestClass(testClassName, uniqueId, collector); | |||
} | |||
}); | |||
} | } | ||
} | } | ||
|
|
||
|
@@ -60,12 +59,16 @@ private void resolveIntoFilteredTestClass(String testClassName, UniqueId uniqueI | ||
} | } | ||
} | } | ||
|
|
||
private String determineTestClassName(UniqueId uniqueId) { | private Optional<String> determineTestClassName(UniqueId uniqueId) { | ||
List<UniqueId.Segment> segments = uniqueId.getSegments(); | Segment runnerSegment = uniqueId.getSegments().get(1); // skip engine node | ||
segments.remove(0); // drop engine node | if (SEGMENT_TYPE_RUNNER.equals(runnerSegment.getType())) { | ||
UniqueId.Segment runnerSegment = segments.remove(0); | return Optional.of(runnerSegment.getValue()); | ||
// TODO [#337] Check that it really is a runner segment | } | ||
return runnerSegment.getValue(); | logger.warning( | ||
() -> format("Unresolvable Unique ID (%s): Unique ID segment after engine segment must be of type \"" | |||
+ SEGMENT_TYPE_RUNNER + "\"", | |||
uniqueId)); | |||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
marcphilipp
Author
Member
|
|||
return Optional.empty(); | |||
} | } | ||
|
|
||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ummmmm.... why did you use
String.format()
combined with String concatenation? 😜