diff --git a/api/client-testextension/src/main/java/org/projectnessie/client/ext/NessieClientResolver.java b/api/client-testextension/src/main/java/org/projectnessie/client/ext/NessieClientResolver.java index 13741d1c7aa..c8ecd617294 100644 --- a/api/client-testextension/src/main/java/org/projectnessie/client/ext/NessieClientResolver.java +++ b/api/client-testextension/src/main/java/org/projectnessie/client/ext/NessieClientResolver.java @@ -19,6 +19,9 @@ import java.io.Serializable; import java.net.URI; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ParameterContext; @@ -88,7 +91,16 @@ public Object resolveParameter( private NessieClientFactory clientFactoryForContext(ExtensionContext extensionContext) { NessieApiVersion apiVersion = apiVersion(extensionContext); URI uri = resolvedNessieUri(extensionContext); - Object testInstance = extensionContext.getTestInstance().orElse(null); + List customizers = + extensionContext + .getTestInstances() + .map( + i -> + i.getAllInstances().stream() + .filter(ti -> ti instanceof NessieClientCustomizer) + .map(ti -> (NessieClientCustomizer) ti) + .collect(Collectors.toList())) + .orElse(Collections.emptyList()); Class responseFactoryClass = extensionContext @@ -97,8 +109,15 @@ private NessieClientFactory clientFactoryForContext(ExtensionContext extensionCo .map(NessieClientResponseFactory::value) .orElse(null); - if (testInstance instanceof NessieClientCustomizer) { - NessieClientCustomizer testCustomizer = (NessieClientCustomizer) testInstance; + if (!customizers.isEmpty()) { + NessieClientCustomizer testCustomizer = + (builder, version) -> { + for (NessieClientCustomizer customizer : customizers) { + builder = customizer.configure(builder, version); + } + return builder; + }; + return new ClientFactory(uri, apiVersion, responseFactoryClass) { @Nonnull @jakarta.annotation.Nonnull