diff --git a/operator/src/test/java/org/bf2/operator/controllers/ManagedKafkaAgentControllerTest.java b/operator/src/test/java/org/bf2/operator/controllers/ManagedKafkaAgentControllerTest.java index 3aaf162df..1c4f853f8 100644 --- a/operator/src/test/java/org/bf2/operator/controllers/ManagedKafkaAgentControllerTest.java +++ b/operator/src/test/java/org/bf2/operator/controllers/ManagedKafkaAgentControllerTest.java @@ -1,8 +1,7 @@ package org.bf2.operator.controllers; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.common.ManagedKafkaAgentResourceClient; import org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent; import org.junit.jupiter.api.Test; @@ -12,7 +11,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest public class ManagedKafkaAgentControllerTest { diff --git a/operator/src/test/java/org/bf2/operator/controllers/ManagedKafkaControllerTest.java b/operator/src/test/java/org/bf2/operator/controllers/ManagedKafkaControllerTest.java index 9583a296d..ea17904cd 100644 --- a/operator/src/test/java/org/bf2/operator/controllers/ManagedKafkaControllerTest.java +++ b/operator/src/test/java/org/bf2/operator/controllers/ManagedKafkaControllerTest.java @@ -2,14 +2,12 @@ import io.fabric8.kubernetes.api.model.OwnerReferenceBuilder; import io.fabric8.kubernetes.api.model.ServiceBuilder; -import io.fabric8.kubernetes.client.Watcher; import io.fabric8.kubernetes.client.Watcher.Action; import io.javaoperatorsdk.operator.api.Context; import io.javaoperatorsdk.operator.processing.event.EventList; import io.javaoperatorsdk.operator.processing.event.internal.CustomResourceEvent; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.operator.events.ResourceEvent; import org.bf2.operator.resources.v1alpha1.ManagedKafka; import org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition; @@ -18,12 +16,12 @@ import javax.inject.Inject; -import java.util.Arrays; +import java.util.Collections; import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest public class ManagedKafkaControllerTest { @@ -34,13 +32,13 @@ public class ManagedKafkaControllerTest { void shouldCreateStatus() throws InterruptedException { ManagedKafka mk = ManagedKafka.getDummyInstance(1); mk.getMetadata().setUid(UUID.randomUUID().toString()); - mk.getMetadata().setGeneration(1l); + mk.getMetadata().setGeneration(1L); mk.getMetadata().setResourceVersion("1"); // create Context context = Mockito.mock(Context.class); Mockito.when(context.getEvents()) - .thenReturn(new EventList(Arrays.asList(new CustomResourceEvent(Action.ADDED, mk, null)))); + .thenReturn(new EventList(Collections.singletonList(new CustomResourceEvent(Action.ADDED, mk, null)))); mkController.createOrUpdateResource(mk, context); ManagedKafkaCondition condition = mk.getStatus().getConditions().get(0); @@ -51,11 +49,11 @@ void shouldCreateStatus() throws InterruptedException { // essentially there "last event" of the delete is something other than a deployment or a kafka // it should still trigger the update of the status Mockito.when(context.getEvents()) - .thenReturn(new EventList(Arrays.asList(new ResourceEvent<>(new ServiceBuilder() + .thenReturn(new EventList(Collections.singletonList(new ResourceEvent<>(new ServiceBuilder() .withNewMetadata() .withOwnerReferences(new OwnerReferenceBuilder().withUid(mk.getMetadata().getUid()).build()) .endMetadata() - .build(), null, Watcher.Action.DELETED)))); + .build(), null, Action.DELETED)))); mkController.createOrUpdateResource(mk, context); // should now be deleted diff --git a/operator/src/test/java/org/bf2/operator/managers/StrimziBundleManagerTest.java b/operator/src/test/java/org/bf2/operator/managers/StrimziBundleManagerTest.java index 85fd4d317..4218f3b50 100644 --- a/operator/src/test/java/org/bf2/operator/managers/StrimziBundleManagerTest.java +++ b/operator/src/test/java/org/bf2/operator/managers/StrimziBundleManagerTest.java @@ -21,9 +21,8 @@ import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder; import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionConditionBuilder; import io.fabric8.openshift.client.OpenShiftClient; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import io.strimzi.api.kafka.model.Kafka; import io.strimzi.api.kafka.model.KafkaBuilder; import org.bf2.operator.clients.KafkaResourceClient; @@ -38,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest public class StrimziBundleManagerTest { diff --git a/operator/src/test/java/org/bf2/operator/managers/StrimziManagerTest.java b/operator/src/test/java/org/bf2/operator/managers/StrimziManagerTest.java index 1ef12ef37..b8e71e66b 100644 --- a/operator/src/test/java/org/bf2/operator/managers/StrimziManagerTest.java +++ b/operator/src/test/java/org/bf2/operator/managers/StrimziManagerTest.java @@ -8,10 +8,9 @@ import io.fabric8.kubernetes.api.model.apps.ReplicaSetBuilder; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.server.mock.KubernetesServer; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; import io.quarkus.test.kubernetes.client.KubernetesTestServer; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import io.strimzi.api.kafka.model.Kafka; import io.strimzi.api.kafka.model.status.ConditionBuilder; import io.strimzi.api.kafka.model.status.KafkaStatusBuilder; @@ -35,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest public class StrimziManagerTest { diff --git a/operator/src/test/java/org/bf2/operator/operands/AdminServerTest.java b/operator/src/test/java/org/bf2/operator/operands/AdminServerTest.java index b44ccc599..59a1b68ec 100644 --- a/operator/src/test/java/org/bf2/operator/operands/AdminServerTest.java +++ b/operator/src/test/java/org/bf2/operator/operands/AdminServerTest.java @@ -3,10 +3,9 @@ import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.client.server.mock.KubernetesServer; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; import io.quarkus.test.kubernetes.client.KubernetesTestServer; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.operator.resources.v1alpha1.ManagedKafka; import org.bf2.operator.resources.v1alpha1.ManagedKafkaBuilder; import org.bf2.operator.resources.v1alpha1.ManagedKafkaSpecBuilder; @@ -16,7 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest public class AdminServerTest { diff --git a/operator/src/test/java/org/bf2/operator/operands/CanaryTest.java b/operator/src/test/java/org/bf2/operator/operands/CanaryTest.java index c6d2316a7..f09304ff9 100644 --- a/operator/src/test/java/org/bf2/operator/operands/CanaryTest.java +++ b/operator/src/test/java/org/bf2/operator/operands/CanaryTest.java @@ -3,10 +3,9 @@ import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.client.server.mock.KubernetesServer; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; import io.quarkus.test.kubernetes.client.KubernetesTestServer; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.operator.resources.v1alpha1.ManagedKafka; import org.bf2.operator.resources.v1alpha1.ManagedKafkaBuilder; import org.bf2.operator.resources.v1alpha1.ManagedKafkaSpecBuilder; @@ -16,7 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest public class CanaryTest { diff --git a/operator/src/test/java/org/bf2/operator/operands/KafkaClusterTest.java b/operator/src/test/java/org/bf2/operator/operands/KafkaClusterTest.java index ee6fbc869..115fb6d80 100644 --- a/operator/src/test/java/org/bf2/operator/operands/KafkaClusterTest.java +++ b/operator/src/test/java/org/bf2/operator/operands/KafkaClusterTest.java @@ -1,17 +1,14 @@ package org.bf2.operator.operands; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.utils.Serialization; import io.fabric8.zjsonpatch.JsonDiff; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusMock; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import io.strimzi.api.kafka.model.Kafka; import io.strimzi.api.kafka.model.KafkaBuilder; import io.strimzi.api.kafka.model.storage.JbodStorage; @@ -39,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest class KafkaClusterTest { @@ -147,7 +144,8 @@ void testKafkaInstanceConfigurationSerialization() throws IOException { assertEquals("zkfoo zkbar, zkfoo2 zkbar2", propertyMap.get("managedkafka.zookeeper.jvm-xx")); } - private JsonNode diffToExpected(Kafka kafka, String expected) throws IOException, JsonProcessingException, JsonMappingException { + + private JsonNode diffToExpected(Kafka kafka, String expected) throws IOException { ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); JsonNode file1 = objectMapper.readTree(KafkaClusterTest.class.getResourceAsStream(expected)); JsonNode file2 = objectMapper.readTree(Serialization.asYaml(kafka)); @@ -155,7 +153,7 @@ private JsonNode diffToExpected(Kafka kafka, String expected) throws IOException } @Test - void testDrainCleanerWebhookFound() throws IOException { + void testDrainCleanerWebhookFound() { DrainCleanerManager mock = Mockito.mock(DrainCleanerManager.class); Mockito.when(mock.isDrainCleanerWebhookFound()).thenReturn(true); QuarkusMock.installMockForType(mock, DrainCleanerManager.class); @@ -168,7 +166,7 @@ void testDrainCleanerWebhookFound() throws IOException { } @Test - void testDrainCleanerWebhookNotFound() throws IOException { + void testDrainCleanerWebhookNotFound() { DrainCleanerManager mock = Mockito.mock(DrainCleanerManager.class); Mockito.when(mock.isDrainCleanerWebhookFound()).thenReturn(false); QuarkusMock.installMockForType(mock, DrainCleanerManager.class); @@ -220,9 +218,9 @@ void testExistingStorageClassOverridesDontGetUpdated() { assertNull(((PersistentClaimStorage) reconciledKafka.getSpec().getZookeeper().getStorage()).getStorageClass()); assertEquals(buildStorageOverrides(), ((PersistentClaimStorage) reconciledKafka.getSpec().getZookeeper().getStorage()).getOverrides()); - ((JbodStorage)reconciledKafka.getSpec().getKafka().getStorage()).getVolumes().stream().forEach(v -> { - assertNull(((PersistentClaimStorage)v).getStorageClass()); - assertEquals(buildStorageOverrides(), ((PersistentClaimStorage)v).getOverrides()); + ((JbodStorage) reconciledKafka.getSpec().getKafka().getStorage()).getVolumes().forEach(v -> { + assertNull(((PersistentClaimStorage) v).getStorageClass()); + assertEquals(buildStorageOverrides(), ((PersistentClaimStorage) v).getOverrides()); }); } @@ -234,9 +232,9 @@ private List buildStorageOverrides() { for (int i = 0; i < num; i++) { overrides.add( new PersistentClaimStorageOverrideBuilder() - .withBroker(i) - .withStorageClass(storageClasses.get(i % storageClasses.size())) - .build()); + .withBroker(i) + .withStorageClass(storageClasses.get(i % storageClasses.size())) + .build()); } return overrides; } diff --git a/operator/src/test/java/org/bf2/operator/operands/KafkaInstanceTest.java b/operator/src/test/java/org/bf2/operator/operands/KafkaInstanceTest.java index eda3ca7e5..8e17f52ca 100644 --- a/operator/src/test/java/org/bf2/operator/operands/KafkaInstanceTest.java +++ b/operator/src/test/java/org/bf2/operator/operands/KafkaInstanceTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import java.io.IOException; import java.util.Arrays; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -15,7 +14,7 @@ public class KafkaInstanceTest { @Test - void testStatus() throws IOException { + void testStatus() { // sample operand readiness Operand error = mockOperand(new OperandReadiness(Status.False, Reason.Error, "I'm not well")); Operand installing = mockOperand(new OperandReadiness(Status.False, Reason.Installing, "I'm installing")); diff --git a/operator/src/test/java/org/bf2/operator/secrets/ImagePullSecretManagerTest.java b/operator/src/test/java/org/bf2/operator/secrets/ImagePullSecretManagerTest.java index 75dec1207..b6a10f17a 100644 --- a/operator/src/test/java/org/bf2/operator/secrets/ImagePullSecretManagerTest.java +++ b/operator/src/test/java/org/bf2/operator/secrets/ImagePullSecretManagerTest.java @@ -6,10 +6,9 @@ import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; import io.fabric8.kubernetes.client.KubernetesClient; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.common.OperandUtils; import org.bf2.operator.MockProfile; import org.bf2.operator.resources.v1alpha1.ManagedKafka; @@ -24,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @TestProfile(MockProfile.class) @QuarkusTest public class ImagePullSecretManagerTest { diff --git a/operator/src/test/java/org/bf2/operator/secrets/ObservabilityManagerTest.java b/operator/src/test/java/org/bf2/operator/secrets/ObservabilityManagerTest.java index 082b01a84..0e7d020eb 100644 --- a/operator/src/test/java/org/bf2/operator/secrets/ObservabilityManagerTest.java +++ b/operator/src/test/java/org/bf2/operator/secrets/ObservabilityManagerTest.java @@ -3,9 +3,8 @@ import io.fabric8.kubernetes.api.model.Secret; import io.fabric8.kubernetes.api.model.SecretBuilder; import io.fabric8.kubernetes.client.KubernetesClient; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.operator.resources.v1alpha1.ObservabilityConfiguration; import org.bf2.operator.resources.v1alpha1.ObservabilityConfigurationBuilder; import org.junit.jupiter.api.Test; @@ -19,7 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest public class ObservabilityManagerTest { diff --git a/sync/src/test/java/org/bf2/sync/AgentPollerTest.java b/sync/src/test/java/org/bf2/sync/AgentPollerTest.java index 9698563c9..2be25166a 100644 --- a/sync/src/test/java/org/bf2/sync/AgentPollerTest.java +++ b/sync/src/test/java/org/bf2/sync/AgentPollerTest.java @@ -1,10 +1,9 @@ package org.bf2.sync; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; import io.quarkus.test.junit.mockito.InjectMock; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.common.ManagedKafkaAgentResourceClient; import org.bf2.operator.resources.v1alpha1.ClusterCapacityBuilder; import org.bf2.operator.resources.v1alpha1.ManagedKafkaAgent; @@ -19,7 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest @TestProfile(MockSyncProfile.class) public class AgentPollerTest { diff --git a/sync/src/test/java/org/bf2/sync/PollerTest.java b/sync/src/test/java/org/bf2/sync/PollerTest.java index 330e9c14e..8550a322d 100644 --- a/sync/src/test/java/org/bf2/sync/PollerTest.java +++ b/sync/src/test/java/org/bf2/sync/PollerTest.java @@ -1,11 +1,10 @@ package org.bf2.sync; import io.fabric8.kubernetes.client.KubernetesClient; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; import io.quarkus.test.junit.mockito.InjectMock; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.common.ManagedKafkaResourceClient; import org.bf2.operator.resources.v1alpha1.ManagedKafka; import org.bf2.operator.resources.v1alpha1.ManagedKafkaList; @@ -31,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest @TestProfile(MockSyncProfile.class) public class PollerTest { diff --git a/sync/src/test/java/org/bf2/sync/UpdateTest.java b/sync/src/test/java/org/bf2/sync/UpdateTest.java index 2b0e5e2d4..da71a853a 100644 --- a/sync/src/test/java/org/bf2/sync/UpdateTest.java +++ b/sync/src/test/java/org/bf2/sync/UpdateTest.java @@ -1,10 +1,9 @@ package org.bf2.sync; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; import io.quarkus.test.junit.mockito.InjectMock; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.bf2.common.ManagedKafkaResourceClient; import org.bf2.operator.resources.v1alpha1.ManagedKafka; import org.bf2.operator.resources.v1alpha1.ManagedKafkaStatus; @@ -23,7 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer @QuarkusTest @TestProfile(MockSyncProfile.class) public class UpdateTest { diff --git a/systemtest/src/test/java/org/bf2/systemtest/unit/SuiteUnitTest.java b/systemtest/src/test/java/org/bf2/systemtest/unit/SuiteUnitTest.java index a4e66b4a2..b801fffe3 100644 --- a/systemtest/src/test/java/org/bf2/systemtest/unit/SuiteUnitTest.java +++ b/systemtest/src/test/java/org/bf2/systemtest/unit/SuiteUnitTest.java @@ -8,10 +8,9 @@ import io.fabric8.kubernetes.api.model.Secret; import io.fabric8.kubernetes.api.model.SecretBuilder; import io.fabric8.kubernetes.client.server.mock.KubernetesServer; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.kubernetes.client.KubernetesServerTestResource; import io.quarkus.test.kubernetes.client.KubernetesTestServer; +import io.quarkus.test.kubernetes.client.WithKubernetesTestServer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.bf2.systemtest.framework.KeycloakInstance; @@ -41,7 +40,7 @@ * Tests for verifying that test suite is not broken and basic functionality is working properly */ @QuarkusTest -@QuarkusTestResource(KubernetesServerTestResource.class) +@WithKubernetesTestServer public class SuiteUnitTest extends AbstractST { private static final Logger LOGGER = LogManager.getLogger(SuiteUnitTest.class); private static final String TEST_NS = "default";