From de927a16d8115a665a6ee46722d82d80f27160f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Thu, 3 Sep 2026 10:34:36 +0200 Subject: [PATCH] test: cover the remaining ConfigurationServiceOverrider settings overrideShouldWork asserted the informer stopped handler override against getLeaderElectionConfiguration(), so it passed whatever the overrider did with the handler, and set a resource cloner it never asserted. Fixes both, and adds coverage for withDependentResourceFactory and withDefaultNonSSAResource, neither of which was exercised anywhere. withDependentResourceFactory had no coverage at all: unlike the scalar setters, it is not reachable through a ConfigLoader binding, so operatorBindingsCoverAllSingleScalarSettersOnConfigurationServiceOverrider does not guard it either. --- .../ConfigurationServiceOverriderTest.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java index 9df62bc03c..01ff61ea30 100644 --- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java +++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverriderTest.java @@ -17,13 +17,17 @@ import java.time.Duration; import java.util.Optional; +import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; import org.junit.jupiter.api.Test; +import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.Secret; import io.javaoperatorsdk.operator.api.monitoring.Metrics; +import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResourceFactory; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -98,10 +102,10 @@ public R clone(R object) { assertNotEquals(config.getExecutorService(), overridden.getExecutorService()); assertNotEquals(config.getWorkflowExecutorService(), overridden.getWorkflowExecutorService()); assertNotEquals(config.getMetrics(), overridden.getMetrics()); + assertNotEquals(config.getResourceCloner(), overridden.getResourceCloner()); assertNotEquals( config.getLeaderElectionConfiguration(), overridden.getLeaderElectionConfiguration()); - assertNotEquals( - config.getInformerStoppedHandler(), overridden.getLeaderElectionConfiguration()); + assertNotEquals(config.getInformerStoppedHandler(), overridden.getInformerStoppedHandler()); assertNotEquals( config.reconciliationTerminationTimeout(), overridden.reconciliationTerminationTimeout()); } @@ -118,4 +122,30 @@ void threadCountConfiguredProperly() { assertThat(((ThreadPoolExecutor) overridden.getWorkflowExecutorService()).getMaximumPoolSize()) .isEqualTo(14); } + + @SuppressWarnings("rawtypes") + @Test + void dependentResourceFactoryDefaultsToTheSharedOneAndCanBeOverridden() { + final var factory = new DependentResourceFactory() {}; + + assertThat(config.dependentResourceFactory()).isSameAs(DependentResourceFactory.DEFAULT); + assertThat( + new ConfigurationServiceOverrider(config) + .withDependentResourceFactory(factory) + .build() + .dependentResourceFactory()) + .isSameAs(factory); + } + + @Test + void defaultNonSSAResourcesDefaultToConfigMapsAndSecretsAndCanBeOverridden() { + assertThat(config.defaultNonSSAResources()) + .containsExactlyInAnyOrder(ConfigMap.class, Secret.class); + assertThat( + new ConfigurationServiceOverrider(config) + .withDefaultNonSSAResource(Set.of()) + .build() + .defaultNonSSAResources()) + .isEmpty(); + } }