@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ConditionalOnSelectiveNamespacesDisabledTests {
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
Mockito.when(CONDITION_CONTEXT.getEnvironment()).thenReturn(environment);
|
||||
boolean result = TO_TEST.matches(CONDITION_CONTEXT, null);
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -47,7 +47,7 @@ public class ConditionalOnSelectiveNamespacesDisabledTests {
|
||||
environment.setProperty("spring.cloud.kubernetes.discovery.namespaces", "");
|
||||
Mockito.when(CONDITION_CONTEXT.getEnvironment()).thenReturn(environment);
|
||||
boolean result = TO_TEST.matches(CONDITION_CONTEXT, null);
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,7 +56,7 @@ public class ConditionalOnSelectiveNamespacesDisabledTests {
|
||||
environment.setProperty("spring.cloud.kubernetes.discovery.namespaces", "default");
|
||||
Mockito.when(CONDITION_CONTEXT.getEnvironment()).thenReturn(environment);
|
||||
boolean result = TO_TEST.matches(CONDITION_CONTEXT, null);
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.discovery;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -37,7 +37,7 @@ class ConditionalOnSelectiveNamespacesEnabledTests {
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
Mockito.when(CONDITION_CONTEXT.getEnvironment()).thenReturn(environment);
|
||||
boolean result = TO_TEST.matches(CONDITION_CONTEXT, null);
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -46,7 +46,7 @@ class ConditionalOnSelectiveNamespacesEnabledTests {
|
||||
environment.setProperty("spring.cloud.kubernetes.discovery.namespaces", "");
|
||||
Mockito.when(CONDITION_CONTEXT.getEnvironment()).thenReturn(environment);
|
||||
boolean result = TO_TEST.matches(CONDITION_CONTEXT, null);
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,7 +55,7 @@ class ConditionalOnSelectiveNamespacesEnabledTests {
|
||||
environment.setProperty("spring.cloud.kubernetes.discovery.namespaces", "default");
|
||||
Mockito.when(CONDITION_CONTEXT.getEnvironment()).thenReturn(environment);
|
||||
boolean result = TO_TEST.matches(CONDITION_CONTEXT, null);
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import io.kubernetes.client.openapi.models.V1ObjectReferenceBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceSpecBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.discovery.InstanceIdHostPodName;
|
||||
@@ -43,8 +43,8 @@ class K8sInstanceIdHostPodNameSupplierTests {
|
||||
K8sInstanceIdHostPodNameSupplier supplier = K8sInstanceIdHostPodNameSupplier.externalName(service);
|
||||
InstanceIdHostPodName result = supplier.get();
|
||||
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result.instanceId(), "123");
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.instanceId()).isEqualTo("123");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -60,8 +60,8 @@ class K8sInstanceIdHostPodNameSupplierTests {
|
||||
service);
|
||||
InstanceIdHostPodName result = supplier.get();
|
||||
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result.instanceId(), "456");
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.instanceId()).isEqualTo("456");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,8 +74,8 @@ class K8sInstanceIdHostPodNameSupplierTests {
|
||||
K8sInstanceIdHostPodNameSupplier supplier = K8sInstanceIdHostPodNameSupplier.externalName(service);
|
||||
InstanceIdHostPodName result = supplier.get();
|
||||
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result.host(), "external-name");
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.host()).isEqualTo("external-name");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,8 +90,8 @@ class K8sInstanceIdHostPodNameSupplierTests {
|
||||
service);
|
||||
InstanceIdHostPodName result = supplier.get();
|
||||
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result.host(), "127.0.0.1");
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.host()).isEqualTo("127.0.0.1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,8 +102,8 @@ class K8sInstanceIdHostPodNameSupplierTests {
|
||||
K8sInstanceIdHostPodNameSupplier supplier = K8sInstanceIdHostPodNameSupplier.externalName(service);
|
||||
InstanceIdHostPodName result = supplier.get();
|
||||
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertNull(result.podName());
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.podName()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,8 +120,8 @@ class K8sInstanceIdHostPodNameSupplierTests {
|
||||
service);
|
||||
InstanceIdHostPodName result = supplier.get();
|
||||
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertNull(result.podName());
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.podName()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,8 +138,8 @@ class K8sInstanceIdHostPodNameSupplierTests {
|
||||
service);
|
||||
InstanceIdHostPodName result = supplier.get();
|
||||
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result.podName(), "my-pod");
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.podName()).isEqualTo("my-pod");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.Map;
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import io.kubernetes.client.openapi.models.V1ObjectMetaBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1PodBuilder;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -52,9 +52,9 @@ class K8sPodLabelsAndAnnotationsSupplierTests {
|
||||
|
||||
PodLabelsAndAnnotations result = K8sPodLabelsAndAnnotationsSupplier.nonExternalName(coreV1Api, NAMESPACE)
|
||||
.apply(POD_NAME);
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertTrue(result.labels().isEmpty());
|
||||
Assertions.assertTrue(result.annotations().isEmpty());
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.labels()).isEmpty();
|
||||
Assertions.assertThat(result.annotations()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,9 +70,9 @@ class K8sPodLabelsAndAnnotationsSupplierTests {
|
||||
|
||||
PodLabelsAndAnnotations result = K8sPodLabelsAndAnnotationsSupplier.nonExternalName(coreV1Api, NAMESPACE)
|
||||
.apply(POD_NAME);
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result.labels(), Map.of("a", "b"));
|
||||
Assertions.assertEquals(result.annotations(), Map.of("c", "d"));
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result.labels()).isEqualTo(Map.of("a", "b"));
|
||||
Assertions.assertThat(result.annotations()).isEqualTo(Map.of("c", "d"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.kubernetes.client.openapi.ApiClient;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mockito;
|
||||
@@ -66,11 +66,11 @@ class KubernetesClientInformerSelectiveNamespacesAutoConfigurationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> selectiveNamespaces = context.getBean("selectiveNamespaces", Set.class);
|
||||
Assertions.assertEquals(selectiveNamespaces, Set.of("a", "b"));
|
||||
Assertions.assertThat(selectiveNamespaces).isEqualTo(Set.of("a", "b"));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<String> namespaces = context.getBean("namespaces", Set.class);
|
||||
Assertions.assertEquals(namespaces, Set.of("c", "d"));
|
||||
Assertions.assertThat(namespaces).isEqualTo(Set.of("c", "d"));
|
||||
});
|
||||
|
||||
assertThat(output.getOut().contains("registering lister (for services) in namespace : " + NAMESPACE_A))
|
||||
|
||||
@@ -22,8 +22,8 @@ import io.kubernetes.client.openapi.ApiClient;
|
||||
import io.kubernetes.client.openapi.JSON;
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
@@ -66,12 +66,12 @@ public class KubernetesDiscoveryClientConfigClientBootstrapConfigurationTests {
|
||||
setup("server.port=7000", "spring.cloud.config.discovery.enabled=true",
|
||||
"spring.cloud.kubernetes.discovery.enabled:true", "spring.application.name:test",
|
||||
"spring.cloud.config.discovery.service-id:configserver");
|
||||
Assertions.assertEquals(1, this.context.getParent().getBeanNamesForType(DiscoveryClient.class).length);
|
||||
Assertions.assertThat(this.context.getParent().getBeanNamesForType(DiscoveryClient.class).length).isEqualTo(1);
|
||||
|
||||
DiscoveryClient client = this.context.getParent().getBean(DiscoveryClient.class);
|
||||
verify(client, atLeast(2)).getInstances("configserver");
|
||||
ConfigClientProperties locator = this.context.getBean(ConfigClientProperties.class);
|
||||
Assertions.assertEquals("http://fake:8888/", locator.getUri()[0]);
|
||||
Assertions.assertThat(locator.getUri()[0]).isEqualTo("http://fake:8888/");
|
||||
}
|
||||
|
||||
private void setup(String... env) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.function.Predicate;
|
||||
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
@@ -46,8 +46,8 @@ class KubernetesDiscoveryClientFilterTests {
|
||||
false, spelFilter, Set.of(), Map.of(), null, null, 0, false);
|
||||
|
||||
Predicate<V1Service> predicate = KubernetesDiscoveryClientUtils.filter(properties);
|
||||
Assertions.assertNotNull(predicate);
|
||||
Assertions.assertTrue(output.getOut().contains("filter not defined, returning always true predicate"));
|
||||
Assertions.assertThat(predicate).isNotNull();
|
||||
Assertions.assertThat(output.getOut()).contains("filter not defined, returning always true predicate");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,8 +58,8 @@ class KubernetesDiscoveryClientFilterTests {
|
||||
false, spelFilter, Set.of(), Map.of(), null, null, 0, false);
|
||||
|
||||
Predicate<V1Service> predicate = KubernetesDiscoveryClientUtils.filter(properties);
|
||||
Assertions.assertNotNull(predicate);
|
||||
Assertions.assertTrue(output.getOut().contains("returning predicate based on filter expression: some"));
|
||||
Assertions.assertThat(predicate).isNotNull();
|
||||
Assertions.assertThat(output.getOut()).contains("returning predicate based on filter expression: some");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,8 +80,8 @@ class KubernetesDiscoveryClientFilterTests {
|
||||
.filter(predicate)
|
||||
.sorted(Comparator.comparing(service -> service.getMetadata().getName()))
|
||||
.toList();
|
||||
Assertions.assertEquals(filtered.get(0).getMetadata().getName(), "a");
|
||||
Assertions.assertEquals(filtered.get(1).getMetadata().getName(), "a");
|
||||
Assertions.assertThat(filtered.get(0).getMetadata().getName()).isEqualTo("a");
|
||||
Assertions.assertThat(filtered.get(1).getMetadata().getName()).isEqualTo("a");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,7 +102,7 @@ class KubernetesDiscoveryClientFilterTests {
|
||||
.filter(predicate)
|
||||
.sorted(Comparator.comparing(service -> service.getMetadata().getName()))
|
||||
.toList();
|
||||
Assertions.assertEquals(filtered.size(), 0);
|
||||
Assertions.assertThat(filtered).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,7 +123,7 @@ class KubernetesDiscoveryClientFilterTests {
|
||||
.filter(predicate)
|
||||
.sorted(Comparator.comparing(service -> service.getMetadata().getName()))
|
||||
.toList();
|
||||
Assertions.assertEquals(filtered.size(), 0);
|
||||
Assertions.assertThat(filtered).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import io.kubernetes.client.openapi.models.V1Service;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ServicePortBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceSpecBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -94,8 +94,8 @@ class KubernetesDiscoveryClientServiceWithoutPortNameTests {
|
||||
endpointsLister, SERVICE_SHARED_INFORMER_STUB, ENDPOINTS_SHARED_INFORMER_STUB, properties);
|
||||
|
||||
List<ServiceInstance> serviceInstances = discoveryClient.getInstances("no-port-name-service");
|
||||
Assertions.assertEquals(serviceInstances.size(), 1);
|
||||
Assertions.assertEquals(serviceInstances.get(0).getMetadata(),
|
||||
Assertions.assertThat(serviceInstances.size()).isEqualTo(1);
|
||||
Assertions.assertThat(serviceInstances.get(0).getMetadata()).isEqualTo(
|
||||
Map.of("port.<unset>", "8080", "k8s_namespace", "spring-k8s", "type", "ClusterIP"));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import io.kubernetes.client.openapi.models.V1EndpointSubsetBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
@@ -56,9 +56,9 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
V1Service service = new V1ServiceBuilder().withMetadata(new V1ObjectMeta().name("my-service")).build();
|
||||
|
||||
boolean result = matchesServiceLabels(service, properties);
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.contains("service labels from properties are empty, service with name : 'my-service' will match"));
|
||||
Assertions.assertThat(result).isTrue();
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains("service labels from properties are empty, service with name : 'my-service' will match");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,8 +72,8 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
V1Service service = new V1ServiceBuilder().withMetadata(new V1ObjectMeta().name("my-service")).build();
|
||||
|
||||
boolean result = matchesServiceLabels(service, properties);
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertTrue(output.getOut().contains("service with name : 'my-service' does not have labels"));
|
||||
Assertions.assertThat(result).isFalse();
|
||||
Assertions.assertThat(output.getOut()).contains("service with name : 'my-service' does not have labels");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,9 +95,9 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.build();
|
||||
|
||||
boolean result = matchesServiceLabels(service, properties);
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertTrue(output.getOut().contains("Service labels from properties : {a=b}"));
|
||||
Assertions.assertTrue(output.getOut().contains("Service labels from service : {a=b}"));
|
||||
Assertions.assertThat(result).isTrue();
|
||||
Assertions.assertThat(output.getOut()).contains("Service labels from properties : {a=b}");
|
||||
Assertions.assertThat(output.getOut()).contains("Service labels from service : {a=b}");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,9 +119,9 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.build();
|
||||
|
||||
boolean result = matchesServiceLabels(service, properties);
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertTrue(output.getOut().contains("Service labels from properties : {a=b, c=d}"));
|
||||
Assertions.assertTrue(output.getOut().contains("Service labels from service : {a=b}"));
|
||||
Assertions.assertThat(result).isFalse();
|
||||
Assertions.assertThat(output.getOut()).contains("Service labels from properties : {a=b, c=d}");
|
||||
Assertions.assertThat(output.getOut()).contains("Service labels from service : {a=b}");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,9 +143,9 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.build();
|
||||
|
||||
boolean result = matchesServiceLabels(service, properties);
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertTrue(output.getOut().contains("Service labels from properties : {a=b, c=d}"));
|
||||
Assertions.assertTrue(output.getOut().contains("Service labels from service : {a=b, c=d}"));
|
||||
Assertions.assertThat(result).isTrue();
|
||||
Assertions.assertThat(output.getOut()).contains("Service labels from properties : {a=b, c=d}");
|
||||
Assertions.assertThat(output.getOut()).contains("Service labels from service : {a=b, c=d}");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,9 +167,9 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.build();
|
||||
|
||||
boolean result = matchesServiceLabels(service, properties);
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertTrue(output.getOut().contains("Service labels from properties : {a=b}"));
|
||||
Assertions.assertTrue(output.getOut().contains("Service labels from service : {a=b, c=d}"));
|
||||
Assertions.assertThat(result).isTrue();
|
||||
Assertions.assertThat(output.getOut()).contains("Service labels from properties : {a=b}");
|
||||
Assertions.assertThat(output.getOut()).contains("Service labels from service : {a=b, c=d}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -183,9 +183,9 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.build());
|
||||
|
||||
Map<String, Integer> portsData = endpointSubsetsPortData(endpointSubsets);
|
||||
Assertions.assertEquals(portsData.size(), 2);
|
||||
Assertions.assertEquals(portsData.get("https"), 8080);
|
||||
Assertions.assertEquals(portsData.get("<unset>"), 8081);
|
||||
Assertions.assertThat(portsData.size()).isEqualTo(2);
|
||||
Assertions.assertThat(portsData.get("https")).isEqualTo(8080);
|
||||
Assertions.assertThat(portsData.get("<unset>")).isEqualTo(8081);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -199,9 +199,9 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.build());
|
||||
|
||||
Map<String, Integer> portsData = endpointSubsetsPortData(endpointSubsets);
|
||||
Assertions.assertEquals(portsData.size(), 2);
|
||||
Assertions.assertEquals(portsData.get("https"), 8080);
|
||||
Assertions.assertEquals(portsData.get("http"), 8081);
|
||||
Assertions.assertThat(portsData.size()).isEqualTo(2);
|
||||
Assertions.assertThat(portsData.get("https")).isEqualTo(8080);
|
||||
Assertions.assertThat(portsData.get("http")).isEqualTo(8081);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -209,7 +209,7 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
V1EndpointSubset endpointSubset = new V1EndpointSubsetBuilder().build();
|
||||
Map<String, Integer> result = endpointSubsetsPortData(List.of(endpointSubset));
|
||||
|
||||
Assertions.assertEquals(result.size(), 0);
|
||||
Assertions.assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -219,8 +219,8 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.build();
|
||||
Map<String, Integer> result = endpointSubsetsPortData(List.of(endpointSubset));
|
||||
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertEquals(result.get("name"), 80);
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result.get("name")).isEqualTo(80);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -230,8 +230,8 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.build();
|
||||
Map<String, Integer> result = endpointSubsetsPortData(List.of(endpointSubset));
|
||||
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertEquals(result.get("<unset>"), 80);
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result.get("<unset>")).isEqualTo(80);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +247,7 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
includeNotReadyAddresses, "", Set.of(), Map.of(), "", null, 0, false, false);
|
||||
V1EndpointSubset endpointSubset = new V1EndpointSubsetBuilder().build();
|
||||
List<V1EndpointAddress> addresses = KubernetesDiscoveryClientUtils.addresses(endpointSubset, properties);
|
||||
Assertions.assertEquals(addresses.size(), 0);
|
||||
Assertions.assertThat(addresses).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,7 +266,7 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
new V1EndpointAddressBuilder().withHostname("two").build())
|
||||
.build();
|
||||
List<V1EndpointAddress> addresses = KubernetesDiscoveryClientUtils.addresses(endpointSubset, properties);
|
||||
Assertions.assertEquals(addresses.size(), 2);
|
||||
Assertions.assertThat(addresses.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,9 +286,8 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.withNotReadyAddresses(new V1EndpointAddressBuilder().withHostname("three").build())
|
||||
.build();
|
||||
List<V1EndpointAddress> addresses = KubernetesDiscoveryClientUtils.addresses(endpointSubset, properties);
|
||||
Assertions.assertEquals(addresses.size(), 2);
|
||||
List<String> hostNames = addresses.stream().map(V1EndpointAddress::getHostname).sorted().toList();
|
||||
Assertions.assertEquals(hostNames, List.of("one", "two"));
|
||||
Assertions.assertThat(hostNames).containsExactly("one", "two");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,9 +307,8 @@ class KubernetesDiscoveryClientUtilsTests {
|
||||
.withNotReadyAddresses(new V1EndpointAddressBuilder().withHostname("three").build())
|
||||
.build();
|
||||
List<V1EndpointAddress> addresses = KubernetesDiscoveryClientUtils.addresses(endpointSubset, properties);
|
||||
Assertions.assertEquals(addresses.size(), 3);
|
||||
List<String> hostNames = addresses.stream().map(V1EndpointAddress::getHostname).sorted().toList();
|
||||
Assertions.assertEquals(hostNames, List.of("one", "three", "two"));
|
||||
Assertions.assertThat(hostNames).containsExactly("one", "three", "two");
|
||||
}
|
||||
|
||||
// preserve order for testing reasons
|
||||
|
||||
@@ -47,7 +47,6 @@ import io.kubernetes.client.openapi.models.V1ServiceBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceSpec;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceSpecBuilder;
|
||||
import io.kubernetes.client.util.ClientBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -545,14 +544,14 @@ class KubernetesInformerDiscoveryClientTests {
|
||||
SHARED_INFORMER_FACTORY, serviceLister, endpointsLister, null, null, properties);
|
||||
|
||||
List<ServiceInstance> result = discoveryClient.getInstances("blue-service");
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
DefaultKubernetesServiceInstance externalNameServiceInstance = (DefaultKubernetesServiceInstance) result.get(0);
|
||||
Assertions.assertEquals(externalNameServiceInstance.getServiceId(), "blue-service");
|
||||
Assertions.assertEquals(externalNameServiceInstance.getHost(), "k8s-spring-b");
|
||||
Assertions.assertEquals(externalNameServiceInstance.getPort(), -1);
|
||||
Assertions.assertFalse(externalNameServiceInstance.isSecure());
|
||||
Assertions.assertEquals(externalNameServiceInstance.getUri().toASCIIString(), "k8s-spring-b");
|
||||
Assertions.assertEquals(externalNameServiceInstance.getMetadata(), Map.of("k8s_namespace", "b",
|
||||
assertThat(externalNameServiceInstance.getServiceId()).isEqualTo("blue-service");
|
||||
assertThat(externalNameServiceInstance.getHost()).isEqualTo("k8s-spring-b");
|
||||
assertThat(externalNameServiceInstance.getPort()).isEqualTo(-1);
|
||||
assertThat(externalNameServiceInstance.isSecure()).isTrue();
|
||||
assertThat(externalNameServiceInstance.getUri().toASCIIString()).isEqualTo("k8s-spring-b");
|
||||
assertThat(externalNameServiceInstance.getMetadata()).isEqualTo(Map.of("k8s_namespace", "b",
|
||||
"labels-prefix-label-key", "label-value", "annotations-prefix-abc", "def", "type", "ExternalName"));
|
||||
}
|
||||
|
||||
@@ -603,17 +602,17 @@ class KubernetesInformerDiscoveryClientTests {
|
||||
discoveryClient.coreV1Api = new CoreV1Api(apiClient);
|
||||
|
||||
List<ServiceInstance> result = discoveryClient.getInstances("blue-service");
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
assertThat(result.size()).isEqualTo(1);
|
||||
DefaultKubernetesServiceInstance serviceInstance = (DefaultKubernetesServiceInstance) result.get(0);
|
||||
Assertions.assertEquals(serviceInstance.getServiceId(), "blue-service");
|
||||
Assertions.assertEquals(serviceInstance.getHost(), "127.0.0.1");
|
||||
Assertions.assertEquals(serviceInstance.getPort(), 8080);
|
||||
Assertions.assertFalse(serviceInstance.isSecure());
|
||||
Assertions.assertEquals(serviceInstance.getUri().toASCIIString(), "http://127.0.0.1:8080");
|
||||
Assertions.assertEquals(serviceInstance.getMetadata(),
|
||||
assertThat(serviceInstance.getServiceId()).isEqualTo("blue-service");
|
||||
assertThat(serviceInstance.getHost()).isEqualTo("127.0.0.1");
|
||||
assertThat(serviceInstance.getPort()).isEqualTo(8080);
|
||||
assertThat(serviceInstance.isSecure()).isTrue();
|
||||
assertThat(serviceInstance.getUri().toASCIIString()).isEqualTo("http://127.0.0.1:8080");
|
||||
assertThat(serviceInstance.getMetadata()).isEqualTo(
|
||||
Map.of("k8s_namespace", "a", "type", "ClusterIP", "ports-prefix<unset>", "8080"));
|
||||
Assertions.assertEquals(serviceInstance.podMetadata().get("labels"), Map.of("a", "b"));
|
||||
Assertions.assertEquals(serviceInstance.podMetadata().get("annotations"), Map.of("c", "d"));
|
||||
assertThat(serviceInstance.podMetadata().get("labels")).isEqualTo(Map.of("a", "b"));
|
||||
assertThat(serviceInstance.podMetadata().get("annotations")).isEqualTo(Map.of("c", "d"));
|
||||
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.kubernetes.client.discovery.catalog;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -30,13 +30,13 @@ class KubernetesCatalogWatchContextTests {
|
||||
@Test
|
||||
void emptyLabels() {
|
||||
String result = KubernetesCatalogWatchContext.labelSelector(Map.of());
|
||||
Assertions.assertEquals("", result);
|
||||
Assertions.assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void singleLabel() {
|
||||
String result = KubernetesCatalogWatchContext.labelSelector(Map.of("a", "b"));
|
||||
Assertions.assertEquals("a=b", result);
|
||||
Assertions.assertThat(result).isEqualTo("a=b");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -45,7 +45,7 @@ class KubernetesCatalogWatchContextTests {
|
||||
labels.put("a", "b");
|
||||
labels.put("c", "d");
|
||||
String result = KubernetesCatalogWatchContext.labelSelector(labels);
|
||||
Assertions.assertEquals("a=b,c=d", result);
|
||||
Assertions.assertThat(result).isEqualTo("a=b,c=d");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ import io.kubernetes.client.openapi.models.V1APIResourceBuilder;
|
||||
import io.kubernetes.client.openapi.models.V1APIResourceList;
|
||||
import io.kubernetes.client.openapi.models.V1APIResourceListBuilder;
|
||||
import io.kubernetes.client.util.ClientBuilder;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
@@ -95,8 +95,8 @@ class KubernetesClientCatalogWatchEndpointSlicesSupportTests {
|
||||
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(list))));
|
||||
|
||||
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(null, apiClient, properties, NAMESPACE_PROVIDER);
|
||||
IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException.class, watch::postConstruct);
|
||||
Assertions.assertEquals("EndpointSlices are not supported on the cluster", ex.getMessage());
|
||||
Assertions.assertThatThrownBy(watch::postConstruct).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("EndpointSlices are not supported on the cluster");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,8 +119,8 @@ class KubernetesClientCatalogWatchEndpointSlicesSupportTests {
|
||||
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(list))));
|
||||
|
||||
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(null, apiClient, properties, NAMESPACE_PROVIDER);
|
||||
IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException.class, watch::postConstruct);
|
||||
Assertions.assertEquals("EndpointSlices are not supported on the cluster", ex.getMessage());
|
||||
Assertions.assertThatThrownBy(watch::postConstruct).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("EndpointSlices are not supported on the cluster");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ class KubernetesClientCatalogWatchEndpointSlicesSupportTests {
|
||||
false, "", Set.of(), Map.of(), "", null, 0, useEndpointSlices);
|
||||
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(null, apiClient, properties, NAMESPACE_PROVIDER);
|
||||
|
||||
Assertions.assertEquals(KubernetesEndpointsCatalogWatch.class, watch.stateGenerator().getClass());
|
||||
Assertions.assertThat(watch.stateGenerator().getClass()).isEqualTo(KubernetesEndpointsCatalogWatch.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +154,7 @@ class KubernetesClientCatalogWatchEndpointSlicesSupportTests {
|
||||
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(list))));
|
||||
|
||||
KubernetesCatalogWatch watch = new KubernetesCatalogWatch(null, apiClient, properties, NAMESPACE_PROVIDER);
|
||||
Assertions.assertEquals(KubernetesEndpointSlicesCatalogWatch.class, watch.stateGenerator().getClass());
|
||||
Assertions.assertThat(watch.stateGenerator().getClass()).isEqualTo(KubernetesEndpointSlicesCatalogWatch.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ import io.kubernetes.client.openapi.models.V1ObjectMeta;
|
||||
import io.kubernetes.client.openapi.models.V1Service;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceSpec;
|
||||
import io.kubernetes.client.openapi.models.V1ServiceSpecBuilder;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -190,9 +190,9 @@ class KubernetesInformerReactiveDiscoveryClientTests {
|
||||
kubernetesDiscoveryProperties));
|
||||
|
||||
List<String> result = discoveryClient.getServices().collectList().block();
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertTrue(result.contains("service-a"));
|
||||
Assertions.assertTrue(result.contains("service-b"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
Assertions.assertThat(result).contains("service-a");
|
||||
Assertions.assertThat(result).contains("service-b");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,9 +224,9 @@ class KubernetesInformerReactiveDiscoveryClientTests {
|
||||
kubernetesDiscoveryProperties));
|
||||
|
||||
List<String> result = discoveryClient.getServices().collectList().block();
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertTrue(result.contains("service-a"));
|
||||
Assertions.assertFalse(result.contains("service-b"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result).contains("service-a");
|
||||
Assertions.assertThat(result).doesNotContain("service-b");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,10 +274,10 @@ class KubernetesInformerReactiveDiscoveryClientTests {
|
||||
kubernetesDiscoveryProperties));
|
||||
|
||||
List<ServiceInstance> result = discoveryClient.getInstances("endpoints-x").collectList().block();
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
List<String> byIp = result.stream().map(ServiceInstance::getHost).sorted().toList();
|
||||
Assertions.assertTrue(byIp.contains("1.1.1.1"));
|
||||
Assertions.assertTrue(byIp.contains("2.2.2.2"));
|
||||
Assertions.assertThat(byIp).contains("1.1.1.1");
|
||||
Assertions.assertThat(byIp).contains("2.2.2.2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,9 +325,9 @@ class KubernetesInformerReactiveDiscoveryClientTests {
|
||||
kubernetesDiscoveryProperties));
|
||||
|
||||
List<ServiceInstance> result = discoveryClient.getInstances("endpoints-x").collectList().block();
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
List<String> byIp = result.stream().map(ServiceInstance::getHost).sorted().toList();
|
||||
Assertions.assertTrue(byIp.contains("1.1.1.1"));
|
||||
Assertions.assertThat(byIp).contains("1.1.1.1");
|
||||
}
|
||||
|
||||
private Lister<V1Service> setupServiceLister(String namespace, V1Service... services) {
|
||||
|
||||
Reference in New Issue
Block a user