From 7d0bd0f51adcbe2f89147862557cba890dc1017c Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 21 Dec 2022 14:38:51 +0100 Subject: [PATCH] Bump Dekorate to 3.2.0 Release changes: https://github.com/dekorateio/dekorate/releases/tag/3.2.0 Fix: https://github.com/quarkusio/quarkus/issues/29962 Relates: https://github.com/quarkusio/quarkus/pull/29807 --- bom/application/pom.xml | 2 +- .../KubernetesWithAutoMongoBindingTest.java | 45 +++++++++++-------- .../KubernetesWithAutoMysqlBindingTest.java | 45 +++++++++++-------- ...KubernetesWithAutoPostgresBindingTest.java | 45 +++++++++++-------- ...rnetesWithSemiAutoPostgresBindingTest.java | 45 +++++++++++-------- .../KubernetesWithServiceBindingTest.java | 45 +++++++++++-------- .../OpenshiftWithServiceBindingTest.java | 45 +++++++++++-------- 7 files changed, 163 insertions(+), 109 deletions(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index ceb89a88f78ff..6667ed1ec2a0c 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -156,7 +156,7 @@ 1.6.4 1.4.1 6.3.1 - 3.1.3 + 3.2.0 3.2.0 4.2.0 1.0.11 diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoMongoBindingTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoMongoBindingTest.java index 3eaf48a95541c..93c5aafb9b8a0 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoMongoBindingTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoMongoBindingTest.java @@ -6,11 +6,10 @@ import java.nio.file.Path; import java.util.List; -import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.dekorate.servicebinding.model.ServiceBinding; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.quarkus.builder.Version; @@ -21,12 +20,14 @@ public class KubernetesWithAutoMongoBindingTest { + private static final String APP_NAME = "kubernetes-with-auto-mongo-binding"; + @RegisterExtension static final QuarkusProdModeTest config = new QuarkusProdModeTest() .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) - .setApplicationName("kubernetes-with-auto-mogno-binding") + .setApplicationName(APP_NAME) .setApplicationVersion("0.1-SNAPSHOT") - .withConfigurationResource("kubernetes-with-auto-mongo-binding.properties") + .withConfigurationResource(APP_NAME + ".properties") .setLogFileName("k8s.log") .setForcedDependencies(List.of( Dependency.of("io.quarkus", "quarkus-mongodb-client", Version.getVersion()), @@ -48,7 +49,7 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(i -> "Deployment".equals(i.getKind())).singleElement().satisfies(i -> { assertThat(i).isInstanceOfSatisfying(Deployment.class, d -> { assertThat(d.getMetadata()).satisfies(m -> { - assertThat(m.getName()).isEqualTo("kubernetes-with-auto-mogno-binding"); + assertThat(m.getName()).isEqualTo(APP_NAME); }); assertThat(d.getSpec()).satisfies(deploymentSpec -> { assertThat(deploymentSpec.getTemplate()).satisfies(t -> { @@ -59,18 +60,26 @@ public void assertGeneratedResources() throws IOException { }); }); - assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement() - .isInstanceOfSatisfying(GenericKubernetesResource.class, sb -> assertThat(sb) - .hasFieldOrPropertyWithValue("metadata.name", "kubernetes-with-auto-mogno-binding-mongodb") - .returns("apps", s -> s.get("spec", "application", "group")) - .returns("v1", s -> s.get("spec", "application", "version")) - .returns("Deployment", s -> s.get("spec", "application", "kind")) - .extracting(s -> s.get("spec", "services")) - .asList() - .singleElement().asInstanceOf(InstanceOfAssertFactories.MAP) - .containsEntry("group", "psmdb.percona.com") - .containsEntry("version", "v1-9-0") - .containsEntry("kind", "PerconaServerMongoDB") - .containsEntry("name", "mongodb")); + assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement().satisfies(i -> { + assertThat(i).isInstanceOfSatisfying(ServiceBinding.class, s -> { + assertThat(s.getMetadata()).satisfies(m -> { + assertThat(m.getName()).isEqualTo(APP_NAME + "-mongodb"); + }); + assertThat(s.getSpec()).satisfies(spec -> { + assertThat(spec.getApplication()).satisfies(a -> { + assertThat(a.getGroup()).isEqualTo("apps"); + assertThat(a.getVersion()).isEqualTo("v1"); + assertThat(a.getKind()).isEqualTo("Deployment"); + }); + + assertThat(spec.getServices()).hasOnlyOneElementSatisfying(service -> { + assertThat(service.getGroup()).isEqualTo("psmdb.percona.com"); + assertThat(service.getVersion()).isEqualTo("v1-9-0"); + assertThat(service.getKind()).isEqualTo("PerconaServerMongoDB"); + assertThat(service.getName()).isEqualTo("mongodb"); + }); + }); + }); + }); } } diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoMysqlBindingTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoMysqlBindingTest.java index a2d2fe8d727bb..110a747273aee 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoMysqlBindingTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoMysqlBindingTest.java @@ -6,11 +6,10 @@ import java.nio.file.Path; import java.util.List; -import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.dekorate.servicebinding.model.ServiceBinding; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.quarkus.builder.Version; @@ -21,12 +20,14 @@ public class KubernetesWithAutoMysqlBindingTest { + private static final String APP_NAME = "kubernetes-with-auto-mysql-binding"; + @RegisterExtension static final QuarkusProdModeTest config = new QuarkusProdModeTest() .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) - .setApplicationName("kubernetes-with-auto-mysql-binding") + .setApplicationName(APP_NAME) .setApplicationVersion("0.1-SNAPSHOT") - .withConfigurationResource("kubernetes-with-auto-mysql-binding.properties") + .withConfigurationResource(APP_NAME + ".properties") .setLogFileName("k8s.log") .setForcedDependencies(List.of( Dependency.of("io.quarkus", "quarkus-kubernetes", Version.getVersion()), @@ -49,7 +50,7 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(i -> "Deployment".equals(i.getKind())).singleElement().satisfies(i -> { assertThat(i).isInstanceOfSatisfying(Deployment.class, d -> { assertThat(d.getMetadata()).satisfies(m -> { - assertThat(m.getName()).isEqualTo("kubernetes-with-auto-mysql-binding"); + assertThat(m.getName()).isEqualTo(APP_NAME); }); assertThat(d.getSpec()).satisfies(deploymentSpec -> { assertThat(deploymentSpec.getTemplate()).satisfies(t -> { @@ -60,18 +61,26 @@ public void assertGeneratedResources() throws IOException { }); }); - assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement() - .isInstanceOfSatisfying(GenericKubernetesResource.class, sb -> assertThat(sb) - .hasFieldOrPropertyWithValue("metadata.name", "kubernetes-with-auto-mysql-binding-mysql") - .returns("apps", s -> s.get("spec", "application", "group")) - .returns("v1", s -> s.get("spec", "application", "version")) - .returns("Deployment", s -> s.get("spec", "application", "kind")) - .extracting(s -> s.get("spec", "services")) - .asList() - .singleElement().asInstanceOf(InstanceOfAssertFactories.MAP) - .containsEntry("group", "pxc.percona.com") - .containsEntry("version", "v1-9-0") - .containsEntry("kind", "PerconaXtraDBCluster") - .containsEntry("name", "mysql")); + assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement().satisfies(i -> { + assertThat(i).isInstanceOfSatisfying(ServiceBinding.class, s -> { + assertThat(s.getMetadata()).satisfies(m -> { + assertThat(m.getName()).isEqualTo(APP_NAME + "-mysql"); + }); + assertThat(s.getSpec()).satisfies(spec -> { + assertThat(spec.getApplication()).satisfies(a -> { + assertThat(a.getGroup()).isEqualTo("apps"); + assertThat(a.getVersion()).isEqualTo("v1"); + assertThat(a.getKind()).isEqualTo("Deployment"); + }); + + assertThat(spec.getServices()).hasOnlyOneElementSatisfying(service -> { + assertThat(service.getGroup()).isEqualTo("pxc.percona.com"); + assertThat(service.getVersion()).isEqualTo("v1-9-0"); + assertThat(service.getKind()).isEqualTo("PerconaXtraDBCluster"); + assertThat(service.getName()).isEqualTo("mysql"); + }); + }); + }); + }); } } diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoPostgresBindingTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoPostgresBindingTest.java index 74f88cf30e2cc..686365ee1df7a 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoPostgresBindingTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithAutoPostgresBindingTest.java @@ -6,11 +6,10 @@ import java.nio.file.Path; import java.util.List; -import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.dekorate.servicebinding.model.ServiceBinding; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.quarkus.builder.Version; @@ -21,12 +20,14 @@ public class KubernetesWithAutoPostgresBindingTest { + private static final String APP_NAME = "kubernetes-with-auto-postgres-binding"; + @RegisterExtension static final QuarkusProdModeTest config = new QuarkusProdModeTest() .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) - .setApplicationName("kubernetes-with-auto-postgres-binding") + .setApplicationName(APP_NAME) .setApplicationVersion("0.1-SNAPSHOT") - .withConfigurationResource("kubernetes-with-auto-postgres-binding.properties") + .withConfigurationResource(APP_NAME + ".properties") .setLogFileName("k8s.log") .setForcedDependencies(List.of( Dependency.of("io.quarkus", "quarkus-kubernetes", Version.getVersion()), @@ -49,7 +50,7 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(i -> "Deployment".equals(i.getKind())).singleElement().satisfies(i -> { assertThat(i).isInstanceOfSatisfying(Deployment.class, d -> { assertThat(d.getMetadata()).satisfies(m -> { - assertThat(m.getName()).isEqualTo("kubernetes-with-auto-postgres-binding"); + assertThat(m.getName()).isEqualTo(APP_NAME); }); assertThat(d.getSpec()).satisfies(deploymentSpec -> { assertThat(deploymentSpec.getTemplate()).satisfies(t -> { @@ -60,18 +61,26 @@ public void assertGeneratedResources() throws IOException { }); }); - assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement() - .isInstanceOfSatisfying(GenericKubernetesResource.class, sb -> assertThat(sb) - .hasFieldOrPropertyWithValue("metadata.name", "kubernetes-with-auto-postgres-binding-postgresql") - .returns("apps", s -> s.get("spec", "application", "group")) - .returns("v1", s -> s.get("spec", "application", "version")) - .returns("Deployment", s -> s.get("spec", "application", "kind")) - .extracting(s -> s.get("spec", "services")) - .asList() - .singleElement().asInstanceOf(InstanceOfAssertFactories.MAP) - .containsEntry("group", "postgres-operator.crunchydata.com") - .containsEntry("version", "v1beta1") - .containsEntry("kind", "PostgresCluster") - .containsEntry("name", "postgresql")); + assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement().satisfies(i -> { + assertThat(i).isInstanceOfSatisfying(ServiceBinding.class, s -> { + assertThat(s.getMetadata()).satisfies(m -> { + assertThat(m.getName()).isEqualTo(APP_NAME + "-postgresql"); + }); + assertThat(s.getSpec()).satisfies(spec -> { + assertThat(spec.getApplication()).satisfies(a -> { + assertThat(a.getGroup()).isEqualTo("apps"); + assertThat(a.getVersion()).isEqualTo("v1"); + assertThat(a.getKind()).isEqualTo("Deployment"); + }); + + assertThat(spec.getServices()).hasOnlyOneElementSatisfying(service -> { + assertThat(service.getGroup()).isEqualTo("postgres-operator.crunchydata.com"); + assertThat(service.getVersion()).isEqualTo("v1beta1"); + assertThat(service.getKind()).isEqualTo("PostgresCluster"); + assertThat(service.getName()).isEqualTo("postgresql"); + }); + }); + }); + }); } } diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithSemiAutoPostgresBindingTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithSemiAutoPostgresBindingTest.java index bcf5659dac518..42db3f78a2294 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithSemiAutoPostgresBindingTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithSemiAutoPostgresBindingTest.java @@ -6,11 +6,10 @@ import java.nio.file.Path; import java.util.List; -import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.dekorate.servicebinding.model.ServiceBinding; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.quarkus.builder.Version; @@ -21,12 +20,14 @@ public class KubernetesWithSemiAutoPostgresBindingTest { + private static final String APP_NAME = "kubernetes-with-semi-auto-postgres-binding"; + @RegisterExtension static final QuarkusProdModeTest config = new QuarkusProdModeTest() .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) - .setApplicationName("kubernetes-with-semi-auto-postgres-binding") + .setApplicationName(APP_NAME) .setApplicationVersion("0.1-SNAPSHOT") - .withConfigurationResource("kubernetes-with-semi-auto-postgres-binding.properties") + .withConfigurationResource(APP_NAME + ".properties") .setLogFileName("k8s.log") .setForcedDependencies(List.of( Dependency.of("io.quarkus", "quarkus-kubernetes", Version.getVersion()), @@ -49,7 +50,7 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(i -> "Deployment".equals(i.getKind())).singleElement().satisfies(i -> { assertThat(i).isInstanceOfSatisfying(Deployment.class, d -> { assertThat(d.getMetadata()).satisfies(m -> { - assertThat(m.getName()).isEqualTo("kubernetes-with-semi-auto-postgres-binding"); + assertThat(m.getName()).isEqualTo(APP_NAME); }); assertThat(d.getSpec()).satisfies(deploymentSpec -> { assertThat(deploymentSpec.getTemplate()).satisfies(t -> { @@ -60,18 +61,26 @@ public void assertGeneratedResources() throws IOException { }); }); - assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement() - .isInstanceOfSatisfying(GenericKubernetesResource.class, sb -> assertThat(sb) - .hasFieldOrPropertyWithValue("metadata.name", "kubernetes-with-semi-auto-postgres-binding-postgresql") - .returns("apps", s -> s.get("spec", "application", "group")) - .returns("v1", s -> s.get("spec", "application", "version")) - .returns("Deployment", s -> s.get("spec", "application", "kind")) - .extracting(s -> s.get("spec", "services")) - .asList() - .singleElement().asInstanceOf(InstanceOfAssertFactories.MAP) - .containsEntry("group", "my.custom-operator.com") - .containsEntry("version", "v1alpha1") - .containsEntry("kind", "Postgres") - .containsEntry("name", "postgresql")); + assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement().satisfies(i -> { + assertThat(i).isInstanceOfSatisfying(ServiceBinding.class, s -> { + assertThat(s.getMetadata()).satisfies(m -> { + assertThat(m.getName()).isEqualTo(APP_NAME + "-postgresql"); + }); + assertThat(s.getSpec()).satisfies(spec -> { + assertThat(spec.getApplication()).satisfies(a -> { + assertThat(a.getGroup()).isEqualTo("apps"); + assertThat(a.getVersion()).isEqualTo("v1"); + assertThat(a.getKind()).isEqualTo("Deployment"); + }); + + assertThat(spec.getServices()).hasOnlyOneElementSatisfying(service -> { + assertThat(service.getGroup()).isEqualTo("my.custom-operator.com"); + assertThat(service.getVersion()).isEqualTo("v1alpha1"); + assertThat(service.getKind()).isEqualTo("Postgres"); + assertThat(service.getName()).isEqualTo("postgresql"); + }); + }); + }); + }); } } diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithServiceBindingTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithServiceBindingTest.java index 0203d1ecc7199..ed8defbe17c7a 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithServiceBindingTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithServiceBindingTest.java @@ -7,11 +7,10 @@ import java.nio.file.Path; import java.util.List; -import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.dekorate.servicebinding.model.ServiceBinding; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.quarkus.builder.Version; @@ -22,12 +21,14 @@ public class KubernetesWithServiceBindingTest { + private static final String APP_NAME = "kubernetes-with-service-binding"; + @RegisterExtension static final QuarkusProdModeTest config = new QuarkusProdModeTest() .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) - .setApplicationName("kubernetes-with-service-binding") + .setApplicationName(APP_NAME) .setApplicationVersion("0.1-SNAPSHOT") - .withConfigurationResource("kubernetes-with-service-binding.properties") + .withConfigurationResource(APP_NAME + ".properties") .setLogFileName("k8s.log") .setForcedDependencies(List.of( Dependency.of("io.quarkus", "quarkus-kubernetes", Version.getVersion()), @@ -48,7 +49,7 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(i -> "Deployment".equals(i.getKind())).singleElement().satisfies(i -> { assertThat(i).isInstanceOfSatisfying(Deployment.class, d -> { assertThat(d.getMetadata()).satisfies(m -> { - assertThat(m.getName()).isEqualTo("kubernetes-with-service-binding"); + assertThat(m.getName()).isEqualTo(APP_NAME); }); assertThat(d.getSpec()).satisfies(deploymentSpec -> { assertThat(deploymentSpec.getTemplate()).satisfies(t -> { @@ -59,18 +60,26 @@ public void assertGeneratedResources() throws IOException { }); }); - assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement() - .isInstanceOfSatisfying(GenericKubernetesResource.class, sb -> assertThat(sb) - .hasFieldOrPropertyWithValue("metadata.name", "kubernetes-with-service-binding-my-db") - .returns("apps", s -> s.get("spec", "application", "group")) - .returns("v1", s -> s.get("spec", "application", "version")) - .returns("Deployment", s -> s.get("spec", "application", "kind")) - .extracting(s -> s.get("spec", "services")) - .asList() - .singleElement().asInstanceOf(InstanceOfAssertFactories.MAP) - .containsEntry("group", "apps") - .containsEntry("version", "v1") - .containsEntry("kind", "Deployment") - .containsEntry("name", "my-postgres")); + assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement().satisfies(i -> { + assertThat(i).isInstanceOfSatisfying(ServiceBinding.class, s -> { + assertThat(s.getMetadata()).satisfies(m -> { + assertThat(m.getName()).isEqualTo(APP_NAME + "-my-db"); + }); + assertThat(s.getSpec()).satisfies(spec -> { + assertThat(spec.getApplication()).satisfies(a -> { + assertThat(a.getGroup()).isEqualTo("apps"); + assertThat(a.getVersion()).isEqualTo("v1"); + assertThat(a.getKind()).isEqualTo("Deployment"); + }); + + assertThat(spec.getServices()).hasOnlyOneElementSatisfying(service -> { + assertThat(service.getGroup()).isEqualTo("apps"); + assertThat(service.getVersion()).isEqualTo("v1"); + assertThat(service.getKind()).isEqualTo("Deployment"); + assertThat(service.getName()).isEqualTo("my-postgres"); + }); + }); + }); + }); } } diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithServiceBindingTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithServiceBindingTest.java index 565bbb8ea2811..e5a65ebae4cea 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithServiceBindingTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/OpenshiftWithServiceBindingTest.java @@ -7,11 +7,10 @@ import java.nio.file.Path; import java.util.List; -import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import io.fabric8.kubernetes.api.model.GenericKubernetesResource; +import io.dekorate.servicebinding.model.ServiceBinding; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.openshift.api.model.DeploymentConfig; import io.quarkus.builder.Version; @@ -22,12 +21,14 @@ public class OpenshiftWithServiceBindingTest { + private static final String APP_NAME = "openshift-with-service-binding"; + @RegisterExtension static final QuarkusProdModeTest config = new QuarkusProdModeTest() .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) - .setApplicationName("openshift-with-service-binding") + .setApplicationName(APP_NAME) .setApplicationVersion("0.1-SNAPSHOT") - .withConfigurationResource("openshift-with-service-binding.properties") + .withConfigurationResource(APP_NAME + ".properties") .setLogFileName("k8s.log") .setForcedDependencies(List.of( Dependency.of("io.quarkus", "quarkus-openshift", Version.getVersion()), @@ -48,23 +49,31 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(i -> "DeploymentConfig".equals(i.getKind())).singleElement().satisfies(i -> { assertThat(i).isInstanceOfSatisfying(DeploymentConfig.class, d -> { assertThat(d.getMetadata()).satisfies(m -> { - assertThat(m.getName()).isEqualTo("openshift-with-service-binding"); + assertThat(m.getName()).isEqualTo(APP_NAME); }); }); }); - assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement() - .isInstanceOfSatisfying(GenericKubernetesResource.class, sb -> assertThat(sb) - .hasFieldOrPropertyWithValue("metadata.name", "openshift-with-service-binding-my-db") - .returns("apps.openshift.io", s -> s.get("spec", "application", "group")) - .returns("v1", s -> s.get("spec", "application", "version")) - .returns("DeploymentConfig", s -> s.get("spec", "application", "kind")) - .extracting(s -> s.get("spec", "services")) - .asList() - .singleElement().asInstanceOf(InstanceOfAssertFactories.MAP) - .containsEntry("group", "apps") - .containsEntry("version", "v1") - .containsEntry("kind", "Deployment") - .containsEntry("name", "my-postgres")); + assertThat(kubernetesList).filteredOn(i -> "ServiceBinding".equals(i.getKind())).singleElement().satisfies(i -> { + assertThat(i).isInstanceOfSatisfying(ServiceBinding.class, s -> { + assertThat(s.getMetadata()).satisfies(m -> { + assertThat(m.getName()).isEqualTo(APP_NAME + "-my-db"); + }); + assertThat(s.getSpec()).satisfies(spec -> { + assertThat(spec.getApplication()).satisfies(a -> { + assertThat(a.getGroup()).isEqualTo("apps.openshift.io"); + assertThat(a.getVersion()).isEqualTo("v1"); + assertThat(a.getKind()).isEqualTo("DeploymentConfig"); + }); + + assertThat(spec.getServices()).hasOnlyOneElementSatisfying(service -> { + assertThat(service.getGroup()).isEqualTo("apps"); + assertThat(service.getVersion()).isEqualTo("v1"); + assertThat(service.getKind()).isEqualTo("Deployment"); + assertThat(service.getName()).isEqualTo("my-postgres"); + }); + }); + }); + }); } }