private Deque<Description> determinePath(RunnerTestDescriptor runnerTestDescriptor, Optional<? extends TestDescriptor> identifiedTestDescriptor) { Deque<Description> path = new ArrayDeque<>(); Optional<? extends TestDescriptor> current = identifiedTestDescriptor; while (current.isPresent() && !current.get().equals(runnerTestDescriptor)) { path.addFirst(((VintageTestDescriptor) current.get()).getDescription()); current = current.get().getParent(); } return path; }
private void fireExecutionFinishedIncludingAncestorsWithoutPendingChildren(Optional<TestDescriptor> parent) { if (parent.isPresent() && canFinish(parent.get())) { fireExecutionFinished(parent.get()); fireExecutionFinishedIncludingAncestorsWithoutPendingChildren(parent.get().getParent()); } }
private void fireExecutionStartedIncludingUnstartedAncestors(Optional<TestDescriptor> parent) { if (parent.isPresent() && canStart(parent.get())) { fireExecutionStartedIncludingUnstartedAncestors(parent.get().getParent()); fireExecutionStarted(parent.get()); } }
private void testFinished(TestDescriptor descriptor) { fireExecutionFinished(descriptor); fireExecutionFinishedIncludingAncestorsWithoutPendingChildren(descriptor.getParent()); }
private void dynamicTestRegistered(TestDescriptor testDescriptor) { fireExecutionStartedIncludingUnstartedAncestors(testDescriptor.getParent()); listener.dynamicTestRegistered(testDescriptor); }
private void testStarted(TestDescriptor testDescriptor) { fireExecutionStartedIncludingUnstartedAncestors(testDescriptor.getParent()); fireExecutionStarted(testDescriptor); }
/** * Determine if this descriptor is a <em>root</em> descriptor. * * <p>A <em>root</em> descriptor is a descriptor without a parent. */ default boolean isRoot() { return !getParent().isPresent(); }
Optional<ExecutionMode> getForcedExecutionMode(TestDescriptor testDescriptor) { return testDescriptor.getParent().flatMap(this::lookupExecutionModeForcedByAncestor); }
private Optional<ExecutionMode> lookupExecutionModeForcedByAncestor(TestDescriptor testDescriptor) { ExecutionMode value = forcedDescendantExecutionModeByTestDescriptor.get(testDescriptor); if (value != null) { return Optional.of(value); } return testDescriptor.getParent().flatMap(this::lookupExecutionModeForcedByAncestor); }
private void notifyFinishedRecursively(TestDescriptor descriptor, Consumer<TestDescriptor> visitor) { Optional<TestDescriptor> parent = descriptor.getParent(); while (parent.isPresent()) { TestDescriptor actualParent = parent.get(); AtomicInteger integer = expectedContainerCount.computeIfAbsent(actualParent, it -> { AtomicInteger childCount = new AtomicInteger(0); it.accept(item -> { if (item instanceof BenchmarkMethodDescriptor || item instanceof BenchmarkFixtureDescriptor) { childCount.incrementAndGet(); } }); return childCount; }); if (integer.decrementAndGet() == 0) { visitor.accept(actualParent); } parent = actualParent.getParent(); } }
private Predicate<TestDescriptor> isChildOf(Predicate<TestDescriptor> parentPredicate) { return descriptor -> descriptor.getParent().map(parentPredicate::test).orElse(false); }