Java Code Examples for org.junit.platform.engine.UniqueId#Segment
The following examples show how to use
org.junit.platform.engine.UniqueId#Segment .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskName.java From sbt-jupiter-interface with Apache License 2.0 | 6 votes |
/** * * @param id The unique test identifier. * @return A string representation of the current invocation (might be {@code null}). */ static String invocation(UniqueId id) { List<UniqueId.Segment> segments = id.getSegments(); if (!segments.isEmpty()) { UniqueId.Segment last = segments.get(segments.size() - 1); switch (last.getType()) { case "dynamic-test": case "test-template-invocation": return last.getValue().replace("#", ""); } } return null; }
Example 2
Source File: ElementResolver.java From ArchUnit with Apache License 2.0 | 5 votes |
PossiblyResolvedClass resolveClass() { UniqueId.Segment nextSegment = checkNotNull(segmentsToResolve.peekFirst()); if (!CLASS_SEGMENT_TYPE.equals(nextSegment.getType())) { return new ClassNotRequested(); } return tryResolveClass(classOf(nextSegment), processedId.append(nextSegment)); }
Example 3
Source File: ElementResolver.java From ArchUnit with Apache License 2.0 | 5 votes |
@MayResolveTypesViaReflection(reason = "Within the ArchUnitTestEngine we may resolve types via reflection, since they are needed anyway") private Class<?> classOf(UniqueId.Segment segment) { try { return Class.forName(segment.getValue()); } catch (ClassNotFoundException e) { throw new ArchTestInitializationException(e, "Failed to load class from %s segment %s", UniqueId.class.getSimpleName(), segment); } }
Example 4
Source File: ElementResolver.java From ArchUnit with Apache License 2.0 | 5 votes |
private static Deque<UniqueId.Segment> getRemainingSegments(UniqueId rootId, UniqueId targetId) { Deque<UniqueId.Segment> remainingSegments = new LinkedList<>(targetId.getSegments()); rootId.getSegments().forEach(segment -> { checkState(segment.equals(remainingSegments.peekFirst()), "targetId %s should start with rootId %s", targetId, rootId); remainingSegments.pollFirst(); }); return remainingSegments; }
Example 5
Source File: ElementResolver.java From ArchUnit with Apache License 2.0 | 4 votes |
private ElementResolver(ArchUnitEngineDescriptor engineDescriptor, UniqueId processedId, Deque<UniqueId.Segment> segmentsToResolve) { this.engineDescriptor = checkNotNull(engineDescriptor); this.processedId = checkNotNull(processedId); this.segmentsToResolve = checkNotNull(segmentsToResolve); }
Example 6
Source File: ElementResolver.java From ArchUnit with Apache License 2.0 | 4 votes |
private Deque<UniqueId.Segment> tail(Deque<UniqueId.Segment> segmentsToResolve) { LinkedList<UniqueId.Segment> result = new LinkedList<>(segmentsToResolve); result.pollFirst(); return result; }
Example 7
Source File: ElementResolver.java From ArchUnit with Apache License 2.0 | 4 votes |
private void handleRequestedSegment(String segmentType, String segmentValue, Consumer<ElementResolver> doIfResolved) { UniqueId.Segment nextSegment = checkNotNull(segmentsToResolve.peekFirst()); if (matches(segmentType, segmentValue).test(nextSegment)) { doIfResolved.accept(new ElementResolver(engineDescriptor, processedId.append(nextSegment), tail(segmentsToResolve))); } }
Example 8
Source File: ElementResolver.java From ArchUnit with Apache License 2.0 | 4 votes |
private Predicate<UniqueId.Segment> matches(String segmentType, String segmentValue) { return nextSegment -> nextSegment.getType().equals(segmentType) && nextSegment.getValue().equals(segmentValue); }