Skip to content

Commit

Permalink
Improve readability by renaming/extracting methods
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Sep 25, 2024
1 parent 8491772 commit c29dbb2
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,21 @@ public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext conte
context.getExtensionRegistry());
AtomicInteger invocationIndex = new AtomicInteger();
for (TestTemplateInvocationContextProvider provider : providers) {
try (Stream<TestTemplateInvocationContext> stream = provider.provideTestTemplateInvocationContexts(
extensionContext)) {
stream.forEach(invocationContext -> createInvocationTestDescriptor(invocationContext,
invocationIndex.incrementAndGet()).ifPresent(
invocationTestDescriptor -> execute(dynamicTestExecutor, invocationTestDescriptor)));
try (Stream<TestTemplateInvocationContext> stream = invocationContexts(provider, extensionContext)) {
stream.forEach(
invocationContext -> toTestDescriptor(invocationContext, invocationIndex.incrementAndGet()) //
.ifPresent(testDescriptor -> execute(dynamicTestExecutor, testDescriptor)));
}
}
validateWasAtLeastInvokedOnce(invocationIndex.get(), providers);
return context;
}

private static Stream<TestTemplateInvocationContext> invocationContexts(
TestTemplateInvocationContextProvider provider, ExtensionContext extensionContext) {
return provider.provideTestTemplateInvocationContexts(extensionContext);
}

private List<TestTemplateInvocationContextProvider> validateProviders(ExtensionContext extensionContext,
ExtensionRegistry extensionRegistry) {

Expand All @@ -127,8 +131,7 @@ private List<TestTemplateInvocationContextProvider> validateProviders(ExtensionC
TestTemplateInvocationContextProvider.class.getSimpleName(), getTestMethod()));
}

private Optional<TestDescriptor> createInvocationTestDescriptor(TestTemplateInvocationContext invocationContext,
int index) {
private Optional<TestDescriptor> toTestDescriptor(TestTemplateInvocationContext invocationContext, int index) {
UniqueId uniqueId = getUniqueId().append(TestTemplateInvocationTestDescriptor.SEGMENT_TYPE, "#" + index);
if (getDynamicDescendantFilter().test(uniqueId, index - 1)) {
return Optional.of(new TestTemplateInvocationTestDescriptor(uniqueId, getTestClass(), getTestMethod(),
Expand Down

0 comments on commit c29dbb2

Please sign in to comment.