@@ -19,7 +19,7 @@ package org.springframework.cloud.kubernetes.commons;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.SanitizableData;
|
||||
@@ -63,7 +63,7 @@ class SanitizeTests {
|
||||
Sanitizer sanitizer = new Sanitizer(SANITIZING_FUNCTIONS);
|
||||
SanitizableData sanitizableData = new SanitizableData(bootstrapPropertySource, "secret", "xyz");
|
||||
|
||||
Assertions.assertEquals(sanitizer.sanitize(sanitizableData, SHOW_UNSANITIZED), "xyz");
|
||||
Assertions.assertThat(sanitizer.sanitize(sanitizableData, SHOW_UNSANITIZED)).isEqualTo("xyz");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,7 +75,7 @@ class SanitizeTests {
|
||||
Sanitizer sanitizer = new Sanitizer(SANITIZING_FUNCTIONS);
|
||||
SanitizableData sanitizableData = new SanitizableData(bootstrapPropertySource, "secret", "xyz");
|
||||
|
||||
Assertions.assertEquals(sanitizer.sanitize(sanitizableData, SHOW_UNSANITIZED), SANITIZED_VALUE);
|
||||
Assertions.assertThat(sanitizer.sanitize(sanitizableData, SHOW_UNSANITIZED)).isEqualTo(SANITIZED_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,7 +87,7 @@ class SanitizeTests {
|
||||
Sanitizer sanitizer = new Sanitizer(SANITIZING_FUNCTIONS);
|
||||
SanitizableData sanitizableData = new SanitizableData(bootstrapPropertySource, "secret", "xyz");
|
||||
|
||||
Assertions.assertEquals(sanitizer.sanitize(sanitizableData, SHOW_UNSANITIZED), "xyz");
|
||||
Assertions.assertThat(sanitizer.sanitize(sanitizableData, SHOW_UNSANITIZED)).isEqualTo("xyz");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +99,7 @@ class SanitizeTests {
|
||||
Sanitizer sanitizer = new Sanitizer(SANITIZING_FUNCTIONS);
|
||||
SanitizableData sanitizableData = new SanitizableData(bootstrapPropertySource, "secret", "xyz");
|
||||
|
||||
Assertions.assertEquals(sanitizer.sanitize(sanitizableData, SHOW_UNSANITIZED), SANITIZED_VALUE);
|
||||
Assertions.assertThat(sanitizer.sanitize(sanitizableData, SHOW_UNSANITIZED)).isEqualTo(SANITIZED_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -114,8 +114,8 @@ class SanitizeTests {
|
||||
SanitizableData sanitizableDataSecret = new SanitizableData(compositePropertySource, "secret", "xyz");
|
||||
SanitizableData sanitizableDataMount = new SanitizableData(compositePropertySource, "mount", "abc");
|
||||
|
||||
Assertions.assertEquals(sanitizer.sanitize(sanitizableDataSecret, SHOW_UNSANITIZED), SANITIZED_VALUE);
|
||||
Assertions.assertEquals(sanitizer.sanitize(sanitizableDataMount, SHOW_UNSANITIZED), "abc");
|
||||
Assertions.assertThat(sanitizer.sanitize(sanitizableDataSecret, SHOW_UNSANITIZED)).isEqualTo(SANITIZED_VALUE);
|
||||
Assertions.assertThat(sanitizer.sanitize(sanitizableDataMount, SHOW_UNSANITIZED)).isEqualTo("abc");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.kubernetes.commons.config;
|
||||
import java.time.Duration;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -38,15 +38,15 @@ class ConfigReloadPropertiesTests {
|
||||
void testDefaults() {
|
||||
new ApplicationContextRunner().withUserConfiguration(Config.class).run(context -> {
|
||||
ConfigReloadProperties properties = context.getBean(ConfigReloadProperties.class);
|
||||
Assertions.assertNotNull(properties);
|
||||
Assertions.assertFalse(properties.enabled());
|
||||
Assertions.assertTrue(properties.monitoringConfigMaps());
|
||||
Assertions.assertFalse(properties.monitoringSecrets());
|
||||
Assertions.assertEquals(ConfigReloadProperties.ReloadStrategy.REFRESH, properties.strategy());
|
||||
Assertions.assertEquals(ConfigReloadProperties.ReloadDetectionMode.EVENT, properties.mode());
|
||||
Assertions.assertEquals(Duration.ofMillis(15000), properties.period());
|
||||
Assertions.assertTrue(properties.namespaces().isEmpty());
|
||||
Assertions.assertEquals(Duration.ofSeconds(2), properties.maxWaitForRestart());
|
||||
Assertions.assertThat(properties).isNotNull();
|
||||
Assertions.assertThat(properties.enabled()).isFalse();
|
||||
Assertions.assertThat(properties.monitoringConfigMaps()).isTrue();
|
||||
Assertions.assertThat(properties.monitoringSecrets()).isFalse();
|
||||
Assertions.assertThat(ConfigReloadProperties.ReloadStrategy.REFRESH).isEqualTo(properties.strategy());
|
||||
Assertions.assertThat(ConfigReloadProperties.ReloadDetectionMode.EVENT).isEqualTo(properties.mode());
|
||||
Assertions.assertThat(Duration.ofMillis(15000)).isEqualTo(properties.period());
|
||||
Assertions.assertThat(properties.namespaces().isEmpty()).isTrue();
|
||||
Assertions.assertThat(Duration.ofSeconds(2)).isEqualTo(properties.maxWaitForRestart());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,15 +62,15 @@ class ConfigReloadPropertiesTests {
|
||||
"spring.cloud.kubernetes.reload.max-wait-for-restart=5s")
|
||||
.run(context -> {
|
||||
ConfigReloadProperties properties = context.getBean(ConfigReloadProperties.class);
|
||||
Assertions.assertNotNull(properties);
|
||||
Assertions.assertTrue(properties.enabled());
|
||||
Assertions.assertFalse(properties.monitoringConfigMaps());
|
||||
Assertions.assertTrue(properties.monitoringSecrets());
|
||||
Assertions.assertEquals(ConfigReloadProperties.ReloadStrategy.SHUTDOWN, properties.strategy());
|
||||
Assertions.assertEquals(ConfigReloadProperties.ReloadDetectionMode.POLLING, properties.mode());
|
||||
Assertions.assertEquals(Duration.ofMillis(1000), properties.period());
|
||||
Assertions.assertEquals(Set.of("a", "b"), properties.namespaces());
|
||||
Assertions.assertEquals(Duration.ofSeconds(5), properties.maxWaitForRestart());
|
||||
Assertions.assertThat(properties).isNotNull();
|
||||
Assertions.assertThat(properties.enabled()).isTrue();
|
||||
Assertions.assertThat(properties.monitoringConfigMaps()).isFalse();
|
||||
Assertions.assertThat(properties.monitoringSecrets()).isTrue();
|
||||
Assertions.assertThat(ConfigReloadProperties.ReloadStrategy.SHUTDOWN).isEqualTo(properties.strategy());
|
||||
Assertions.assertThat(ConfigReloadProperties.ReloadDetectionMode.POLLING).isEqualTo(properties.mode());
|
||||
Assertions.assertThat(Duration.ofMillis(1000)).isEqualTo(properties.period());
|
||||
Assertions.assertThat(properties.namespaces()).containsExactlyInAnyOrder("a", "b");
|
||||
Assertions.assertThat(Duration.ofSeconds(5)).isEqualTo(properties.maxWaitForRestart());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.kubernetes.commons.config;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ class ConfigUtilsRawDataContainsProfileBasedSourceTests {
|
||||
Map<String, String> rawData = null;
|
||||
|
||||
boolean result = ConfigUtils.rawDataContainsProfileBasedSource(activeProfiles, rawData).getAsBoolean();
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -44,7 +44,7 @@ class ConfigUtilsRawDataContainsProfileBasedSourceTests {
|
||||
Map<String, String> rawData = Map.of("account-k8s.yaml", "value");
|
||||
|
||||
boolean result = ConfigUtils.rawDataContainsProfileBasedSource(activeProfiles, rawData).getAsBoolean();
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,7 +53,7 @@ class ConfigUtilsRawDataContainsProfileBasedSourceTests {
|
||||
Map<String, String> rawData = Map.of("account", "value");
|
||||
|
||||
boolean result = ConfigUtils.rawDataContainsProfileBasedSource(activeProfiles, rawData).getAsBoolean();
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,7 +62,7 @@ class ConfigUtilsRawDataContainsProfileBasedSourceTests {
|
||||
Map<String, String> rawData = Map.of("account-dev.yml", "value");
|
||||
|
||||
boolean result = ConfigUtils.rawDataContainsProfileBasedSource(activeProfiles, rawData).getAsBoolean();
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,7 +71,7 @@ class ConfigUtilsRawDataContainsProfileBasedSourceTests {
|
||||
Map<String, String> rawData = Map.of("account-dev.yml", "value");
|
||||
|
||||
boolean result = ConfigUtils.rawDataContainsProfileBasedSource(activeProfiles, rawData).getAsBoolean();
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +80,7 @@ class ConfigUtilsRawDataContainsProfileBasedSourceTests {
|
||||
Map<String, String> rawData = Map.of("account-dev.yaml", "value");
|
||||
|
||||
boolean result = ConfigUtils.rawDataContainsProfileBasedSource(activeProfiles, rawData).getAsBoolean();
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,7 +89,7 @@ class ConfigUtilsRawDataContainsProfileBasedSourceTests {
|
||||
Map<String, String> rawData = Map.of("account-dev.properties", "value");
|
||||
|
||||
boolean result = ConfigUtils.rawDataContainsProfileBasedSource(activeProfiles, rawData).getAsBoolean();
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
@@ -36,54 +36,54 @@ class ConfigUtilsTests {
|
||||
@Test
|
||||
void testExplicitPrefixSet() {
|
||||
ConfigUtils.Prefix result = ConfigUtils.findPrefix("explicitPrefix", null, false, "irrelevant");
|
||||
Assertions.assertSame(result, ConfigUtils.Prefix.KNOWN);
|
||||
Assertions.assertEquals(result.prefixProvider().get(), "explicitPrefix");
|
||||
Assertions.assertThat(result).isSameAs(ConfigUtils.Prefix.KNOWN);
|
||||
Assertions.assertThat(result.prefixProvider().get()).isEqualTo("explicitPrefix");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUseNameAsPrefixTrue() {
|
||||
ConfigUtils.Prefix result = ConfigUtils.findPrefix("", Boolean.TRUE, false, "name-to-use");
|
||||
Assertions.assertSame(result, ConfigUtils.Prefix.KNOWN);
|
||||
Assertions.assertEquals(result.prefixProvider().get(), "name-to-use");
|
||||
Assertions.assertThat(result).isSameAs(ConfigUtils.Prefix.KNOWN);
|
||||
Assertions.assertThat(result.prefixProvider().get()).isEqualTo("name-to-use");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUseNameAsPrefixFalse() {
|
||||
ConfigUtils.Prefix result = ConfigUtils.findPrefix("", Boolean.FALSE, false, "name-not-to-use");
|
||||
Assertions.assertSame(result, ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertThat(result).isSameAs(ConfigUtils.Prefix.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultUseNameAsPrefixTrue() {
|
||||
ConfigUtils.Prefix result = ConfigUtils.findPrefix("", null, true, "name-to-use");
|
||||
Assertions.assertSame(result, ConfigUtils.Prefix.KNOWN);
|
||||
Assertions.assertEquals(result.prefixProvider().get(), "name-to-use");
|
||||
Assertions.assertThat(result).isSameAs(ConfigUtils.Prefix.KNOWN);
|
||||
Assertions.assertThat(result.prefixProvider().get()).isEqualTo("name-to-use");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoMatch() {
|
||||
ConfigUtils.Prefix result = ConfigUtils.findPrefix("", null, false, "name-not-to-use");
|
||||
Assertions.assertSame(result, ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertThat(result).isSameAs(ConfigUtils.Prefix.DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnsetEmpty() {
|
||||
ConfigUtils.Prefix result = ConfigUtils.findPrefix("", null, false, "name-not-to-use");
|
||||
Assertions.assertSame(result, ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertThat(result).isSameAs(ConfigUtils.Prefix.DEFAULT);
|
||||
|
||||
String expected = Assertions.assertDoesNotThrow(() -> result.prefixProvider().get());
|
||||
Assertions.assertEquals("", expected);
|
||||
String[] expected = new String[1];
|
||||
Assertions.assertThatCode(() -> expected[0] = result.prefixProvider().get()).doesNotThrowAnyException();
|
||||
Assertions.assertThat(expected[0]).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDelayed() {
|
||||
ConfigUtils.Prefix result = ConfigUtils.findPrefix(null, true, false, null);
|
||||
Assertions.assertSame(result, ConfigUtils.Prefix.DELAYED);
|
||||
Assertions.assertThat(result).isSameAs(ConfigUtils.Prefix.DELAYED);
|
||||
|
||||
IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException.class,
|
||||
() -> result.prefixProvider().get());
|
||||
Assertions.assertThatThrownBy(() -> result.prefixProvider().get()).isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("prefix is delayed, needs to be taken elsewhere");
|
||||
|
||||
Assertions.assertEquals("prefix is delayed, needs to be taken elsewhere", ex.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ class ConfigUtilsTests {
|
||||
*/
|
||||
@Test
|
||||
void testUseIncludeProfileSpecificSourcesOnlyDefaultSet() {
|
||||
Assertions.assertTrue(ConfigUtils.includeProfileSpecificSources(true, null));
|
||||
Assertions.assertThat(ConfigUtils.includeProfileSpecificSources(true, null)).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ class ConfigUtilsTests {
|
||||
*/
|
||||
@Test
|
||||
void testUseIncludeProfileSpecificSourcesOnlyDefaultNotSet() {
|
||||
Assertions.assertFalse(ConfigUtils.includeProfileSpecificSources(false, null));
|
||||
Assertions.assertThat(ConfigUtils.includeProfileSpecificSources(false, null)).isFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ class ConfigUtilsTests {
|
||||
*/
|
||||
@Test
|
||||
void testUseIncludeProfileSpecificSourcesSourcesOverridesDefault() {
|
||||
Assertions.assertFalse(ConfigUtils.includeProfileSpecificSources(true, false));
|
||||
Assertions.assertThat(ConfigUtils.includeProfileSpecificSources(true, false)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,10 +144,10 @@ class ConfigUtilsTests {
|
||||
|
||||
SourceData result = ConfigUtils.withPrefix("configmap", context);
|
||||
|
||||
Assertions.assertEquals(result.sourceName(), "configmap.name1.name2.namespace");
|
||||
Assertions.assertThat(result.sourceName()).isEqualTo("configmap.name1.name2.namespace");
|
||||
|
||||
Assertions.assertEquals(result.sourceData().get("prefix.a"), "b");
|
||||
Assertions.assertEquals(result.sourceData().get("prefix.c"), "d");
|
||||
Assertions.assertThat(result.sourceData().get("prefix.a")).isEqualTo("b");
|
||||
Assertions.assertThat(result.sourceData().get("prefix.c")).isEqualTo("d");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -159,10 +159,10 @@ class ConfigUtilsTests {
|
||||
Set.of("namec", "namea", "nameb"));
|
||||
|
||||
SourceData result = ConfigUtils.withPrefix("configmap", context);
|
||||
Assertions.assertEquals(result.sourceName(), "configmap.namea.nameb.namec.namespace");
|
||||
Assertions.assertThat(result.sourceName()).isEqualTo("configmap.namea.nameb.namec.namespace");
|
||||
|
||||
Assertions.assertEquals(result.sourceData().get("prefix.a"), "b");
|
||||
Assertions.assertEquals(result.sourceData().get("prefix.c"), "d");
|
||||
Assertions.assertThat(result.sourceData().get("prefix.a")).isEqualTo("b");
|
||||
Assertions.assertThat(result.sourceData().get("prefix.c")).isEqualTo("d");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,36 +190,36 @@ class ConfigUtilsTests {
|
||||
MultipleSourcesContainer result = ConfigUtils.processNamedData(List.of(configMapOne, configMapOneK8s),
|
||||
new MockEnvironment(), sourceNames, "default", false);
|
||||
|
||||
Assertions.assertEquals(result.data().size(), 3);
|
||||
Assertions.assertEquals(result.data().get("propA"), "AA");
|
||||
Assertions.assertEquals(result.data().get("propB"), "B");
|
||||
Assertions.assertEquals(result.data().get("propC"), "C");
|
||||
Assertions.assertThat(result.data().size()).isEqualTo(3);
|
||||
Assertions.assertThat(result.data().get("propA")).isEqualTo("AA");
|
||||
Assertions.assertThat(result.data().get("propB")).isEqualTo("B");
|
||||
Assertions.assertThat(result.data().get("propC")).isEqualTo("C");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKeysWithPrefixNullMap() {
|
||||
Map<String, String> result = ConfigUtils.keysWithPrefix(null, "");
|
||||
Assertions.assertTrue(result.isEmpty());
|
||||
Assertions.assertThat(result.isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKeysWithPrefixEmptyMap() {
|
||||
Map<String, String> result = ConfigUtils.keysWithPrefix(Map.of(), "");
|
||||
Assertions.assertTrue(result.isEmpty());
|
||||
Assertions.assertThat(result.isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKeysWithPrefixEmptyPrefix() {
|
||||
Map<String, String> result = ConfigUtils.keysWithPrefix(Map.of("a", "b"), "");
|
||||
Assertions.assertFalse(result.isEmpty());
|
||||
Assertions.assertEquals(Map.of("a", "b"), result);
|
||||
Assertions.assertThat(result.isEmpty()).isFalse();
|
||||
Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("a", "b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKeysWithPrefixNonEmptyPrefix() {
|
||||
Map<String, String> result = ConfigUtils.keysWithPrefix(Map.of("a", "b", "c", "d"), "prefix-");
|
||||
Assertions.assertFalse(result.isEmpty());
|
||||
Assertions.assertEquals(Map.of("prefix-a", "b", "prefix-c", "d"), result);
|
||||
Assertions.assertThat(result.isEmpty()).isFalse();
|
||||
Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("prefix-a", "b", "prefix-c", "d"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.kubernetes.commons.config;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.BootstrapRegistry;
|
||||
@@ -60,7 +60,7 @@ class KubernetesConfigDataLoaderTests {
|
||||
@Test
|
||||
void testIsLoadable() {
|
||||
KubernetesConfigDataLoader loader = new KubernetesConfigDataLoader();
|
||||
Assertions.assertTrue(loader.isLoadable(null, null));
|
||||
Assertions.assertThat(loader.isLoadable(null, null)).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,14 +76,14 @@ class KubernetesConfigDataLoaderTests {
|
||||
|
||||
MockPropertySource propertySource = new MockPropertySource("k8s");
|
||||
|
||||
Assertions.assertNotNull(configData);
|
||||
Assertions.assertEquals(0, configData.getPropertySources().size());
|
||||
Assertions.assertThat(configData).isNotNull();
|
||||
Assertions.assertThat(configData.getPropertySources()).isEmpty();
|
||||
ConfigData.Options options = configData.getOptions(propertySource);
|
||||
Assertions.assertNotNull(options);
|
||||
Assertions.assertTrue(options.contains(ConfigData.Option.IGNORE_IMPORTS));
|
||||
Assertions.assertTrue(options.contains(ConfigData.Option.IGNORE_PROFILES));
|
||||
Assertions.assertThat(options).isNotNull();
|
||||
Assertions.assertThat(options.contains(ConfigData.Option.IGNORE_IMPORTS)).isTrue();
|
||||
Assertions.assertThat(options.contains(ConfigData.Option.IGNORE_PROFILES)).isTrue();
|
||||
|
||||
Assertions.assertFalse(options.contains(ConfigData.Option.PROFILE_SPECIFIC));
|
||||
Assertions.assertThat(options.contains(ConfigData.Option.PROFILE_SPECIFIC)).isFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,14 +101,14 @@ class KubernetesConfigDataLoaderTests {
|
||||
|
||||
MockPropertySource propertySource = new MockPropertySource("k8s-dev");
|
||||
|
||||
Assertions.assertNotNull(configData);
|
||||
Assertions.assertEquals(0, configData.getPropertySources().size());
|
||||
Assertions.assertThat(configData).isNotNull();
|
||||
Assertions.assertThat(configData.getPropertySources()).isEmpty();
|
||||
ConfigData.Options options = configData.getOptions(propertySource);
|
||||
Assertions.assertNotNull(options);
|
||||
Assertions.assertTrue(options.contains(ConfigData.Option.IGNORE_IMPORTS));
|
||||
Assertions.assertTrue(options.contains(ConfigData.Option.IGNORE_PROFILES));
|
||||
Assertions.assertThat(options).isNotNull();
|
||||
Assertions.assertThat(options.contains(ConfigData.Option.IGNORE_IMPORTS)).isTrue();
|
||||
Assertions.assertThat(options.contains(ConfigData.Option.IGNORE_PROFILES)).isTrue();
|
||||
|
||||
Assertions.assertTrue(options.contains(ConfigData.Option.PROFILE_SPECIFIC));
|
||||
Assertions.assertThat(options.contains(ConfigData.Option.PROFILE_SPECIFIC)).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,10 +135,10 @@ class KubernetesConfigDataLoaderTests {
|
||||
|
||||
KubernetesConfigDataLoader loader = new KubernetesConfigDataLoader();
|
||||
ConfigData configData = loader.load(CONTEXT, EMPTY_RESOURCE);
|
||||
Assertions.assertNotNull(configData);
|
||||
Assertions.assertEquals(2, configData.getPropertySources().size());
|
||||
Assertions.assertEquals("k8s-secrets", configData.getPropertySources().get(0).getName());
|
||||
Assertions.assertEquals("k8s-config-map", configData.getPropertySources().get(1).getName());
|
||||
Assertions.assertThat(configData).isNotNull();
|
||||
Assertions.assertThat(configData.getPropertySources().size()).isEqualTo(2);
|
||||
Assertions.assertThat(configData.getPropertySources().get(0).getName()).isEqualTo("k8s-secrets");
|
||||
Assertions.assertThat(configData.getPropertySources().get(1).getName()).isEqualTo("k8s-config-map");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -58,7 +58,7 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
|
||||
@Test
|
||||
void testGetPrefix() {
|
||||
Assertions.assertEquals("kubernetes:", NOOP_RESOLVER.getPrefix());
|
||||
Assertions.assertThat(NOOP_RESOLVER.getPrefix()).isEqualTo("kubernetes:");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
|
||||
ConfigDataLocation configDataLocation = ConfigDataLocation.of("kubernetes:abc");
|
||||
boolean result = NOOP_RESOLVER.isResolvable(RESOLVER_CONTEXT, configDataLocation);
|
||||
Assertions.assertTrue(result);
|
||||
Assertions.assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,14 +88,14 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
|
||||
ConfigDataLocation configDataLocation = ConfigDataLocation.of("kubernetes:abc");
|
||||
boolean result = NOOP_RESOLVER.isResolvable(RESOLVER_CONTEXT, configDataLocation);
|
||||
Assertions.assertFalse(result);
|
||||
Assertions.assertThat(result).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testResolve() {
|
||||
ConfigDataLocation configDataLocation = ConfigDataLocation.of("kubernetes:abc");
|
||||
List<KubernetesConfigDataResource> result = NOOP_RESOLVER.resolve(RESOLVER_CONTEXT, configDataLocation);
|
||||
Assertions.assertEquals(0, result.size());
|
||||
Assertions.assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,14 +123,14 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
List<KubernetesConfigDataResource> result = NOOP_RESOLVER.resolveProfileSpecific(RESOLVER_CONTEXT,
|
||||
configDataLocation, profiles);
|
||||
|
||||
Assertions.assertEquals(1, result.size());
|
||||
Assertions.assertEquals("k8s-app-name",
|
||||
result.get(0).getEnvironment().getRequiredProperty("spring.application.name"));
|
||||
Assertions.assertEquals("non-default-namespace",
|
||||
result.get(0).getEnvironment().getRequiredProperty("spring.cloud.kubernetes.client.namespace"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result.get(0).getEnvironment().getRequiredProperty("spring.application.name"))
|
||||
.isEqualTo("k8s-app-name");
|
||||
Assertions.assertThat(result.get(0).getEnvironment().getRequiredProperty("spring.cloud.kubernetes.client.namespace"))
|
||||
.isEqualTo("non-default-namespace");
|
||||
// ensures that we called 'bindOrCreate' and as such @Default is picked-up
|
||||
Assertions.assertEquals("Spring-Cloud-Kubernetes-Application", result.get(0).getProperties().userAgent());
|
||||
Assertions.assertEquals("non-default-namespace", result.get(0).getProperties().namespace());
|
||||
Assertions.assertThat(result.get(0).getProperties().userAgent()).isEqualTo("Spring-Cloud-Kubernetes-Application");
|
||||
Assertions.assertThat(result.get(0).getProperties().namespace()).isEqualTo("non-default-namespace");
|
||||
|
||||
}
|
||||
|
||||
@@ -165,14 +165,14 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
List<KubernetesConfigDataResource> result = NOOP_RESOLVER.resolveProfileSpecific(RESOLVER_CONTEXT,
|
||||
configDataLocation, profiles);
|
||||
|
||||
Assertions.assertEquals(1, result.size());
|
||||
Assertions.assertEquals("k8s-app-name",
|
||||
result.get(0).getEnvironment().getRequiredProperty("spring.application.name"));
|
||||
Assertions.assertEquals("non-default-namespace",
|
||||
result.get(0).getEnvironment().getRequiredProperty("spring.cloud.kubernetes.client.namespace"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result.get(0).getEnvironment().getRequiredProperty("spring.application.name"))
|
||||
.isEqualTo("k8s-app-name");
|
||||
Assertions.assertThat(result.get(0).getEnvironment().getRequiredProperty("spring.cloud.kubernetes.client.namespace"))
|
||||
.isEqualTo("non-default-namespace");
|
||||
// ensures we bind existing from bootstrap context, and not call 'bindOrCreate'
|
||||
Assertions.assertEquals("user-agent", result.get(0).getProperties().userAgent());
|
||||
Assertions.assertEquals("non-default-namespace", result.get(0).getProperties().namespace());
|
||||
Assertions.assertThat(result.get(0).getProperties().userAgent()).isEqualTo("user-agent");
|
||||
Assertions.assertThat(result.get(0).getProperties().namespace()).isEqualTo("non-default-namespace");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,9 +198,9 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
SecretsConfigProperties secretsConfigProperties = RESOLVER_CONTEXT.getBootstrapContext()
|
||||
.get(SecretsConfigProperties.class);
|
||||
|
||||
Assertions.assertNotNull(kubernetesClientProperties);
|
||||
Assertions.assertNotNull(configMapConfigProperties);
|
||||
Assertions.assertNotNull(secretsConfigProperties);
|
||||
Assertions.assertThat(kubernetesClientProperties).isNotNull();
|
||||
Assertions.assertThat(configMapConfigProperties).isNotNull();
|
||||
Assertions.assertThat(secretsConfigProperties).isNotNull();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,9 +237,9 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
SecretsConfigProperties secretsConfigProperties = RESOLVER_CONTEXT.getBootstrapContext()
|
||||
.getOrElse(SecretsConfigProperties.class, two);
|
||||
|
||||
Assertions.assertNotNull(kubernetesClientProperties);
|
||||
Assertions.assertSame(one, configMapConfigProperties);
|
||||
Assertions.assertSame(two, secretsConfigProperties);
|
||||
Assertions.assertThat(kubernetesClientProperties).isNotNull();
|
||||
Assertions.assertThat(one).isSameAs(configMapConfigProperties);
|
||||
Assertions.assertThat(two).isSameAs(secretsConfigProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,10 +261,10 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
configDataLocation, profiles);
|
||||
|
||||
// we have @DefaultValue("true") boolean enableApi
|
||||
Assertions.assertTrue(result.get(0).getConfigMapProperties().enableApi());
|
||||
Assertions.assertThat(result.get(0).getConfigMapProperties().enableApi()).isTrue();
|
||||
|
||||
// we have @DefaultValue("true") boolean enabled
|
||||
Assertions.assertTrue(result.get(0).getSecretsConfigProperties().enabled());
|
||||
Assertions.assertThat(result.get(0).getSecretsConfigProperties().enabled()).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,15 +290,15 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
// we have @DefaultValue("true") boolean enableApi, but it is not going to be
|
||||
// picked up
|
||||
// because of the explicit property we set in environment
|
||||
Assertions.assertFalse(result.get(0).getConfigMapProperties().enableApi());
|
||||
Assertions.assertThat(result.get(0).getConfigMapProperties().enableApi()).isFalse();
|
||||
// on the other hand, @Default will be picked here
|
||||
Assertions.assertTrue(result.get(0).getConfigMapProperties().enabled());
|
||||
Assertions.assertThat(result.get(0).getConfigMapProperties().enabled()).isTrue();
|
||||
|
||||
// we have @DefaultValue enabled on paths, but it is not going to be picked up
|
||||
// because of the explicit property we set in environment
|
||||
Assertions.assertEquals("a", result.get(0).getSecretsConfigProperties().paths().get(0));
|
||||
Assertions.assertThat(result.get(0).getSecretsConfigProperties().paths().get(0)).isEqualTo("a");
|
||||
// on the other hand, @Default will be picked here
|
||||
Assertions.assertTrue(result.get(0).getSecretsConfigProperties().includeProfileSpecificSources());
|
||||
Assertions.assertThat(result.get(0).getSecretsConfigProperties().includeProfileSpecificSources()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -315,7 +315,7 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
List<KubernetesConfigDataResource> result = NOOP_RESOLVER.resolveProfileSpecific(RESOLVER_CONTEXT,
|
||||
configDataLocation, profiles);
|
||||
|
||||
Assertions.assertFalse(result.get(0).isOptional());
|
||||
Assertions.assertThat(result.get(0).isOptional()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -334,9 +334,9 @@ class KubernetesConfigDataLocationResolverTests {
|
||||
List<KubernetesConfigDataResource> result = NOOP_RESOLVER.resolveProfileSpecific(RESOLVER_CONTEXT,
|
||||
configDataLocation, profiles);
|
||||
|
||||
Assertions.assertEquals(List.of("a", "b"),
|
||||
Arrays.stream(result.get(0).getEnvironment().getActiveProfiles()).toList());
|
||||
Assertions.assertEquals("a,b", result.get(0).getProfiles());
|
||||
Assertions.assertThat(Arrays.stream(result.get(0).getEnvironment().getActiveProfiles()).toList())
|
||||
.containsExactly("a", "b");
|
||||
Assertions.assertThat(result.get(0).getProfiles()).isEqualTo("a,b");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.kubernetes.commons.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -35,44 +35,44 @@ class LabeledConfigMapNormalizedSourceTests {
|
||||
LabeledConfigMapNormalizedSource right = new LabeledConfigMapNormalizedSource("name", Map.of("key", "value"),
|
||||
true, false);
|
||||
|
||||
Assertions.assertEquals(left.hashCode(), right.hashCode());
|
||||
Assertions.assertEquals(left, right);
|
||||
Assertions.assertThat(left.hashCode()).isEqualTo(right.hashCode());
|
||||
Assertions.assertThat(left).isEqualTo(right);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testType() {
|
||||
LabeledConfigMapNormalizedSource source = new LabeledConfigMapNormalizedSource("name", Map.of("key", "value"),
|
||||
false, false);
|
||||
Assertions.assertSame(source.type(), NormalizedSourceType.LABELED_CONFIG_MAP);
|
||||
Assertions.assertThat(source.type()).isSameAs(NormalizedSourceType.LABELED_CONFIG_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTarget() {
|
||||
LabeledConfigMapNormalizedSource source = new LabeledConfigMapNormalizedSource("name", Map.of("key", "value"),
|
||||
false, false);
|
||||
Assertions.assertEquals(source.target(), "configmap");
|
||||
Assertions.assertThat(source.target()).isEqualTo("configmap");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructorFields() {
|
||||
LabeledConfigMapNormalizedSource source = new LabeledConfigMapNormalizedSource("namespace",
|
||||
Map.of("key", "value"), false, PREFIX, true);
|
||||
Assertions.assertEquals(source.labels(), Map.of("key", "value"));
|
||||
Assertions.assertEquals(source.namespace().get(), "namespace");
|
||||
Assertions.assertFalse(source.failFast());
|
||||
Assertions.assertSame(PREFIX, source.prefix());
|
||||
Assertions.assertTrue(source.profileSpecificSources());
|
||||
Assertions.assertThat(source.labels()).containsExactlyInAnyOrderEntriesOf(Map.of("key", "value"));
|
||||
Assertions.assertThat(source.namespace().get()).isEqualTo("namespace");
|
||||
Assertions.assertThat(source.failFast()).isFalse();
|
||||
Assertions.assertThat(PREFIX).isSameAs(source.prefix());
|
||||
Assertions.assertThat(source.profileSpecificSources()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructorWithoutPrefixFields() {
|
||||
LabeledConfigMapNormalizedSource source = new LabeledConfigMapNormalizedSource("namespace",
|
||||
Map.of("key", "value"), true, true);
|
||||
Assertions.assertEquals(source.labels(), Map.of("key", "value"));
|
||||
Assertions.assertEquals(source.namespace().get(), "namespace");
|
||||
Assertions.assertTrue(source.failFast());
|
||||
Assertions.assertSame(ConfigUtils.Prefix.DEFAULT, source.prefix());
|
||||
Assertions.assertTrue(source.profileSpecificSources());
|
||||
Assertions.assertThat(source.labels()).containsExactlyInAnyOrderEntriesOf(Map.of("key", "value"));
|
||||
Assertions.assertThat(source.namespace().get()).isEqualTo("namespace");
|
||||
Assertions.assertThat(source.failFast()).isTrue();
|
||||
Assertions.assertThat(ConfigUtils.Prefix.DEFAULT).isSameAs(source.prefix());
|
||||
Assertions.assertThat(source.profileSpecificSources()).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.kubernetes.commons.config;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,8 @@ class LabeledSecretNormalizedSourceTests {
|
||||
LabeledSecretNormalizedSource left = new LabeledSecretNormalizedSource("namespace", labels, false, false);
|
||||
LabeledSecretNormalizedSource right = new LabeledSecretNormalizedSource("namespace", labels, true, false);
|
||||
|
||||
Assertions.assertEquals(left.hashCode(), right.hashCode());
|
||||
Assertions.assertEquals(left, right);
|
||||
Assertions.assertThat(left.hashCode()).isEqualTo(right.hashCode());
|
||||
Assertions.assertThat(left).isEqualTo(right);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -53,26 +53,26 @@ class LabeledSecretNormalizedSourceTests {
|
||||
LabeledSecretNormalizedSource right = new LabeledSecretNormalizedSource("namespace", labels, true, knownRight,
|
||||
false);
|
||||
|
||||
Assertions.assertEquals(left.hashCode(), right.hashCode());
|
||||
Assertions.assertEquals(left, right);
|
||||
Assertions.assertThat(left.hashCode()).isEqualTo(right.hashCode());
|
||||
Assertions.assertThat(left).isEqualTo(right);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testType() {
|
||||
LabeledSecretNormalizedSource source = new LabeledSecretNormalizedSource("namespace", labels, false, false);
|
||||
Assertions.assertSame(source.type(), NormalizedSourceType.LABELED_SECRET);
|
||||
Assertions.assertThat(source.type()).isSameAs(NormalizedSourceType.LABELED_SECRET);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testImmutableGetLabels() {
|
||||
LabeledSecretNormalizedSource source = new LabeledSecretNormalizedSource("namespace", labels, false, false);
|
||||
Assertions.assertThrows(RuntimeException.class, () -> source.labels().put("c", "d"));
|
||||
Assertions.assertThatThrownBy(() -> source.labels().put("c", "d")).isInstanceOf(RuntimeException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTarget() {
|
||||
LabeledSecretNormalizedSource source = new LabeledSecretNormalizedSource("namespace", labels, false, false);
|
||||
Assertions.assertEquals(source.target(), "secret");
|
||||
Assertions.assertThat(source.target()).isEqualTo("secret");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,19 +80,19 @@ class LabeledSecretNormalizedSourceTests {
|
||||
ConfigUtils.Prefix prefix = ConfigUtils.findPrefix("prefix", false, false, "some");
|
||||
LabeledSecretNormalizedSource source = new LabeledSecretNormalizedSource("namespace", labels, false, prefix,
|
||||
true);
|
||||
Assertions.assertTrue(source.name().isEmpty());
|
||||
Assertions.assertEquals(source.namespace().get(), "namespace");
|
||||
Assertions.assertFalse(source.failFast());
|
||||
Assertions.assertTrue(source.profileSpecificSources());
|
||||
Assertions.assertThat(source.name().isEmpty()).isTrue();
|
||||
Assertions.assertThat(source.namespace().get()).isEqualTo("namespace");
|
||||
Assertions.assertThat(source.failFast()).isFalse();
|
||||
Assertions.assertThat(source.profileSpecificSources()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructorWithoutPrefixFields() {
|
||||
LabeledSecretNormalizedSource source = new LabeledSecretNormalizedSource("namespace", labels, true, true);
|
||||
Assertions.assertEquals(source.namespace().get(), "namespace");
|
||||
Assertions.assertTrue(source.failFast());
|
||||
Assertions.assertSame(ConfigUtils.Prefix.DEFAULT, source.prefix());
|
||||
Assertions.assertTrue(source.profileSpecificSources());
|
||||
Assertions.assertThat(source.namespace().get()).isEqualTo("namespace");
|
||||
Assertions.assertThat(source.failFast()).isTrue();
|
||||
Assertions.assertThat(ConfigUtils.Prefix.DEFAULT).isSameAs(source.prefix());
|
||||
Assertions.assertThat(source.profileSpecificSources()).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.commons.config;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -37,8 +37,8 @@ class NamedConfigMapNormalizedSourceTests {
|
||||
NamedConfigMapNormalizedSource right = new NamedConfigMapNormalizedSource("name", "namespace", true, knownRight,
|
||||
false);
|
||||
|
||||
Assertions.assertEquals(left.hashCode(), right.hashCode());
|
||||
Assertions.assertEquals(left, right);
|
||||
Assertions.assertThat(left.hashCode()).isEqualTo(right.hashCode());
|
||||
Assertions.assertThat(left).isEqualTo(right);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -46,23 +46,23 @@ class NamedConfigMapNormalizedSourceTests {
|
||||
|
||||
NamedConfigMapNormalizedSource one = new NamedConfigMapNormalizedSource("name", "namespace", false, PREFIX,
|
||||
true);
|
||||
Assertions.assertSame(one.type(), NormalizedSourceType.NAMED_CONFIG_MAP);
|
||||
Assertions.assertThat(one.type()).isSameAs(NormalizedSourceType.NAMED_CONFIG_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTarget() {
|
||||
NamedConfigMapNormalizedSource one = new NamedConfigMapNormalizedSource("name", "namespace", false, PREFIX,
|
||||
true);
|
||||
Assertions.assertEquals(one.target(), "configmap");
|
||||
Assertions.assertThat(one.target()).isEqualTo("configmap");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructorFields() {
|
||||
NamedConfigMapNormalizedSource one = new NamedConfigMapNormalizedSource("name", "namespace", false, PREFIX,
|
||||
true);
|
||||
Assertions.assertEquals(one.name().get(), "name");
|
||||
Assertions.assertEquals(one.namespace().get(), "namespace");
|
||||
Assertions.assertFalse(one.failFast());
|
||||
Assertions.assertThat(one.name().get()).isEqualTo("name");
|
||||
Assertions.assertThat(one.namespace().get()).isEqualTo("namespace");
|
||||
Assertions.assertThat(one.failFast()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.commons.config;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -31,40 +31,40 @@ class NamedSecretNormalizedSourceTests {
|
||||
NamedSecretNormalizedSource left = new NamedSecretNormalizedSource("name", "namespace", false, false);
|
||||
NamedSecretNormalizedSource right = new NamedSecretNormalizedSource("name", "namespace", true, false);
|
||||
|
||||
Assertions.assertEquals(left.hashCode(), right.hashCode());
|
||||
Assertions.assertEquals(left, right);
|
||||
Assertions.assertThat(left.hashCode()).isEqualTo(right.hashCode());
|
||||
Assertions.assertThat(left).isEqualTo(right);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testType() {
|
||||
NamedSecretNormalizedSource source = new NamedSecretNormalizedSource("name", "namespace", false, false);
|
||||
Assertions.assertSame(source.type(), NormalizedSourceType.NAMED_SECRET);
|
||||
Assertions.assertThat(source.type()).isEqualTo(NormalizedSourceType.NAMED_SECRET);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTarget() {
|
||||
NamedSecretNormalizedSource source = new NamedSecretNormalizedSource("name", "namespace", false, false);
|
||||
Assertions.assertEquals(source.target(), "secret");
|
||||
Assertions.assertThat(source.target()).isEqualTo("secret");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructorFields() {
|
||||
NamedSecretNormalizedSource source = new NamedSecretNormalizedSource("name", "namespace", false, PREFIX, true);
|
||||
Assertions.assertEquals(source.name().get(), "name");
|
||||
Assertions.assertEquals(source.namespace().get(), "namespace");
|
||||
Assertions.assertFalse(source.failFast());
|
||||
Assertions.assertSame(PREFIX, source.prefix());
|
||||
Assertions.assertTrue(source.profileSpecificSources());
|
||||
Assertions.assertThat(source.name().get()).isEqualTo("name");
|
||||
Assertions.assertThat(source.namespace().get()).isEqualTo("namespace");
|
||||
Assertions.assertThat(source.failFast()).isFalse();
|
||||
Assertions.assertThat(source.prefix()).isEqualTo(PREFIX);
|
||||
Assertions.assertThat(source.profileSpecificSources()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConstructorWithoutPrefixFields() {
|
||||
NamedSecretNormalizedSource source = new NamedSecretNormalizedSource("name", "namespace", true, true);
|
||||
Assertions.assertEquals(source.name().get(), "name");
|
||||
Assertions.assertEquals(source.namespace().get(), "namespace");
|
||||
Assertions.assertTrue(source.failFast());
|
||||
Assertions.assertSame(ConfigUtils.Prefix.DEFAULT, source.prefix());
|
||||
Assertions.assertTrue(source.profileSpecificSources());
|
||||
Assertions.assertThat(source.name().get()).isEqualTo("name");
|
||||
Assertions.assertThat(source.namespace().get()).isEqualTo("namespace");
|
||||
Assertions.assertThat(source.failFast()).isFalse();
|
||||
Assertions.assertThat(ConfigUtils.Prefix.DEFAULT).isSameAs(source.prefix());
|
||||
Assertions.assertThat(source.profileSpecificSources()).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.commons.config;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -35,24 +35,24 @@ class SecretsConfigPropertiesBindingTests {
|
||||
void testWithDefaults() {
|
||||
new ApplicationContextRunner().withUserConfiguration(Config.class).run(context -> {
|
||||
SecretsConfigProperties props = context.getBean(SecretsConfigProperties.class);
|
||||
Assertions.assertNotNull(props);
|
||||
Assertions.assertFalse(props.enableApi());
|
||||
Assertions.assertTrue(props.paths().isEmpty());
|
||||
Assertions.assertTrue(props.sources().isEmpty());
|
||||
Assertions.assertTrue(props.labels().isEmpty());
|
||||
Assertions.assertTrue(props.enabled());
|
||||
Assertions.assertNull(props.name());
|
||||
Assertions.assertNull(props.namespace());
|
||||
Assertions.assertFalse(props.useNameAsPrefix());
|
||||
Assertions.assertTrue(props.includeProfileSpecificSources());
|
||||
Assertions.assertFalse(props.failFast());
|
||||
Assertions.assertThat(props).isNotNull();
|
||||
Assertions.assertThat(props.enableApi()).isFalse();
|
||||
Assertions.assertThat(props.paths()).isEmpty();
|
||||
Assertions.assertThat(props.sources()).isEmpty();
|
||||
Assertions.assertThat(props.labels()).isEmpty();
|
||||
Assertions.assertThat(props.enabled()).isTrue();
|
||||
Assertions.assertThat(props.name()).isNull();
|
||||
Assertions.assertThat(props.namespace()).isNull();
|
||||
Assertions.assertThat(props.useNameAsPrefix()).isFalse();
|
||||
Assertions.assertThat(props.includeProfileSpecificSources()).isTrue();
|
||||
Assertions.assertThat(props.failFast()).isFalse();
|
||||
|
||||
Assertions.assertNotNull(props.retry());
|
||||
Assertions.assertEquals(props.retry().initialInterval(), 1000L);
|
||||
Assertions.assertEquals(props.retry().multiplier(), 1.1D);
|
||||
Assertions.assertEquals(props.retry().maxInterval(), 2000L);
|
||||
Assertions.assertEquals(props.retry().maxAttempts(), 6);
|
||||
Assertions.assertTrue(props.retry().enabled());
|
||||
Assertions.assertThat(props.retry()).isNotNull();
|
||||
Assertions.assertThat(props.retry().initialInterval()).isEqualTo(1000L);
|
||||
Assertions.assertThat(props.retry().multiplier()).isEqualTo(1.1D);
|
||||
Assertions.assertThat(props.retry().maxInterval()).isEqualTo(2000L);
|
||||
Assertions.assertThat(props.retry().maxAttempts()).isEqualTo(6);
|
||||
Assertions.assertThat(props.retry().enabled()).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,39 +80,39 @@ class SecretsConfigPropertiesBindingTests {
|
||||
"spring.cloud.kubernetes.secrets.retry.enabled=false")
|
||||
.run(context -> {
|
||||
SecretsConfigProperties props = context.getBean(SecretsConfigProperties.class);
|
||||
Assertions.assertNotNull(props);
|
||||
Assertions.assertFalse(props.enableApi());
|
||||
Assertions.assertThat(props).isNotNull();
|
||||
Assertions.assertThat(props.enableApi()).isFalse();
|
||||
|
||||
Assertions.assertEquals(props.paths().size(), 2);
|
||||
Assertions.assertEquals(props.paths().get(0), "a");
|
||||
Assertions.assertEquals(props.paths().get(1), "b");
|
||||
Assertions.assertThat(props.paths().size()).isEqualTo(2);
|
||||
Assertions.assertThat(props.paths().get(0)).isEqualTo("a");
|
||||
Assertions.assertThat(props.paths().get(1)).isEqualTo("b");
|
||||
|
||||
Assertions.assertEquals(props.sources().size(), 1);
|
||||
Assertions.assertThat(props.sources().size()).isEqualTo(1);
|
||||
SecretsConfigProperties.Source source = props.sources().get(0);
|
||||
Assertions.assertEquals(source.name(), "source-a");
|
||||
Assertions.assertEquals(source.namespace(), "source-namespace-a");
|
||||
Assertions.assertEquals(source.labels().size(), 1);
|
||||
Assertions.assertEquals(source.labels().get("key"), "source-value");
|
||||
Assertions.assertEquals(source.explicitPrefix(), "source-prefix");
|
||||
Assertions.assertTrue(source.useNameAsPrefix());
|
||||
Assertions.assertTrue(source.includeProfileSpecificSources());
|
||||
Assertions.assertThat(source.name()).isEqualTo("source-a");
|
||||
Assertions.assertThat(source.namespace()).isEqualTo("source-namespace-a");
|
||||
Assertions.assertThat(source.labels().size()).isEqualTo(1);
|
||||
Assertions.assertThat(source.labels().get("key")).isEqualTo("source-value");
|
||||
Assertions.assertThat(source.explicitPrefix()).isEqualTo("source-prefix");
|
||||
Assertions.assertThat(source.useNameAsPrefix()).isTrue();
|
||||
Assertions.assertThat(source.includeProfileSpecificSources()).isTrue();
|
||||
|
||||
Assertions.assertEquals(props.labels().size(), 1);
|
||||
Assertions.assertEquals(props.labels().get("label-a"), "label-a");
|
||||
Assertions.assertThat(props.labels().size()).isEqualTo(1);
|
||||
Assertions.assertThat(props.labels().get("label-a")).isEqualTo("label-a");
|
||||
|
||||
Assertions.assertFalse(props.enabled());
|
||||
Assertions.assertEquals(props.name(), "name");
|
||||
Assertions.assertEquals(props.namespace(), "namespace");
|
||||
Assertions.assertTrue(props.useNameAsPrefix());
|
||||
Assertions.assertTrue(props.includeProfileSpecificSources());
|
||||
Assertions.assertTrue(props.failFast());
|
||||
Assertions.assertThat(props.enabled()).isFalse();
|
||||
Assertions.assertThat(props.name()).isEqualTo("name");
|
||||
Assertions.assertThat(props.namespace()).isEqualTo("namespace");
|
||||
Assertions.assertThat(props.useNameAsPrefix()).isTrue();
|
||||
Assertions.assertThat(props.includeProfileSpecificSources()).isTrue();
|
||||
Assertions.assertThat(props.failFast()).isTrue();
|
||||
|
||||
RetryProperties retryProperties = props.retry();
|
||||
Assertions.assertNotNull(retryProperties);
|
||||
Assertions.assertEquals(retryProperties.initialInterval(), 1);
|
||||
Assertions.assertEquals(retryProperties.multiplier(), 1.2);
|
||||
Assertions.assertEquals(retryProperties.maxInterval(), 3);
|
||||
Assertions.assertFalse(retryProperties.enabled());
|
||||
Assertions.assertThat(retryProperties).isNotNull();
|
||||
Assertions.assertThat(retryProperties.initialInterval()).isEqualTo(1);
|
||||
Assertions.assertThat(retryProperties.multiplier()).isEqualTo(1.2);
|
||||
Assertions.assertThat(retryProperties.maxInterval()).isEqualTo(3);
|
||||
Assertions.assertThat(retryProperties.enabled()).isFalse();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
@@ -43,10 +43,10 @@ class SecretsConfigPropertiesTests {
|
||||
null, "namespace", false, true, false, RetryProperties.DEFAULT);
|
||||
|
||||
List<NormalizedSource> source = properties.determineSources(new MockEnvironment());
|
||||
Assertions.assertEquals(source.size(), 1);
|
||||
Assertions.assertTrue(source.get(0) instanceof NamedSecretNormalizedSource);
|
||||
Assertions.assertTrue(source.get(0).name().isPresent());
|
||||
Assertions.assertEquals(source.get(0).name().get(), "application");
|
||||
Assertions.assertThat(source.size()).isEqualTo(1);
|
||||
Assertions.assertThat(source.get(0) instanceof NamedSecretNormalizedSource).isTrue();
|
||||
Assertions.assertThat(source.get(0).name().isPresent()).isTrue();
|
||||
Assertions.assertThat(source.get(0).name().get()).isEqualTo("application");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,30 +84,27 @@ class SecretsConfigPropertiesTests {
|
||||
List.of(one, two, three), true, null, "namespace", false, true, false, RetryProperties.DEFAULT);
|
||||
|
||||
List<NormalizedSource> result = properties.determineSources(new MockEnvironment());
|
||||
Assertions.assertEquals(result.size(), 6);
|
||||
Assertions.assertThat(result.size()).isEqualTo(6);
|
||||
|
||||
Set<NormalizedSource> resultAsSet = new LinkedHashSet<>(result);
|
||||
Assertions.assertEquals(resultAsSet.size(), 5);
|
||||
Assertions.assertThat(resultAsSet.size()).isEqualTo(5);
|
||||
|
||||
Iterator<NormalizedSource> iterator = resultAsSet.iterator();
|
||||
|
||||
NormalizedSource oneResult = iterator.next();
|
||||
Assertions.assertEquals(oneResult.name().get(), "one");
|
||||
Assertions.assertThat(oneResult.name().get()).isEqualTo("one");
|
||||
|
||||
NormalizedSource twoResult = iterator.next();
|
||||
Assertions.assertEquals(((LabeledSecretNormalizedSource) twoResult).labels(),
|
||||
Collections.singletonMap("one", "1"));
|
||||
Assertions.assertThat(((LabeledSecretNormalizedSource) twoResult).labels()).isEqualTo(Map.of("one", "1"));
|
||||
|
||||
NormalizedSource threeResult = iterator.next();
|
||||
Assertions.assertEquals(threeResult.name().get(), "application");
|
||||
Assertions.assertThat(threeResult.name().get()).isEqualTo("application");
|
||||
|
||||
NormalizedSource fourResult = iterator.next();
|
||||
Assertions.assertEquals(((LabeledSecretNormalizedSource) fourResult).labels(),
|
||||
Collections.singletonMap("two", "2"));
|
||||
Assertions.assertThat(((LabeledSecretNormalizedSource) fourResult).labels()).isEqualTo(Map.of("two", "2"));
|
||||
|
||||
NormalizedSource fiveResult = iterator.next();
|
||||
Assertions.assertEquals(((LabeledSecretNormalizedSource) fiveResult).labels(),
|
||||
Collections.singletonMap("three", "3"));
|
||||
Assertions.assertThat(((LabeledSecretNormalizedSource) fiveResult).labels()).isEqualTo(Map.of("three", "3"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,9 +126,9 @@ class SecretsConfigPropertiesTests {
|
||||
"secret-a", "namespace", false, true, false, RetryProperties.DEFAULT);
|
||||
|
||||
List<NormalizedSource> sources = properties.determineSources(new MockEnvironment());
|
||||
Assertions.assertEquals(sources.size(), 1, "empty sources must generate a List with a single NormalizedSource");
|
||||
Assertions.assertThat(sources.size()).isEqualTo(1);
|
||||
|
||||
Assertions.assertSame(((NamedSecretNormalizedSource) sources.get(0)).prefix(), ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(0)).prefix()).isSameAs(ConfigUtils.Prefix.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,11 +152,9 @@ class SecretsConfigPropertiesTests {
|
||||
"secret-a", "namespace", true, true, false, RetryProperties.DEFAULT);
|
||||
|
||||
List<NormalizedSource> sources = properties.determineSources(new MockEnvironment());
|
||||
Assertions.assertEquals(sources.size(), 1, "empty sources must generate a List with a single NormalizedSource");
|
||||
Assertions.assertThat(sources.size()).isEqualTo(1);
|
||||
|
||||
Assertions.assertSame(((NamedSecretNormalizedSource) sources.get(0)).prefix(), ConfigUtils.Prefix.DEFAULT,
|
||||
"empty sources must generate a List with a single NormalizedSource, where prefix is unset,"
|
||||
+ "no matter of 'spring.cloud.kubernetes.secret.useNameAsPrefix' value");
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(0)).prefix()).isSameAs(ConfigUtils.Prefix.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,10 +182,10 @@ class SecretsConfigPropertiesTests {
|
||||
"secret-one", null, false, true, false, RetryProperties.DEFAULT);
|
||||
|
||||
List<NormalizedSource> sources = properties.determineSources(new MockEnvironment());
|
||||
Assertions.assertEquals(sources.size(), 1, "a single NormalizedSource is expected");
|
||||
Assertions.assertThat(sources.size()).isEqualTo(1);
|
||||
|
||||
Assertions.assertEquals(((NamedSecretNormalizedSource) sources.get(0)).prefix().prefixProvider().get(),
|
||||
"secret-one");
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(0)).prefix().prefixProvider().get()).
|
||||
isEqualTo("secret-one");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,13 +225,13 @@ class SecretsConfigPropertiesTests {
|
||||
List.of(one, two, three), true, "secret-one", null, false, true, false, RetryProperties.DEFAULT);
|
||||
|
||||
List<NormalizedSource> sources = properties.determineSources(new MockEnvironment());
|
||||
Assertions.assertEquals(sources.size(), 3, "3 NormalizedSources are expected");
|
||||
Assertions.assertThat(sources.size()).isEqualTo(3);
|
||||
|
||||
Assertions.assertSame(((NamedSecretNormalizedSource) sources.get(0)).prefix(), ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertEquals(((NamedSecretNormalizedSource) sources.get(1)).prefix().prefixProvider().get(),
|
||||
"secret-two");
|
||||
Assertions.assertEquals(((NamedSecretNormalizedSource) sources.get(2)).prefix().prefixProvider().get(),
|
||||
"secret-three");
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(0)).prefix()).isSameAs(ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(1)).prefix().prefixProvider().get())
|
||||
.isEqualTo("secret-two");
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(2)).prefix().prefixProvider().get())
|
||||
.isEqualTo("secret-three");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,13 +275,15 @@ class SecretsConfigPropertiesTests {
|
||||
RetryProperties.DEFAULT);
|
||||
|
||||
List<NormalizedSource> sources = properties.determineSources(new MockEnvironment());
|
||||
Assertions.assertEquals(sources.size(), 4, "4 NormalizedSources are expected");
|
||||
Assertions.assertThat(sources.size()).isEqualTo(4);
|
||||
|
||||
Assertions.assertEquals(((NamedSecretNormalizedSource) sources.get(0)).prefix().prefixProvider().get(), "one");
|
||||
Assertions.assertEquals(((NamedSecretNormalizedSource) sources.get(1)).prefix().prefixProvider().get(), "two");
|
||||
Assertions.assertEquals(((NamedSecretNormalizedSource) sources.get(2)).prefix().prefixProvider().get(),
|
||||
"three");
|
||||
Assertions.assertSame(((NamedSecretNormalizedSource) sources.get(3)).prefix(), ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(0)).prefix().prefixProvider().get())
|
||||
.isEqualTo("one");
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(1)).prefix().prefixProvider().get())
|
||||
.isEqualTo("two");
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(2)).prefix().prefixProvider().get())
|
||||
.isEqualTo("three");
|
||||
Assertions.assertThat(((NamedSecretNormalizedSource) sources.get(3)).prefix()).isSameAs(ConfigUtils.Prefix.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,26 +341,26 @@ class SecretsConfigPropertiesTests {
|
||||
// duplicated.
|
||||
// that's OK, since later in the code we get a LinkedHashSet out of them all,
|
||||
// so they become 5 only.
|
||||
Assertions.assertEquals(sources.size(), 8, "4 NormalizedSources are expected");
|
||||
Assertions.assertThat(sources.size()).isEqualTo(8);
|
||||
|
||||
LabeledSecretNormalizedSource labeled1 = (LabeledSecretNormalizedSource) sources.get(1);
|
||||
Assertions.assertEquals(labeled1.prefix().prefixProvider().get(), "one");
|
||||
Assertions.assertFalse(labeled1.profileSpecificSources());
|
||||
Assertions.assertThat(labeled1.prefix().prefixProvider().get()).isEqualTo("one");
|
||||
Assertions.assertThat(labeled1.profileSpecificSources()).isFalse();
|
||||
|
||||
LabeledSecretNormalizedSource labeled3 = (LabeledSecretNormalizedSource) sources.get(3);
|
||||
Assertions.assertEquals(labeled3.prefix().prefixProvider().get(), "two");
|
||||
Assertions.assertTrue(labeled3.profileSpecificSources());
|
||||
Assertions.assertThat(labeled3.prefix().prefixProvider().get()).isEqualTo("two");
|
||||
Assertions.assertThat(labeled3.profileSpecificSources()).isTrue();
|
||||
|
||||
LabeledSecretNormalizedSource labeled5 = (LabeledSecretNormalizedSource) sources.get(5);
|
||||
Assertions.assertEquals(labeled5.prefix().prefixProvider().get(), "three");
|
||||
Assertions.assertFalse(labeled5.profileSpecificSources());
|
||||
Assertions.assertThat(labeled5.prefix().prefixProvider().get()).isEqualTo("three");
|
||||
Assertions.assertThat(labeled5.profileSpecificSources()).isFalse();
|
||||
|
||||
LabeledSecretNormalizedSource labeled7 = (LabeledSecretNormalizedSource) sources.get(7);
|
||||
Assertions.assertSame(labeled7.prefix(), ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertFalse(labeled7.profileSpecificSources());
|
||||
Assertions.assertThat(labeled7.prefix()).isSameAs(ConfigUtils.Prefix.DEFAULT);
|
||||
Assertions.assertThat(labeled7.profileSpecificSources()).isFalse();
|
||||
|
||||
Set<NormalizedSource> set = new LinkedHashSet<>(sources);
|
||||
Assertions.assertEquals(5, set.size());
|
||||
Assertions.assertThat(set.size()).isEqualTo(5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
@@ -39,9 +39,9 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "simple-property");
|
||||
Assertions.assertEquals(result.get(0).getValue(), "value");
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo("simple-property");
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("value");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,12 +54,12 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "one");
|
||||
Assertions.assertEquals(result.get(0).getValue(), "1");
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo("one");
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("1");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "two");
|
||||
Assertions.assertEquals(result.get(1).getValue(), "2");
|
||||
Assertions.assertThat(result.get(1).getKey()).isEqualTo("two");
|
||||
Assertions.assertThat(result.get(1).getValue()).isEqualTo("2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,9 +71,9 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo(Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("key=value");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,12 +86,12 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo(Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "simple");
|
||||
Assertions.assertEquals(result.get(1).getValue(), "other_value");
|
||||
Assertions.assertThat(result.get(1).getKey()).isEqualTo("simple");
|
||||
Assertions.assertThat(result.get(1).getValue()).isEqualTo("other_value");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,12 +104,12 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo(Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "simple");
|
||||
Assertions.assertEquals(result.get(1).getValue(), "other_value");
|
||||
Assertions.assertThat(result.get(1).getKey()).isEqualTo("simple");
|
||||
Assertions.assertThat(result.get(1).getValue()).isEqualTo("other_value");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,15 +124,15 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
mockEnvironment.setActiveProfiles("dev");
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 3);
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
Assertions.assertThat(result.size()).isEqualTo(3);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo(Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "application-dev.properties");
|
||||
Assertions.assertEquals(result.get(1).getValue(), "key-dev=value-dev");
|
||||
Assertions.assertThat(result.get(1).getKey()).isEqualTo("application-dev.properties");
|
||||
Assertions.assertThat(result.get(1).getValue()).isEqualTo("key-dev=value-dev");
|
||||
|
||||
Assertions.assertEquals(result.get(2).getKey(), "simple");
|
||||
Assertions.assertEquals(result.get(2).getValue(), "other_value");
|
||||
Assertions.assertThat(result.get(2).getKey()).isEqualTo("simple");
|
||||
Assertions.assertThat(result.get(2).getValue()).isEqualTo("other_value");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,10 +147,10 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
mockEnvironment.setActiveProfiles("dev");
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment, false);
|
||||
Assertions.assertEquals(1, result.size());
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
|
||||
Assertions.assertEquals(result.get(0).getKey(), "application-dev.properties");
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key-dev=value-dev");
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo("application-dev.properties");
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("key-dev=value-dev");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,18 +168,18 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
mockEnvironment.setActiveProfiles("k8s");
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 4);
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
Assertions.assertThat(result.size()).isEqualTo(4);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo(Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "application-k8s.properties");
|
||||
Assertions.assertEquals(result.get(1).getValue(), "key-k8s=value-k8s");
|
||||
Assertions.assertThat(result.get(1).getKey()).isEqualTo("application-k8s.properties");
|
||||
Assertions.assertThat(result.get(1).getValue()).isEqualTo("key-k8s=value-k8s");
|
||||
|
||||
Assertions.assertEquals(result.get(2).getKey(), "simple");
|
||||
Assertions.assertEquals(result.get(2).getValue(), "other_value");
|
||||
Assertions.assertThat(result.get(2).getKey()).isEqualTo("simple");
|
||||
Assertions.assertThat(result.get(2).getValue()).isEqualTo("other_value");
|
||||
|
||||
Assertions.assertEquals(result.get(3).getKey(), "second-simple");
|
||||
Assertions.assertEquals(result.get(3).getValue(), "second_other_value");
|
||||
Assertions.assertThat(result.get(3).getKey()).isEqualTo("second-simple");
|
||||
Assertions.assertThat(result.get(3).getValue()).isEqualTo("second_other_value");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -198,13 +198,13 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
mockEnvironment.setActiveProfiles("k8s");
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
|
||||
Assertions.assertEquals(result.get(0).getKey(), "simple");
|
||||
Assertions.assertEquals(result.get(0).getValue(), "other_value");
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo("simple");
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("other_value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "second-simple");
|
||||
Assertions.assertEquals(result.get(1).getValue(), "second_other_value");
|
||||
Assertions.assertThat(result.get(1).getKey()).isEqualTo("second-simple");
|
||||
Assertions.assertThat(result.get(1).getValue()).isEqualTo("second_other_value");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,18 +223,18 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
mockEnvironment.setActiveProfiles("k8s");
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 4);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "sorted.properties");
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
Assertions.assertThat(result.size()).isEqualTo(4);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo("sorted.properties");
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "sorted-k8s.properties");
|
||||
Assertions.assertEquals(result.get(1).getValue(), "key-k8s=value-k8s");
|
||||
Assertions.assertThat(result.get(1).getKey()).isEqualTo("sorted-k8s.properties");
|
||||
Assertions.assertThat(result.get(1).getValue()).isEqualTo("key-k8s=value-k8s");
|
||||
|
||||
Assertions.assertEquals(result.get(2).getKey(), "simple");
|
||||
Assertions.assertEquals(result.get(2).getValue(), "other_value");
|
||||
Assertions.assertThat(result.get(2).getKey()).isEqualTo("simple");
|
||||
Assertions.assertThat(result.get(2).getValue()).isEqualTo("other_value");
|
||||
|
||||
Assertions.assertEquals(result.get(3).getKey(), "second-simple");
|
||||
Assertions.assertEquals(result.get(3).getValue(), "second_other_value");
|
||||
Assertions.assertThat(result.get(3).getKey()).isEqualTo("second-simple");
|
||||
Assertions.assertThat(result.get(3).getValue()).isEqualTo("second_other_value");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -250,15 +250,15 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
mockEnvironment.setActiveProfiles("k8s");
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 3);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "sorted-k8s.properties");
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key-k8s=value-k8s");
|
||||
Assertions.assertThat(result.size()).isEqualTo(3);
|
||||
Assertions.assertThat(result.get(0).getKey()).isEqualTo("sorted-k8s.properties");
|
||||
Assertions.assertThat(result.get(0).getValue()).isEqualTo("key-k8s=value-k8s");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "simple");
|
||||
Assertions.assertEquals(result.get(1).getValue(), "other_value");
|
||||
Assertions.assertThat(result.get(1).getKey()).isEqualTo("simple");
|
||||
Assertions.assertThat(result.get(1).getValue()).isEqualTo("other_value");
|
||||
|
||||
Assertions.assertEquals(result.get(2).getKey(), "second-simple");
|
||||
Assertions.assertEquals(result.get(2).getValue(), "second_other_value");
|
||||
Assertions.assertThat(result.get(2).getKey()).isEqualTo("second-simple");
|
||||
Assertions.assertThat(result.get(2).getValue()).isEqualTo("second_other_value");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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;
|
||||
|
||||
@@ -71,8 +71,8 @@ class DiscoveryClientUtilsTests {
|
||||
serviceAnnotations);
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertEquals(result, Map.of("k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
Assertions.assertThat(result).isEqualTo(Map.of("k8s_namespace", "default", "type", "ClusterIP"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,8 +103,8 @@ class DiscoveryClientUtilsTests {
|
||||
serviceAnnotations);
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertEquals(result, Map.of("k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
Assertions.assertThat(result).isEqualTo(Map.of("k8s_namespace", "default", "type", "ClusterIP"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,11 +136,11 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
|
||||
Assertions.assertEquals(result.size(), 3);
|
||||
Assertions.assertEquals(result, Map.of("a", "b", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(3);
|
||||
Assertions.assertThat(result).isEqualTo(Map.of("a", "b", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
String labelsMetadata = filterOnK8sNamespaceAndType(result);
|
||||
Assertions.assertTrue(
|
||||
output.getOut().contains("Adding labels metadata: " + labelsMetadata + " for serviceId: my-service"));
|
||||
Assertions.assertThat(
|
||||
output.getOut()).contains("Adding labels metadata: " + labelsMetadata + " for serviceId: my-service");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,13 +172,13 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
|
||||
Assertions.assertEquals(result.size(), 4);
|
||||
Assertions.assertEquals(result,
|
||||
Assertions.assertThat(result.size()).isEqualTo(4);
|
||||
Assertions.assertThat(result).isEqualTo(
|
||||
Map.of("prefix-a", "b", "prefix-c", "d", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
// so that result is deterministic in assertion
|
||||
String labelsMetadata = filterOnK8sNamespaceAndType(result);
|
||||
Assertions.assertTrue(
|
||||
output.getOut().contains("Adding labels metadata: " + labelsMetadata + " for serviceId: my-service"));
|
||||
Assertions.assertThat(
|
||||
output.getOut()).contains("Adding labels metadata: " + labelsMetadata + " for serviceId: my-service");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,10 +210,10 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
|
||||
Assertions.assertEquals(result.size(), 3);
|
||||
Assertions.assertEquals(result, Map.of("aa", "bb", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(3);
|
||||
Assertions.assertThat(result).isEqualTo(Map.of("aa", "bb", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions
|
||||
.assertTrue(output.getOut().contains("Adding annotations metadata: {aa=bb} for serviceId: my-service"));
|
||||
.assertThat(output.getOut()).contains("Adding annotations metadata: {aa=bb} for serviceId: my-service");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,13 +245,13 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
|
||||
Assertions.assertEquals(result.size(), 4);
|
||||
Assertions.assertEquals(result,
|
||||
Assertions.assertThat(result.size()).isEqualTo(4);
|
||||
Assertions.assertThat(result).isEqualTo(
|
||||
Map.of("prefix-aa", "bb", "prefix-cc", "dd", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
// so that result is deterministic in assertion
|
||||
String annotations = filterOnK8sNamespaceAndType(result);
|
||||
Assertions.assertTrue(
|
||||
output.getOut().contains("Adding annotations metadata: " + annotations + " for serviceId: my-service"));
|
||||
Assertions.assertThat(
|
||||
output.getOut()).contains("Adding annotations metadata: " + annotations + " for serviceId: my-service");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,8 +283,7 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
|
||||
Assertions.assertEquals(result.size(), 6);
|
||||
Assertions.assertEquals(result, Map.of("annotation-aa", "bb", "annotation-cc", "dd", "label-a", "b", "label-c",
|
||||
Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("annotation-aa", "bb", "annotation-cc", "dd", "label-a", "b", "label-c",
|
||||
"d", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
// so that result is deterministic in assertion
|
||||
String labels = result.entrySet()
|
||||
@@ -298,9 +297,9 @@ class DiscoveryClientUtilsTests {
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))
|
||||
.toString();
|
||||
Assertions
|
||||
.assertTrue(output.getOut().contains("Adding labels metadata: " + labels + " for serviceId: my-service"));
|
||||
Assertions.assertTrue(
|
||||
output.getOut().contains("Adding annotations metadata: " + annotations + " for serviceId: my-service"));
|
||||
.assertThat(output.getOut()).contains("Adding labels metadata: " + labels + " for serviceId: my-service");
|
||||
Assertions.assertThat(
|
||||
output.getOut()).contains("Adding annotations metadata: " + annotations + " for serviceId: my-service");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -331,10 +330,9 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
|
||||
Assertions.assertEquals(result.size(), 3);
|
||||
Assertions.assertEquals(result, Map.of("https", "8080", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("https", "8080", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions
|
||||
.assertTrue(output.getOut().contains("Adding port metadata: {https=8080} for serviceId : my-service"));
|
||||
.assertThat(output.getOut()).contains("Adding port metadata: {https=8080} for serviceId : my-service");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,11 +363,10 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, String> result = serviceInstanceMetadata(portsData, serviceMetadata, properties);
|
||||
|
||||
Assertions.assertEquals(result.size(), 4);
|
||||
Assertions.assertEquals(result,
|
||||
Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(
|
||||
Map.of("prefix-https", "8080", "prefix-http", "8081", "k8s_namespace", "default", "type", "ClusterIP"));
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.contains("Adding port metadata: {prefix-http=8081, prefix-https=8080} for serviceId : my-service"));
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains("Adding port metadata: {prefix-http=8081, prefix-https=8080} for serviceId : my-service");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,10 +384,10 @@ class DiscoveryClientUtilsTests {
|
||||
Map<String, String> serviceLabels = Map.of();
|
||||
|
||||
String result = primaryPortName(properties, serviceLabels, "abc");
|
||||
Assertions.assertNull(result);
|
||||
Assertions.assertTrue(output.getOut()
|
||||
Assertions.assertThat(result).isNull();
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains(
|
||||
"did not find a primary-port-name in neither properties nor service labels for service with ID : abc"));
|
||||
"did not find a primary-port-name in neither properties nor service labels for service with ID : abc");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,9 +407,9 @@ class DiscoveryClientUtilsTests {
|
||||
Map<String, String> serviceLabels = Map.of();
|
||||
|
||||
String result = primaryPortName(properties, serviceLabels, "abc");
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result, primaryPortName);
|
||||
Assertions.assertTrue(output.getOut().contains("will use primaryPortName : https for service with ID = abc"));
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result).isEqualTo(primaryPortName);
|
||||
Assertions.assertThat(output.getOut()).contains("will use primaryPortName : https for service with ID = abc");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,9 +426,9 @@ class DiscoveryClientUtilsTests {
|
||||
KubernetesDiscoveryProperties properties = KubernetesDiscoveryProperties.DEFAULT;
|
||||
|
||||
String result = primaryPortName(properties, serviceLabels, "abc");
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result, "https");
|
||||
Assertions.assertTrue(output.getOut().contains("will use primaryPortName : https for service with ID = abc"));
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result).isEqualTo("https");
|
||||
Assertions.assertThat(output.getOut()).contains("will use primaryPortName : https for service with ID = abc");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -450,9 +447,9 @@ class DiscoveryClientUtilsTests {
|
||||
true, "", Set.of(), Map.of(), primaryPortName, null, 0, false);
|
||||
|
||||
String result = primaryPortName(properties, serviceLabels, "abc");
|
||||
Assertions.assertNotNull(result);
|
||||
Assertions.assertEquals(result, "http");
|
||||
Assertions.assertTrue(output.getOut().contains("will use primaryPortName : http for service with ID = abc"));
|
||||
Assertions.assertThat(result).isNotNull();
|
||||
Assertions.assertThat(result).isEqualTo("http");
|
||||
Assertions.assertThat(output.getOut()).contains("will use primaryPortName : http for service with ID = abc");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -471,9 +468,9 @@ class DiscoveryClientUtilsTests {
|
||||
Map.of());
|
||||
|
||||
ServicePortNameAndNumber portData = endpointsPort(endpointsPorts, serviceMetadata, properties);
|
||||
Assertions.assertEquals(portData.portNumber(), 0);
|
||||
Assertions.assertEquals(portData.portName(), "http");
|
||||
Assertions.assertTrue(output.getOut().contains("no ports found for service : spring-k8s, will return zero"));
|
||||
Assertions.assertThat(portData.portNumber()).isEqualTo(0);
|
||||
Assertions.assertThat(portData.portName()).isEqualTo("http");
|
||||
Assertions.assertThat(output.getOut()).contains("no ports found for service : spring-k8s, will return zero");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,9 +490,9 @@ class DiscoveryClientUtilsTests {
|
||||
Map.of());
|
||||
|
||||
ServicePortNameAndNumber portData = endpointsPort(endpointsPorts, serviceMetadata, properties);
|
||||
Assertions.assertEquals(portData.portNumber(), 8080);
|
||||
Assertions.assertEquals(portData.portName(), "http");
|
||||
Assertions.assertTrue(output.getOut().contains("endpoint ports has a single entry, using port : 8080"));
|
||||
Assertions.assertThat(portData.portNumber()).isEqualTo(8080);
|
||||
Assertions.assertThat(portData.portName()).isEqualTo("http");
|
||||
Assertions.assertThat(output.getOut()).contains("endpoint ports has a single entry, using port : 8080");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -517,22 +514,22 @@ class DiscoveryClientUtilsTests {
|
||||
Map.of());
|
||||
|
||||
ServicePortNameAndNumber portData = endpointsPort(endpointsPorts, serviceMetadata, properties);
|
||||
Assertions.assertEquals(portData.portNumber(), 8080);
|
||||
Assertions.assertEquals(portData.portName(), "not-null");
|
||||
Assertions.assertTrue(output.getOut()
|
||||
Assertions.assertThat(portData.portNumber()).isEqualTo(8080);
|
||||
Assertions.assertThat(portData.portName()).isEqualTo("not-null");
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains(
|
||||
"did not find a primary-port-name in neither properties nor service labels for service with ID : spring-k8s"));
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.contains("not found primary-port-name (with value: 'null') via properties or service labels"));
|
||||
Assertions.assertTrue(output.getOut().contains("not found primary-port-name via 'https' to match port"));
|
||||
Assertions.assertTrue(output.getOut().contains("not found primary-port-name via 'http' to match port"));
|
||||
Assertions.assertTrue(
|
||||
output.getOut().contains("Could not find a port named 'https' or 'http' for service 'spring-k8s'."));
|
||||
Assertions.assertTrue(output.getOut().contains("""
|
||||
"did not find a primary-port-name in neither properties nor service labels for service with ID : spring-k8s");
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains("not found primary-port-name (with value: 'null') via properties or service labels");
|
||||
Assertions.assertThat(output.getOut()).contains("not found primary-port-name via 'https' to match port");
|
||||
Assertions.assertThat(output.getOut()).contains("not found primary-port-name via 'http' to match port");
|
||||
Assertions.assertThat(
|
||||
output.getOut()).contains("Could not find a port named 'https' or 'http' for service 'spring-k8s'.");
|
||||
Assertions.assertThat(output.getOut()).contains("""
|
||||
Make sure that either the primary-port-name label has been added to the service,
|
||||
or spring.cloud.kubernetes.discovery.primary-port-name has been configured.
|
||||
Alternatively name the primary port 'https' or 'http'.
|
||||
An incorrect configuration may result in non-deterministic behaviour."""));
|
||||
An incorrect configuration may result in non-deterministic behaviour.""");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -556,21 +553,21 @@ class DiscoveryClientUtilsTests {
|
||||
Map.of());
|
||||
|
||||
ServicePortNameAndNumber portData = endpointsPort(endpointsPorts, serviceMetadata, properties);
|
||||
Assertions.assertEquals(portData.portNumber(), 8080);
|
||||
Assertions.assertEquals(portData.portName(), "one");
|
||||
Assertions.assertThat(portData.portNumber()).isEqualTo(8080);
|
||||
Assertions.assertThat(portData.portName()).isEqualTo("one");
|
||||
Assertions
|
||||
.assertTrue(output.getOut().contains("will use primaryPortName : three for service with ID = spring-k8s"));
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.contains("not found primary-port-name (with value: 'three') via properties or service labels"));
|
||||
Assertions.assertTrue(output.getOut().contains("not found primary-port-name via 'https' to match port"));
|
||||
Assertions.assertTrue(output.getOut().contains("not found primary-port-name via 'http' to match port"));
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.contains("Could not find a port named 'three', 'https', or 'http' for service 'spring-k8s'."));
|
||||
Assertions.assertTrue(output.getOut().contains("""
|
||||
.assertThat(output.getOut()).contains("will use primaryPortName : three for service with ID = spring-k8s");
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains("not found primary-port-name (with value: 'three') via properties or service labels");
|
||||
Assertions.assertThat(output.getOut()).contains("not found primary-port-name via 'https' to match port");
|
||||
Assertions.assertThat(output.getOut()).contains("not found primary-port-name via 'http' to match port");
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains("Could not find a port named 'three', 'https', or 'http' for service 'spring-k8s'.");
|
||||
Assertions.assertThat(output.getOut()).contains("""
|
||||
Make sure that either the primary-port-name label has been added to the service,
|
||||
or spring.cloud.kubernetes.discovery.primary-port-name has been configured.
|
||||
Alternatively name the primary port 'https' or 'http'.
|
||||
An incorrect configuration may result in non-deterministic behaviour."""));
|
||||
An incorrect configuration may result in non-deterministic behaviour.""");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -594,13 +591,13 @@ class DiscoveryClientUtilsTests {
|
||||
Map.of());
|
||||
|
||||
ServicePortNameAndNumber portData = endpointsPort(endpointsPorts, serviceMetadata, properties);
|
||||
Assertions.assertEquals(portData.portNumber(), 8081);
|
||||
Assertions.assertEquals(portData.portName(), "two");
|
||||
Assertions.assertThat(portData.portNumber()).isEqualTo(8081);
|
||||
Assertions.assertThat(portData.portName()).isEqualTo("two");
|
||||
Assertions
|
||||
.assertTrue(output.getOut().contains("will use primaryPortName : two for service with ID = spring-k8s"));
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.assertThat(output.getOut()).contains("will use primaryPortName : two for service with ID = spring-k8s");
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains(
|
||||
"found primary-port-name (with value: 'two') via properties or service labels to match port : 8081"));
|
||||
"found primary-port-name (with value: 'two') via properties or service labels to match port : 8081");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -626,14 +623,14 @@ class DiscoveryClientUtilsTests {
|
||||
Map.of());
|
||||
|
||||
ServicePortNameAndNumber portData = endpointsPort(endpointsPorts, serviceMetadata, properties);
|
||||
Assertions.assertEquals(portData.portNumber(), 8082);
|
||||
Assertions.assertEquals(portData.portName(), "https");
|
||||
Assertions.assertThat(portData.portNumber()).isEqualTo(8082);
|
||||
Assertions.assertThat(portData.portName()).isEqualTo("https");
|
||||
Assertions
|
||||
.assertTrue(output.getOut().contains("will use primaryPortName : three for service with ID = spring-k8s"));
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.assertThat(output.getOut()).contains("will use primaryPortName : three for service with ID = spring-k8s");
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains(
|
||||
"not found primary-port-name (with value: 'three') via properties or service labels to match port"));
|
||||
Assertions.assertTrue(output.getOut().contains("found primary-port-name via 'https' to match port : 8082"));
|
||||
"not found primary-port-name (with value: 'three') via properties or service labels to match port");
|
||||
Assertions.assertThat(output.getOut()).contains("found primary-port-name via 'https' to match port : 8082");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -659,14 +656,14 @@ class DiscoveryClientUtilsTests {
|
||||
Map.of());
|
||||
|
||||
ServicePortNameAndNumber portData = endpointsPort(endpointsPorts, serviceMetadata, properties);
|
||||
Assertions.assertEquals(portData.portNumber(), 8082);
|
||||
Assertions.assertEquals(portData.portName(), "http");
|
||||
Assertions.assertThat(portData.portNumber()).isEqualTo(8082);
|
||||
Assertions.assertThat(portData.portName()).isEqualTo("http");
|
||||
Assertions
|
||||
.assertTrue(output.getOut().contains("will use primaryPortName : three for service with ID = spring-k8s"));
|
||||
Assertions.assertTrue(output.getOut()
|
||||
.assertThat(output.getOut()).contains("will use primaryPortName : three for service with ID = spring-k8s");
|
||||
Assertions.assertThat(output.getOut())
|
||||
.contains(
|
||||
"not found primary-port-name (with value: 'three') via properties or service labels to match port"));
|
||||
Assertions.assertTrue(output.getOut().contains("found primary-port-name via 'http' to match port : 8082"));
|
||||
"not found primary-port-name (with value: 'three') via properties or service labels to match port");
|
||||
Assertions.assertThat(output.getOut()).contains("found primary-port-name via 'http' to match port : 8082");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -682,18 +679,18 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
ServiceInstance serviceInstance = serviceInstance(resolver, forServiceInstance, () -> instanceIdHostPodName,
|
||||
null, portData, serviceMetadata, properties);
|
||||
Assertions.assertTrue(serviceInstance instanceof DefaultKubernetesServiceInstance);
|
||||
Assertions.assertThat(serviceInstance).isInstanceOf(DefaultKubernetesServiceInstance.class);
|
||||
DefaultKubernetesServiceInstance defaultInstance = (DefaultKubernetesServiceInstance) serviceInstance;
|
||||
Assertions.assertEquals(defaultInstance.getInstanceId(), "123");
|
||||
Assertions.assertEquals(defaultInstance.getServiceId(), "my-service");
|
||||
Assertions.assertEquals(defaultInstance.getHost(), "127.0.0.1");
|
||||
Assertions.assertEquals(defaultInstance.getPort(), 8080);
|
||||
Assertions.assertFalse(defaultInstance.isSecure());
|
||||
Assertions.assertEquals(defaultInstance.getUri().toASCIIString(), "http://127.0.0.1:8080");
|
||||
Assertions.assertEquals(defaultInstance.getMetadata(), Map.of("a", "b"));
|
||||
Assertions.assertEquals(defaultInstance.getScheme(), "http");
|
||||
Assertions.assertEquals(defaultInstance.getNamespace(), "k8s");
|
||||
Assertions.assertNull(defaultInstance.getCluster());
|
||||
Assertions.assertThat(defaultInstance.getInstanceId()).isEqualTo("123");
|
||||
Assertions.assertThat(defaultInstance.getServiceId()).isEqualTo("my-service");
|
||||
Assertions.assertThat(defaultInstance.getHost()).isEqualTo("127.0.0.1");
|
||||
Assertions.assertThat(defaultInstance.getPort()).isEqualTo(8080);
|
||||
Assertions.assertThat(defaultInstance.isSecure()).isFalse();
|
||||
Assertions.assertThat(defaultInstance.getUri().toASCIIString()).isEqualTo("http://127.0.0.1:8080");
|
||||
Assertions.assertThat(defaultInstance.getMetadata()).containsExactlyEntriesOf(Map.of("a", "b"));
|
||||
Assertions.assertThat(defaultInstance.getScheme()).isEqualTo("http");
|
||||
Assertions.assertThat(defaultInstance.getNamespace()).isEqualTo("k8s");
|
||||
Assertions.assertThat(defaultInstance.getCluster()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -710,18 +707,18 @@ class DiscoveryClientUtilsTests {
|
||||
ServiceInstance serviceInstance = serviceInstance(null, forServiceInstance, () -> instanceIdHostPodName, null,
|
||||
portData, serviceMetadata, properties);
|
||||
|
||||
Assertions.assertTrue(serviceInstance instanceof DefaultKubernetesServiceInstance);
|
||||
Assertions.assertThat(serviceInstance).isInstanceOf(DefaultKubernetesServiceInstance.class);
|
||||
DefaultKubernetesServiceInstance defaultInstance = (DefaultKubernetesServiceInstance) serviceInstance;
|
||||
Assertions.assertEquals(defaultInstance.getInstanceId(), "123");
|
||||
Assertions.assertEquals(defaultInstance.getServiceId(), "my-service");
|
||||
Assertions.assertEquals(defaultInstance.getHost(), "spring.io");
|
||||
Assertions.assertEquals(defaultInstance.getPort(), -1);
|
||||
Assertions.assertFalse(defaultInstance.isSecure());
|
||||
Assertions.assertEquals(defaultInstance.getUri().toASCIIString(), "spring.io");
|
||||
Assertions.assertEquals(defaultInstance.getMetadata(), Map.of("a", "b"));
|
||||
Assertions.assertEquals(defaultInstance.getScheme(), "http");
|
||||
Assertions.assertEquals(defaultInstance.getNamespace(), "k8s");
|
||||
Assertions.assertNull(defaultInstance.getCluster());
|
||||
Assertions.assertThat(defaultInstance.getInstanceId()).isEqualTo("123");
|
||||
Assertions.assertThat(defaultInstance.getServiceId()).isEqualTo("my-service");
|
||||
Assertions.assertThat(defaultInstance.getHost()).isEqualTo("spring.io");
|
||||
Assertions.assertThat(defaultInstance.getPort()).isEqualTo(-1);
|
||||
Assertions.assertThat(defaultInstance.isSecure()).isFalse();
|
||||
Assertions.assertThat(defaultInstance.getUri().toASCIIString()).isEqualTo("spring.io");
|
||||
Assertions.assertThat(defaultInstance.getMetadata()).isEqualTo(Map.of("a", "b"));
|
||||
Assertions.assertThat(defaultInstance.getScheme()).isEqualTo("http");
|
||||
Assertions.assertThat(defaultInstance.getNamespace()).isEqualTo("k8s");
|
||||
Assertions.assertThat(defaultInstance.getCluster()).isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -741,7 +738,7 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, Map<String, String>> result = podMetadata(podName, serviceMetadata, properties,
|
||||
podLabelsAndMetadata);
|
||||
Assertions.assertTrue(result.isEmpty());
|
||||
Assertions.assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -762,7 +759,7 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, Map<String, String>> result = podMetadata(podName, serviceMetadata, properties,
|
||||
podLabelsAndMetadata);
|
||||
Assertions.assertTrue(result.isEmpty());
|
||||
Assertions.assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -788,7 +785,7 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, Map<String, String>> result = podMetadata(podName, serviceMetadata, properties,
|
||||
podLabelsAndMetadata);
|
||||
Assertions.assertTrue(result.isEmpty());
|
||||
Assertions.assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -817,9 +814,9 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, Map<String, String>> result = podMetadata(podName, serviceMetadata, properties,
|
||||
podLabelsAndMetadata);
|
||||
Assertions.assertTrue(result.isEmpty());
|
||||
Assertions.assertThat(result).isEmpty();
|
||||
|
||||
Assertions.assertTrue(output.getOut().contains("adding podMetadata : {} from pod : my-pod"));
|
||||
Assertions.assertThat(output.getOut()).contains("adding podMetadata : {} from pod : my-pod");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -848,10 +845,10 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, Map<String, String>> result = podMetadata(podName, serviceMetadata, properties,
|
||||
podLabelsAndMetadata);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertEquals(result.get("labels"), Map.of("a", "b"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result.get("labels")).isEqualTo(Map.of("a", "b"));
|
||||
|
||||
Assertions.assertTrue(output.getOut().contains("adding podMetadata : {labels={a=b}} from pod : my-pod"));
|
||||
Assertions.assertThat(output.getOut()).contains("adding podMetadata : {labels={a=b}} from pod : my-pod");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -880,9 +877,9 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, Map<String, String>> result = podMetadata(podName, serviceMetadata, properties,
|
||||
podLabelsAndMetadata);
|
||||
Assertions.assertTrue(result.isEmpty());
|
||||
Assertions.assertThat(result).isEmpty();
|
||||
|
||||
Assertions.assertTrue(output.getOut().contains("adding podMetadata : {} from pod : my-pod"));
|
||||
Assertions.assertThat(output.getOut()).contains("adding podMetadata : {} from pod : my-pod");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -911,10 +908,10 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, Map<String, String>> result = podMetadata(podName, serviceMetadata, properties,
|
||||
podLabelsAndMetadata);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertEquals(result.get("annotations"), Map.of("c", "d"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(1);
|
||||
Assertions.assertThat(result.get("annotations")).isEqualTo(Map.of("c", "d"));
|
||||
|
||||
Assertions.assertTrue(output.getOut().contains("adding podMetadata : {annotations={c=d}} from pod : my-pod"));
|
||||
Assertions.assertThat(output.getOut()).contains("adding podMetadata : {annotations={c=d}} from pod : my-pod");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -943,12 +940,12 @@ class DiscoveryClientUtilsTests {
|
||||
|
||||
Map<String, Map<String, String>> result = podMetadata(podName, serviceMetadata, properties,
|
||||
podLabelsAndMetadata);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertEquals(result.get("annotations"), Map.of("c", "d"));
|
||||
Assertions.assertEquals(result.get("labels"), Map.of("a", "b"));
|
||||
Assertions.assertThat(result.size()).isEqualTo(2);
|
||||
Assertions.assertThat(result.get("annotations")).isEqualTo(Map.of("c", "d"));
|
||||
Assertions.assertThat(result.get("labels")).isEqualTo(Map.of("a", "b"));
|
||||
|
||||
Assertions.assertTrue(
|
||||
output.getOut().contains("adding podMetadata : {annotations={c=d}, labels={a=b}} from pod : my-pod"));
|
||||
Assertions.assertThat(
|
||||
output.getOut()).contains("adding podMetadata : {annotations={c=d}, labels={a=b}} from pod : my-pod");
|
||||
}
|
||||
|
||||
private String filterOnK8sNamespaceAndType(Map<String, String> result) {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.kubernetes.commons.leader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -45,7 +45,7 @@ class LeaderInfoContributorTests {
|
||||
Info.Builder builder = new Info.Builder();
|
||||
leaderInfoContributor.contribute(builder);
|
||||
|
||||
Assertions.assertEquals(builder.build().getDetails().get("leaderElection"), Map.of("leaderId", "Unknown"));
|
||||
Assertions.assertThat(builder.build().getDetails().get("leaderElection")).isEqualTo(Map.of("leaderId", "Unknown"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,7 +65,7 @@ class LeaderInfoContributorTests {
|
||||
Info.Builder builder = new Info.Builder();
|
||||
leaderInfoContributor.contribute(builder);
|
||||
|
||||
Assertions.assertEquals(builder.build().getDetails().get("leaderElection"),
|
||||
Assertions.assertThat(builder.build().getDetails().get("leaderElection")).isEqualTo(
|
||||
Map.of("role", "leaderRole", "isLeader", true, "leaderId", "leaderId"));
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class LeaderInfoContributorTests {
|
||||
Info.Builder builder = new Info.Builder();
|
||||
leaderInfoContributor.contribute(builder);
|
||||
|
||||
Assertions.assertEquals(builder.build().getDetails().get("leaderElection"),
|
||||
Assertions.assertThat(builder.build().getDetails().get("leaderElection")).isEqualTo(
|
||||
Map.of("role", "leaderRole", "isLeader", false, "leaderId", "leaderId"));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.commons.leader;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ class LeaderPropertiesTests {
|
||||
void getNamespaceNull() {
|
||||
LeaderProperties leaderProperties = new LeaderProperties();
|
||||
String namespace = leaderProperties.getNamespace("a");
|
||||
Assertions.assertEquals("a", namespace);
|
||||
Assertions.assertThat(namespace).isEqualTo("a");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -36,7 +36,7 @@ class LeaderPropertiesTests {
|
||||
LeaderProperties leaderProperties = new LeaderProperties();
|
||||
leaderProperties.setNamespace("");
|
||||
String namespace = leaderProperties.getNamespace("a");
|
||||
Assertions.assertEquals("a", namespace);
|
||||
Assertions.assertThat(namespace).isEqualTo("a");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -44,7 +44,7 @@ class LeaderPropertiesTests {
|
||||
LeaderProperties leaderProperties = new LeaderProperties();
|
||||
leaderProperties.setNamespace("c");
|
||||
String namespace = leaderProperties.getNamespace("a");
|
||||
Assertions.assertEquals("c", namespace);
|
||||
Assertions.assertThat(namespace).isEqualTo("c");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.kubernetes.commons.leader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
@@ -38,7 +38,7 @@ class LeaderUtilsTests {
|
||||
envReaderMockedStatic.when(() -> EnvReader.getEnv("HOSTNAME")).thenReturn("from-env");
|
||||
|
||||
String hostname = LeaderUtils.hostName();
|
||||
Assertions.assertEquals("from-env", hostname);
|
||||
Assertions.assertThat(hostname).isEqualTo("from-env");
|
||||
|
||||
envReaderMockedStatic.close();
|
||||
|
||||
@@ -56,7 +56,7 @@ class LeaderUtilsTests {
|
||||
inet4AddressMockedStatic.when(InetAddress::getLocalHost).thenReturn(inetAddress);
|
||||
|
||||
String hostname = LeaderUtils.hostName();
|
||||
Assertions.assertEquals("from-api-call", hostname);
|
||||
Assertions.assertThat(hostname).isEqualTo("from-api-call");
|
||||
|
||||
envReaderMockedStatic.close();
|
||||
inet4AddressMockedStatic.close();
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
@@ -178,16 +178,14 @@ public class KubernetesProfileEnvironmentPostProcessorTest {
|
||||
* 'kubernetes' profile is not present
|
||||
*/
|
||||
private void assertKubernetesProfileNotPresent() {
|
||||
Assertions.assertFalse(kubernetesProfile().isPresent(),
|
||||
"'kubernetes' profile must not be present when not running in kubernetes");
|
||||
Assertions.assertThat(kubernetesProfile().isPresent()).isFalse();
|
||||
}
|
||||
|
||||
/*
|
||||
* 'kubernetes' profile is present
|
||||
*/
|
||||
private void assertKubernetesProfilePresent() {
|
||||
Assertions.assertTrue(kubernetesProfile().isPresent(),
|
||||
"'kubernetes' profile must be present when running in kubernetes");
|
||||
Assertions.assertThat(kubernetesProfile().isPresent()).isTrue();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -196,8 +194,7 @@ public class KubernetesProfileEnvironmentPostProcessorTest {
|
||||
private void assertKubernetesPropertySourceNotPresent() {
|
||||
Optional<PropertySource<?>> kubernetesPropertySource = kubernetesPropertySource();
|
||||
|
||||
Assertions.assertFalse(kubernetesPropertySource.isPresent(),
|
||||
"'KUBERNETES_NAMESPACE_PROPERTY_SOURCE' source must not be present when not running on kubernetes");
|
||||
Assertions.assertThat(kubernetesPropertySource.isPresent()).isFalse();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -206,13 +203,11 @@ public class KubernetesProfileEnvironmentPostProcessorTest {
|
||||
private void assertKubernetesPropertySourcePresent() {
|
||||
|
||||
Optional<PropertySource<?>> kubernetesPropertySource = kubernetesPropertySource();
|
||||
Assertions.assertTrue(kubernetesPropertySource.isPresent(),
|
||||
"'KUBERNETES_NAMESPACE_PROPERTY_SOURCE' source must be present when running on kubernetes");
|
||||
Assertions.assertThat(kubernetesPropertySource.isPresent()).isTrue();
|
||||
|
||||
String property = (String) kubernetesPropertySource.get()
|
||||
.getProperty("spring.cloud.kubernetes.client.namespace");
|
||||
Assertions.assertEquals(property, FOUNT_IT,
|
||||
"'spring.cloud.kubernetes.client.namespace' must be set to 'foundIt'");
|
||||
Assertions.assertThat(property).isEqualTo(FOUNT_IT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user