Skip to content

Commit

Permalink
fix: replace AssertJ's deprecated asList() DSL method in PodTemplateH…
Browse files Browse the repository at this point in the history
…andlerTest (3465)

Replaced asList() method with asInstanceOf(InstanceOfAssertFactories.list(Type.class)
---
Replaced asList() method with asInstanceOf(InstanceOfAssertFactories.list(Type.class)
---
repushing the code dueto some failuers
  • Loading branch information
ShivamChavan01 authored Oct 18, 2024
1 parent beb975c commit 78e8631
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import io.fabric8.kubernetes.api.model.LocalObjectReference;
import io.fabric8.kubernetes.api.model.PodSpec;
import io.fabric8.kubernetes.api.model.PodTemplateSpec;
import io.fabric8.kubernetes.api.model.Volume;
import io.fabric8.kubernetes.api.model.Container;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.eclipse.jkube.kit.config.image.build.BuildConfiguration;
import org.eclipse.jkube.kit.config.image.ImageConfiguration;
Expand Down Expand Up @@ -87,7 +89,7 @@ void getPodTemplate_withoutVolumeConfig_shouldGeneratePodTemplateWithoutVolume()
assertThat(podTemplateSpec.getSpec().getVolumes()).isEmpty();
assertThat(podTemplateSpec.getSpec())
.extracting(PodSpec::getContainers).isNotNull()
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(Container.class))
.first()
.hasFieldOrPropertyWithValue("name", "test-app")
.hasFieldOrPropertyWithValue("image", "docker.io/test:latest")
Expand All @@ -105,10 +107,10 @@ void getPodTemplate_withEmptyVolumeAndWithoutServiceAccount_shouldGeneratePodTem

PodTemplateSpec podTemplateSpec = podTemplateHandler.getPodTemplate(config, null, images);
assertThat(podTemplateSpec.getSpec())
.hasFieldOrPropertyWithValue("serviceAccountName", null)
.returns(true, spec -> spec.getVolumes().isEmpty())
.extracting(PodSpec::getContainers)
.isNotNull();
.hasFieldOrPropertyWithValue("serviceAccountName", null)
.returns(true, spec -> spec.getVolumes().isEmpty())
.extracting(PodSpec::getContainers)
.isNotNull();
}

@Test
Expand All @@ -128,7 +130,8 @@ void getPodTemplate_withVolumeAndServiceAccount_shouldGeneratePodTemplateWithCon

assertThat(podTemplateSpec.getSpec().getContainers()).isNotNull();
assertThat(podTemplateSpec.getSpec())
.extracting(PodSpec::getVolumes).asList()
.extracting(PodSpec::getVolumes)
.asInstanceOf(InstanceOfAssertFactories.list(Volume.class))
.isNotEmpty()
.first()
.hasFieldOrPropertyWithValue("name", "test")
Expand Down

0 comments on commit 78e8631

Please sign in to comment.