Skip to content

Commit

Permalink
fix: replace AssertJ's deprecated asList() DSL method in ControllerVi…
Browse files Browse the repository at this point in the history
…aPluginConfigurationEnricherTest (3289)

chore : replacing AssertJ's deprecated asList() DSL method with asInstanceOf(InstanceOfAssertFactories.list(type.class))

Signed-off-by: Aman <[email protected]>
---
chore : replacing AssertJ's deprecated asList() DSL method with asInstanceOf(InstanceOfAssertFactories.list(type.class))
  • Loading branch information
aizwal9 authored Aug 13, 2024
1 parent 2f1ac69 commit d0f7c62
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.jkube.enricher.generic;

import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.EnvVarBuilder;
import io.fabric8.kubernetes.api.model.KubernetesList;
import io.fabric8.kubernetes.api.model.KubernetesListBuilder;
Expand All @@ -26,6 +27,7 @@
import io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder;
import io.fabric8.kubernetes.api.model.apps.StatefulSetSpec;
import io.fabric8.openshift.api.model.DeploymentConfig;
import io.fabric8.openshift.api.model.DeploymentTriggerPolicy;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.eclipse.jkube.enricher.generic.openshift.DeploymentConfigEnricher;
import org.eclipse.jkube.enricher.generic.openshift.ImageChangeTriggerEnricher;
Expand Down Expand Up @@ -169,42 +171,42 @@ void enablesImageChangeTriggers() {
// Then
assertThat(kubernetesListBuilder.build().getItems()).asInstanceOf(InstanceOfAssertFactories.list(DeploymentConfig.class))
.singleElement()
.extracting("spec.triggers").asList().hasSize(2)
.extracting("spec.triggers").asInstanceOf(InstanceOfAssertFactories.list(DeploymentTriggerPolicy.class)).hasSize(2)
.extracting("type")
.containsExactlyInAnyOrder("ImageChange", "ConfigChange");
}

private void assertGeneratedListContainsDeploymentWithNameAndEnvVar(KubernetesListBuilder kubernetesListBuilder, String name) {
assertThat(kubernetesListBuilder.build())
.extracting(KubernetesList::getItems)
.asList()
.singleElement(InstanceOfAssertFactories.type(Deployment.class))
.asInstanceOf(InstanceOfAssertFactories.list(Deployment.class))
.singleElement()
.hasFieldOrPropertyWithValue("metadata.name", name)
.extracting(Deployment::getSpec)
.extracting(DeploymentSpec::getTemplate)
.extracting(PodTemplateSpec::getSpec)
.extracting(PodSpec::getContainers)
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(Container.class))
.first(InstanceOfAssertFactories.type(Container.class))
.extracting(Container::getEnv)
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(EnvVar.class))
.contains(new EnvVarBuilder().withName("FOO").withValue("bar").build());
}

private void assertGeneratedListContainsStatefulSetWithNameAndEnvVar(KubernetesListBuilder kubernetesListBuilder, String name) {
assertThat(kubernetesListBuilder.build())
.extracting(KubernetesList::getItems)
.asList()
.singleElement(InstanceOfAssertFactories.type(StatefulSet.class))
.asInstanceOf(InstanceOfAssertFactories.list(StatefulSet.class))
.singleElement()
.hasFieldOrPropertyWithValue("metadata.name", name)
.extracting(StatefulSet::getSpec)
.extracting(StatefulSetSpec::getTemplate)
.extracting(PodTemplateSpec::getSpec)
.extracting(PodSpec::getContainers)
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(Container.class))
.first(InstanceOfAssertFactories.type(Container.class))
.extracting(Container::getEnv)
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(EnvVar.class))
.contains(new EnvVarBuilder().withName("FOO").withValue("bar").build());
}

Expand Down

0 comments on commit d0f7c62

Please sign in to comment.