Skip to content

Commit

Permalink
fix: replace AssertJ's deprecated asList() DSL method in DockerHealth…
Browse files Browse the repository at this point in the history
…CheckEnricherTest (3466)
  • Loading branch information
ShivamChavan01 authored Oct 18, 2024
1 parent 1aeb58d commit beb975c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
import java.util.Collections;
import java.util.List;

import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.KubernetesList;
import io.fabric8.kubernetes.api.model.KubernetesListBuilder;
import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.eclipse.jkube.kit.config.image.build.BuildConfiguration;
import org.eclipse.jkube.kit.config.image.ImageConfiguration;
import org.eclipse.jkube.kit.common.Arguments;
Expand Down Expand Up @@ -202,22 +204,24 @@ private KubernetesListBuilder addDeployment(KubernetesListBuilder list, String n
private void assertNoProbes(KubernetesList list) {
assertThat(list.getItems()).singleElement()
.extracting("spec.template.spec.containers")
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(Container.class))
.first()
.hasFieldOrPropertyWithValue("livenessProbe", null)
.hasFieldOrPropertyWithValue("readinessProbe", null);
}

private void assertHealthCheckMatching(HasMetadata resource, String type, String command, int timeoutSeconds, int periodSeconds, int failureThreshold) {
assertThat(resource)
.extracting("spec.template.spec.containers").asList()
.extracting("spec.template.spec.containers")
.asInstanceOf(InstanceOfAssertFactories.list(Container.class))
.first()
.extracting(type).isNotNull()
.hasFieldOrPropertyWithValue("timeoutSeconds", timeoutSeconds)
.hasFieldOrPropertyWithValue("periodSeconds", periodSeconds)
.hasFieldOrPropertyWithValue("failureThreshold", failureThreshold)
.satisfies(r -> assertThat(r)
.extracting("exec.command").asList()
.extracting("exec.command")
.asInstanceOf(InstanceOfAssertFactories.list(String.class))
.first()
.isEqualTo(command));
}
Expand Down

0 comments on commit beb975c

Please sign in to comment.