Skip to content

Commit

Permalink
fix: replace AssertJ's deprecated asList() DSL method in RouteEnriche…
Browse files Browse the repository at this point in the history
…rBehavioralTest and ProjectEnricherTest (3524)

removed deprected method asList()
---
removed deprected aslist
---
removed asList() deprected method in the ProjectEnricherTest
---
improved imports
  • Loading branch information
ShivamChavan01 authored Nov 8, 2024
1 parent 51e25ea commit ea78f03
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
*/
package org.eclipse.jkube.enricher.generic.openshift;

import org.eclipse.jkube.kit.config.resource.PlatformMode;
import org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext;

import io.fabric8.kubernetes.api.model.KubernetesList;
import io.fabric8.kubernetes.api.model.KubernetesListBuilder;
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceBuilder;
import io.fabric8.kubernetes.api.model.HasMetadata;

import org.assertj.core.api.InstanceOfAssertFactories;
import org.eclipse.jkube.kit.config.resource.PlatformMode;
import org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext;

import io.fabric8.openshift.api.model.Project;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -47,7 +50,7 @@ void create_whenKubernetesListHasNamespace_thenNamespaceConvertedToProject() {
// Then
assertThat(klb.build())
.extracting(KubernetesList::getItems)
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class))
.singleElement()
.isInstanceOf(Project.class)
.hasFieldOrPropertyWithValue("metadata.name", "foo");
Expand All @@ -64,11 +67,11 @@ void create_whenKubernetesListHasNamespaceWithSpec_thenNamespaceConvertedToProje
// Then
assertThat(klb.build())
.extracting(KubernetesList::getItems)
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class))
.singleElement()
.isInstanceOf(Project.class)
.extracting("spec.finalizers")
.asList().first().isEqualTo("hoo");
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class)).first().isEqualTo("hoo");
}

@Test
Expand All @@ -82,7 +85,7 @@ void create_whenKubernetesListHasNamespaceWithStatus_thenNamespaceConvertedToPro
// Then
assertThat(klb.build())
.extracting(KubernetesList::getItems)
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class))
.singleElement()
.isInstanceOf(Project.class)
.hasFieldOrPropertyWithValue("status.phase", "Complete");
Expand All @@ -98,7 +101,7 @@ void create_whenKubernetesListDoesNotHasNamespace_thenDoesNotNamespaceConvertedT
// Then
assertThat(klb.build())
.extracting(KubernetesList::getItems)
.asList()
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class))
.singleElement()
.isInstanceOf(Service.class)
.hasFieldOrPropertyWithValue("metadata.name", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package org.eclipse.jkube.enricher.generic.openshift;

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.Service;
Expand Down Expand Up @@ -54,7 +55,9 @@ void create_withNoServices_shouldNotCreateRoute() {
// When
new RouteEnricher(context).create(PlatformMode.openshift, klb);
// Then
assertThat(klb.build()).extracting(KubernetesList::getItems).asList().isEmpty();
assertThat(klb.build()).extracting(KubernetesList::getItems)
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class))
.isEmpty();
}

@Test
Expand All @@ -65,8 +68,10 @@ void create_withServiceNotExposed_shouldNotCreateRoute() {
// When
new RouteEnricher(context).create(PlatformMode.openshift, klb);
// Then
assertThat(klb.build()).extracting(KubernetesList::getItems).asList().singleElement()
.isInstanceOf(Service.class);
assertThat(klb.build()).extracting(KubernetesList::getItems)
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class))
.singleElement()
.isInstanceOf(Service.class);
}

@Test
Expand All @@ -77,7 +82,9 @@ void create_withServiceWithNoWebPort_shouldNotCreateRoute() {
// When
new RouteEnricher(context).create(PlatformMode.openshift, klb);
// Then
assertThat(klb.build()).extracting(KubernetesList::getItems).asList().singleElement()
assertThat(klb.build()).extracting(KubernetesList::getItems)
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class))
.singleElement()
.isInstanceOf(Service.class);
}

Expand Down Expand Up @@ -115,7 +122,9 @@ void inKubernetes_shouldNotCreateRoute() {
// When
new RouteEnricher(context).create(PlatformMode.kubernetes, klb);
// Then
assertThat(klb.build()).extracting(KubernetesList::getItems).asList().singleElement()
assertThat(klb.build()).extracting(KubernetesList::getItems)
.asInstanceOf(InstanceOfAssertFactories.list(HasMetadata.class))
.singleElement()
.isInstanceOf(Service.class);
}

Expand Down

0 comments on commit ea78f03

Please sign in to comment.