Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.springframework.cloud.kubernetes.client;

import org.junit.jupiter.api.Assertions;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -57,8 +57,7 @@ void healthEndpointShouldNotContainKubernetes() {
.jsonPath("components.kubernetes")
.doesNotExist();

Assertions.assertNull(registry.getContributor("kubernetes"),
"reactive kubernetes contributor must NOT be present when 'management.health.kubernetes.enabled=false'");
Assertions.assertThat(registry.getContributor("kubernetes")).isNull();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.util.Config;
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.MockedStatic;
import org.mockito.Mockito;
Expand Down Expand Up @@ -68,7 +68,7 @@ void afterEach() {
@Test
void test() throws ApiException {
Health health = healthIndicator.getHealth(true);
Assertions.assertEquals(health.getStatus(), Status.DOWN);
Assertions.assertThat(Status.DOWN).isSameAs(health.getStatus());
Mockito.verify(coreV1Api).readNamespacedPod("host", "my-namespace", null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.springframework.cloud.kubernetes.client;

import org.junit.jupiter.api.Assertions;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -54,8 +54,8 @@ void healthEndpointShouldContainKubernetes() {
.jsonPath("components.kubernetes")
.exists();

Assertions.assertNotNull(registry.getContributor("kubernetes"),
"reactive kubernetes contributor must be present when 'management.health.kubernetes.enabled=true'");
Assertions.assertThat(registry.getContributor("kubernetes")).isNotNull();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.util.Config;
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.MockedStatic;
import org.mockito.Mockito;
Expand Down Expand Up @@ -71,7 +71,7 @@ void afterEach() {
@Test
void test() throws ApiException {
Health health = healthIndicator.getHealth(true);
Assertions.assertEquals(health.getStatus(), Status.UP);
Assertions.assertThat(Status.UP).isSameAs(health.getStatus());
Mockito.verify(coreV1Api).readNamespacedPod("host", "my-namespace", null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.apis.CoreV1Api;
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;
Expand Down Expand Up @@ -78,15 +78,15 @@ void testBothMissing() {
ConfigDataLocation configDataLocation = ConfigDataLocation.of("kubernetes:abc");
RESOLVER.resolveProfileSpecific(RESOLVER_CONTEXT, configDataLocation, profiles);

Assertions.assertTrue(context.isRegistered(KubernetesClientProperties.class));
Assertions.assertTrue(context.isRegistered(CoreV1Api.class));
Assertions.assertTrue(context.isRegistered(ApiClient.class));
Assertions.assertThat(context.isRegistered(KubernetesClientProperties.class)).isTrue();
Assertions.assertThat(context.isRegistered(CoreV1Api.class)).isTrue();
Assertions.assertThat(context.isRegistered(ApiClient.class)).isTrue();

Assertions.assertFalse(context.isRegistered(ConfigMapConfigProperties.class));
Assertions.assertFalse(context.isRegistered(SecretsConfigProperties.class));
Assertions.assertThat(context.isRegistered(ConfigMapConfigProperties.class)).isFalse();
Assertions.assertThat(context.isRegistered(SecretsConfigProperties.class)).isFalse();

Assertions.assertFalse(context.isRegistered(ConfigMapPropertySourceLocator.class));
Assertions.assertFalse(context.isRegistered(SecretsPropertySourceLocator.class));
Assertions.assertThat(context.isRegistered(ConfigMapPropertySourceLocator.class)).isFalse();
Assertions.assertThat(context.isRegistered(SecretsPropertySourceLocator.class)).isFalse();
}

/*
Expand Down Expand Up @@ -114,24 +114,24 @@ void testBothPresent() {
ConfigDataLocation configDataLocation = ConfigDataLocation.of("kubernetes:abc");
RESOLVER.resolveProfileSpecific(RESOLVER_CONTEXT, configDataLocation, profiles);

Assertions.assertTrue(context.isRegistered(KubernetesClientProperties.class));
Assertions.assertTrue(context.isRegistered(CoreV1Api.class));
Assertions.assertTrue(context.isRegistered(ApiClient.class));
Assertions.assertThat(context.isRegistered(KubernetesClientProperties.class)).isTrue();
Assertions.assertThat(context.isRegistered(CoreV1Api.class)).isTrue();
Assertions.assertThat(context.isRegistered(ApiClient.class)).isTrue();

Assertions.assertTrue(context.isRegistered(ConfigMapConfigProperties.class));
Assertions.assertTrue(context.isRegistered(SecretsConfigProperties.class));
Assertions.assertThat(context.isRegistered(ConfigMapConfigProperties.class)).isTrue();
Assertions.assertThat(context.isRegistered(SecretsConfigProperties.class)).isTrue();

Assertions.assertTrue(context.isRegistered(ConfigMapPropertySourceLocator.class));
Assertions.assertTrue(context.isRegistered(SecretsPropertySourceLocator.class));
Assertions.assertThat(context.isRegistered(ConfigMapPropertySourceLocator.class)).isTrue();
Assertions.assertThat(context.isRegistered(SecretsPropertySourceLocator.class)).isTrue();

ConfigMapPropertySourceLocator configMapPropertySourceLocator = context
.get(ConfigMapPropertySourceLocator.class);
Assertions.assertSame(KubernetesClientConfigMapPropertySourceLocator.class,
configMapPropertySourceLocator.getClass());
Assertions.assertThat(configMapPropertySourceLocator.getClass())
.isEqualTo(KubernetesClientConfigMapPropertySourceLocator.class);

SecretsPropertySourceLocator secretsPropertySourceLocator = context.get(SecretsPropertySourceLocator.class);
Assertions.assertSame(KubernetesClientSecretsPropertySourceLocator.class,
secretsPropertySourceLocator.getClass());
Assertions.assertThat(secretsPropertySourceLocator.getClass())
.isEqualTo(KubernetesClientSecretsPropertySourceLocator.class);

}

Expand Down Expand Up @@ -161,25 +161,25 @@ void testBothPresentExplicitly(CapturedOutput capturedOutput) {
ConfigDataLocation configDataLocation = ConfigDataLocation.of("kubernetes:abc");
RESOLVER.resolveProfileSpecific(RESOLVER_CONTEXT, configDataLocation, profiles);

Assertions.assertTrue(context.isRegistered(KubernetesClientProperties.class));
Assertions.assertTrue(context.isRegistered(CoreV1Api.class));
Assertions.assertTrue(context.isRegistered(ApiClient.class));
Assertions.assertThat(context.isRegistered(KubernetesClientProperties.class)).isTrue();
Assertions.assertThat(context.isRegistered(CoreV1Api.class)).isTrue();
Assertions.assertThat(context.isRegistered(ApiClient.class)).isTrue();

Assertions.assertTrue(context.isRegistered(ConfigMapConfigProperties.class));
Assertions.assertTrue(context.isRegistered(SecretsConfigProperties.class));
Assertions.assertThat(context.isRegistered(ConfigMapConfigProperties.class)).isTrue();
Assertions.assertThat(context.isRegistered(SecretsConfigProperties.class)).isTrue();

ConfigMapPropertySourceLocator configMapPropertySourceLocator = context
.get(ConfigMapPropertySourceLocator.class);
Assertions.assertSame(KubernetesClientConfigMapPropertySourceLocator.class,
configMapPropertySourceLocator.getClass());
Assertions.assertThat(configMapPropertySourceLocator.getClass())
.isEqualTo(KubernetesClientConfigMapPropertySourceLocator.class);

SecretsPropertySourceLocator secretsPropertySourceLocator = context.get(SecretsPropertySourceLocator.class);
Assertions.assertSame(KubernetesClientSecretsPropertySourceLocator.class,
secretsPropertySourceLocator.getClass());
Assertions.assertThat(secretsPropertySourceLocator.getClass())
.isEqualTo(KubernetesClientSecretsPropertySourceLocator.class);

Assertions.assertTrue(capturedOutput.getOut()
Assertions.assertThat(capturedOutput.getOut())
.contains("Could not create the Kubernetes ApiClient in a cluster environment, because connection port "
+ "was not provided."));
+ "was not provided.");
}

/*
Expand Down Expand Up @@ -211,24 +211,24 @@ void testBothPresentAndRetryEnabled() {
ConfigDataLocation configDataLocation = ConfigDataLocation.of("kubernetes:abc");
RESOLVER.resolveProfileSpecific(RESOLVER_CONTEXT, configDataLocation, profiles);

Assertions.assertTrue(context.isRegistered(KubernetesClientProperties.class));
Assertions.assertTrue(context.isRegistered(CoreV1Api.class));
Assertions.assertTrue(context.isRegistered(ApiClient.class));
Assertions.assertThat(context.isRegistered(KubernetesClientProperties.class)).isTrue();
Assertions.assertThat(context.isRegistered(CoreV1Api.class)).isTrue();
Assertions.assertThat(context.isRegistered(ApiClient.class)).isTrue();

Assertions.assertTrue(context.isRegistered(ConfigMapConfigProperties.class));
Assertions.assertTrue(context.isRegistered(SecretsConfigProperties.class));
Assertions.assertThat(context.isRegistered(ConfigMapConfigProperties.class)).isTrue();
Assertions.assertThat(context.isRegistered(SecretsConfigProperties.class)).isTrue();

Assertions.assertTrue(context.isRegistered(ConfigMapPropertySourceLocator.class));
Assertions.assertTrue(context.isRegistered(SecretsPropertySourceLocator.class));
Assertions.assertThat(context.isRegistered(ConfigMapPropertySourceLocator.class)).isTrue();
Assertions.assertThat(context.isRegistered(SecretsPropertySourceLocator.class)).isTrue();

ConfigMapPropertySourceLocator configMapPropertySourceLocator = context
.get(ConfigMapPropertySourceLocator.class);
Assertions.assertSame(ConfigDataRetryableConfigMapPropertySourceLocator.class,
configMapPropertySourceLocator.getClass());
Assertions.assertThat(configMapPropertySourceLocator.getClass())
.isEqualTo(ConfigDataRetryableConfigMapPropertySourceLocator.class);

SecretsPropertySourceLocator secretsPropertySourceLocator = context.get(SecretsPropertySourceLocator.class);
Assertions.assertSame(ConfigDataRetryableSecretsPropertySourceLocator.class,
secretsPropertySourceLocator.getClass());
Assertions.assertThat(secretsPropertySourceLocator.getClass())
.isEqualTo(ConfigDataRetryableSecretsPropertySourceLocator.class);

}

Expand Down
Loading
Loading