From 032014e7b841bb3346f2a9a097fe9bd5983a30e9 Mon Sep 17 00:00:00 2001 From: wind57 Date: Sat, 4 Dec 2021 07:59:07 -0800 Subject: [PATCH 1/9] test --- delme.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 delme.sh diff --git a/delme.sh b/delme.sh new file mode 100644 index 0000000000..707d90cb73 --- /dev/null +++ b/delme.sh @@ -0,0 +1 @@ +dadsa \ No newline at end of file From 10889fd1fc9c5ec3a32699d70d4a0e914aae7577 Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 16 Dec 2021 04:15:40 -0800 Subject: [PATCH 2/9] fix @Nested tests not running --- .circleci/config.yml | 2 +- pom.xml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f197c14d8..7eed9f3449 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,7 +44,7 @@ jobs: echo $CLASSNAMES TEST_ARG=$(echo $CLASSNAMES | sed 's/ /,/g') echo $TEST_ARG - ./mvnw -s .settings.xml -DfailIfNoTests=false -Dtest=$TEST_ARG -e clean org.jacoco:jacoco-maven-plugin:prepare-agent test -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + ./mvnw -s .settings.xml -DfailIfNoTests=false -DtestsToRun=$TEST_ARG -e clean org.jacoco:jacoco-maven-plugin:prepare-agent test -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn mkdir -p $HOME/artifacts/junit/ find . -type f -regex ".*/spring-cloud-*.*/target/*.*" -exec cp {} $HOME/artifacts/ \; find . -type f -regex ".*/target/.*-reports/.*" -exec cp {} $HOME/artifacts/junit/ \; diff --git a/pom.xml b/pom.xml index 191dae7c2d..e25caca33c 100644 --- a/pom.xml +++ b/pom.xml @@ -204,6 +204,11 @@ all false + + + + ${testsToRun} + @@ -356,6 +361,11 @@ all false + + + + ${testsToRun} + ${surefireArgLine} From b041c00ea5cac0bb3e7bd43bc75ee470920cc3fe Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 13 Jan 2022 15:33:08 +0200 Subject: [PATCH 3/9] trigger again From a34ac473971fca316b05a0b886de000f05220b1e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 08:43:39 +0000 Subject: [PATCH 4/9] Add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000000..7bd954555f --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ] +} From 618f25aeccb763010ba7777653994148514c8d99 Mon Sep 17 00:00:00 2001 From: erabii Date: Tue, 14 Mar 2023 10:39:50 +0200 Subject: [PATCH 5/9] Delete renovate.json --- renovate.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 renovate.json diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 7bd954555f..0000000000 --- a/renovate.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base" - ] -} From 100a9cd110d5c5e614573d8c3726b21788c1b550 Mon Sep 17 00:00:00 2001 From: erabii Date: Tue, 14 Mar 2023 10:40:02 +0200 Subject: [PATCH 6/9] Delete delme.sh --- delme.sh | 1 - 1 file changed, 1 deletion(-) delete mode 100644 delme.sh diff --git a/delme.sh b/delme.sh deleted file mode 100644 index 707d90cb73..0000000000 --- a/delme.sh +++ /dev/null @@ -1 +0,0 @@ -dadsa \ No newline at end of file From 667b4df714021d57227dfbc653e8de0695d26e3f Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 8 May 2025 16:40:51 +0300 Subject: [PATCH 7/9] started work Signed-off-by: wind57 --- .../config/MultipleSourcesContainer.java | 9 +- .../commons/config/PrefixContext.java | 32 -------- .../commons/config/SourceDataFlattener.java | 34 ++------ .../config/SourceDataFlattenerTests.java | 82 +++++++------------ 4 files changed, 41 insertions(+), 116 deletions(-) delete mode 100644 spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/PrefixContext.java diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/MultipleSourcesContainer.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/MultipleSourcesContainer.java index 892171f758..86a7cc63f7 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/MultipleSourcesContainer.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/MultipleSourcesContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2022 the original author or authors. + * Copyright 2013-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package org.springframework.cloud.kubernetes.commons.config; -import java.util.LinkedHashSet; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -25,10 +25,9 @@ * Container that stores multiple sources, to be exact their names and their flattenned * data. We force a LinkedHashSet on purpose, to preserve the order of sources. */ -public record MultipleSourcesContainer(LinkedHashSet names, Map data) { +public record MultipleSourcesContainer(LinkedHashMap> data) { - private static final MultipleSourcesContainer EMPTY = new MultipleSourcesContainer(new LinkedHashSet<>(0), - Map.of()); + private static final MultipleSourcesContainer EMPTY = new MultipleSourcesContainer(new LinkedHashMap<>(0)); public static MultipleSourcesContainer empty() { return EMPTY; diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/PrefixContext.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/PrefixContext.java deleted file mode 100644 index 720998e34a..0000000000 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/PrefixContext.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.commons.config; - -import java.util.Map; -import java.util.Set; - -/** - * A holder for data needed to compute prefix based properties, in case of a secret or - * config map. - * - * @author wind57 - * @deprecated will be deleted in a future release. - */ -@Deprecated(forRemoval = true) -public record PrefixContext(Map data, String prefix, String namespace, - Set propertySourceNames) { -} diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java index 2f22310750..0c795fe8e0 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java @@ -17,7 +17,7 @@ package org.springframework.cloud.kubernetes.commons.config; import java.util.HashMap; -import java.util.LinkedHashSet; +import java.util.LinkedHashMap; import java.util.Map; /** @@ -32,31 +32,20 @@ private SourceDataFlattener() { /** * Flattens the data from rawData without any additional processing. */ - static Map defaultFlattenedSourceData(LinkedHashSet names, Map rawData) { + static Map defaultFlattenedSourceData(LinkedHashMap> sourceData) { Map flattenedData = new HashMap<>(); - - names.forEach(name -> { - @SuppressWarnings("unchecked") - Map singleDataEntry = (Map) rawData.getOrDefault(name, Map.of()); - flattenedData.putAll(singleDataEntry); - }); - + sourceData.values().forEach(flattenedData::putAll); return flattenedData; } /** * Flattens the data from rawData by adding a prefix for each key. */ - static Map prefixFlattenedSourceData(LinkedHashSet names, Map rawData, + static Map prefixFlattenedSourceData(LinkedHashMap> sourceData, String prefix) { Map flattenedData = new HashMap<>(); - - names.forEach(name -> { - @SuppressWarnings("unchecked") - Map singleDataEntry = (Map) rawData.getOrDefault(name, Map.of()); - singleDataEntry.forEach((key, value) -> flattenedData.put(prefix + "." + key, value)); - }); - + sourceData.values().forEach(data -> + data.forEach((key, value) -> flattenedData.put(prefix + "." + key, value))); return flattenedData; } @@ -64,15 +53,10 @@ static Map prefixFlattenedSourceData(LinkedHashSet names * Flattens the data from rawData by adding a prefix for each key, which is equal to * the source name. */ - static Map nameFlattenedSourceData(LinkedHashSet names, Map rawData) { + static Map nameFlattenedSourceData(LinkedHashMap> sourceData) { Map flattenedData = new HashMap<>(); - - names.forEach(name -> { - @SuppressWarnings("unchecked") - Map singleDataEntry = (Map) rawData.getOrDefault(name, Map.of()); - singleDataEntry.forEach((key, value) -> flattenedData.put(name + "." + key, value)); - }); - + sourceData.forEach((name, data) -> + data.forEach((key, value) -> flattenedData.put(name + "." + key, value))); return flattenedData; } diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattenerTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattenerTests.java index f03d274373..f28794851f 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattenerTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattenerTests.java @@ -17,6 +17,7 @@ package org.springframework.cloud.kubernetes.commons.config; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; @@ -36,15 +37,11 @@ class SourceDataFlattenerTests { */ @Test void defaultFlattenedSourceDataNoOverlap() { - LinkedHashSet names = new LinkedHashSet<>(); - names.add("nameA"); - names.add("nameB"); + LinkedHashMap> data = new LinkedHashMap<>(); + data.put("nameA", Map.of("a", "b")); + data.put("nameB", Map.of("c", "d")); - Map rawData = new HashMap<>(); - rawData.put("nameA", Map.of("a", "b")); - rawData.put("nameB", Map.of("c", "d")); - - Map result = SourceDataFlattener.defaultFlattenedSourceData(names, rawData); + Map result = SourceDataFlattener.defaultFlattenedSourceData(data); Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("a", "b", "c", "d")); } @@ -58,17 +55,12 @@ void defaultFlattenedSourceDataNoOverlap() { */ @Test void defaultFlattenedSourceDataOverlap() { - LinkedHashSet names = new LinkedHashSet<>(); - names.add("nameA"); - names.add("nameB"); - names.add("nameC"); - - Map rawData = new HashMap<>(); - rawData.put("nameA", Map.of("a", "b")); - rawData.put("nameB", Map.of("c", "d")); - rawData.put("nameC", Map.of("a", "w")); + LinkedHashMap> data = new LinkedHashMap<>(); + data.put("nameA", Map.of("a", "b")); + data.put("nameB", Map.of("c", "d")); + data.put("nameC", Map.of("a", "w")); - Map result = SourceDataFlattener.defaultFlattenedSourceData(names, rawData); + Map result = SourceDataFlattener.defaultFlattenedSourceData(data); Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("a", "w", "c", "d")); } @@ -82,15 +74,11 @@ void defaultFlattenedSourceDataOverlap() { */ @Test void prefixFlattenedSourceDataNoOverlap() { - LinkedHashSet names = new LinkedHashSet<>(); - names.add("nameA"); - names.add("nameB"); - - Map rawData = new HashMap<>(); - rawData.put("nameA", Map.of("a", "b")); - rawData.put("nameB", Map.of("c", "d")); + LinkedHashMap> data = new LinkedHashMap<>(); + data.put("nameA", Map.of("a", "b")); + data.put("nameB", Map.of("c", "d")); - Map result = SourceDataFlattener.prefixFlattenedSourceData(names, rawData, "one"); + Map result = SourceDataFlattener.prefixFlattenedSourceData(data, "one"); Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("one.a", "b", "one.c", "d")); } @@ -105,17 +93,12 @@ void prefixFlattenedSourceDataNoOverlap() { */ @Test void prefixFlattenedSourceDataOverlap() { - LinkedHashSet names = new LinkedHashSet<>(); - names.add("nameA"); - names.add("nameB"); - names.add("nameC"); + LinkedHashMap> data = new LinkedHashMap<>(); + data.put("nameA", Map.of("a", "b")); + data.put("nameB", Map.of("c", "d")); + data.put("nameC", Map.of("a", "w")); - Map rawData = new HashMap<>(); - rawData.put("nameA", Map.of("a", "b")); - rawData.put("nameB", Map.of("c", "d")); - rawData.put("nameC", Map.of("a", "w")); - - Map result = SourceDataFlattener.prefixFlattenedSourceData(names, rawData, "one"); + Map result = SourceDataFlattener.prefixFlattenedSourceData(data, "one"); Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("one.a", "w", "one.c", "d")); } @@ -128,15 +111,11 @@ void prefixFlattenedSourceDataOverlap() { */ @Test void nameFlattenedSourceDataNoOverlap() { - LinkedHashSet names = new LinkedHashSet<>(); - names.add("nameA"); - names.add("nameB"); - - Map rawData = new HashMap<>(); - rawData.put("nameA", Map.of("a", "b")); - rawData.put("nameB", Map.of("c", "d")); + LinkedHashMap> data = new LinkedHashMap<>(); + data.put("nameA", Map.of("a", "b")); + data.put("nameB", Map.of("c", "d")); - Map result = SourceDataFlattener.nameFlattenedSourceData(names, rawData); + Map result = SourceDataFlattener.nameFlattenedSourceData(data); Assertions.assertThat(result).containsExactlyInAnyOrderEntriesOf(Map.of("nameA.a", "b", "nameB.c", "d")); } @@ -150,17 +129,12 @@ void nameFlattenedSourceDataNoOverlap() { */ @Test void nameFlattenedSourceDataOverlap() { - LinkedHashSet names = new LinkedHashSet<>(); - names.add("nameA"); - names.add("nameB"); - names.add("nameC"); - - Map rawData = new HashMap<>(); - rawData.put("nameA", Map.of("a", "b")); - rawData.put("nameB", Map.of("c", "d")); - rawData.put("nameC", Map.of("a", "w")); + LinkedHashMap> data = new LinkedHashMap<>(); + data.put("nameA", Map.of("a", "b")); + data.put("nameB", Map.of("c", "d")); + data.put("nameC", Map.of("a", "w")); - Map result = SourceDataFlattener.nameFlattenedSourceData(names, rawData); + Map result = SourceDataFlattener.nameFlattenedSourceData(data); Assertions.assertThat(result) .containsExactlyInAnyOrderEntriesOf(Map.of("nameA.a", "b", "nameB.c", "d", "nameC.a", "w")); From 0b468065923919cdb3ee114e64429bb1cbf9833a Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 8 May 2025 16:41:34 +0300 Subject: [PATCH 8/9] cleanup Signed-off-by: wind57 --- .../kubernetes/commons/config/SourceDataFlattenerTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattenerTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattenerTests.java index f28794851f..3fa1a78f23 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattenerTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattenerTests.java @@ -16,9 +16,7 @@ package org.springframework.cloud.kubernetes.commons.config; -import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.Map; import org.assertj.core.api.Assertions; From d240fe12bb55d5ee7177bedf4b091834a9f0b26c Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 8 May 2025 17:11:04 +0300 Subject: [PATCH 9/9] cleanup Signed-off-by: wind57 --- .../commons/config/ConfigUtils.java | 30 ++----- .../commons/config/LabeledSourceData.java | 19 +++-- .../commons/config/NamedSourceData.java | 28 ++++--- .../commons/config/SourceDataFlattener.java | 6 +- .../config/ConfigUtilsProcessSourceTests.java | 25 +++--- .../commons/config/ConfigUtilsTests.java | 14 ++-- .../config/Fabric8ConfigUtilsTests.java | 81 ++++++++----------- 7 files changed, 81 insertions(+), 122 deletions(-) diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java index 05fd1f166c..8bb29b5fd3 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.Base64; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -157,21 +158,6 @@ public static void onException(boolean failFast, Exception e) { LOG.warn(e.getMessage() + ". Ignoring.", e); } - /* - * This method will return a SourceData that has a name in the form : - * "configmap.my-configmap.my-configmap-2.namespace" and the "data" from the context - * is appended with prefix. So if incoming is "a=b", the result will be : "prefix.a=b" - */ - @Deprecated(forRemoval = true) - public static SourceData withPrefix(String target, PrefixContext context) { - Map withPrefix = CollectionUtils.newHashMap(context.data().size()); - context.data().forEach((key, value) -> withPrefix.put(context.prefix() + "." + key, value)); - - String propertySourceTokens = String.join(PROPERTY_SOURCE_NAME_SEPARATOR, - context.propertySourceNames().stream().sorted().collect(Collectors.toCollection(LinkedHashSet::new))); - return new SourceData(sourceName(target, propertySourceTokens, context.namespace()), withPrefix); - } - public static String sourceName(String target, String applicationName, String namespace) { return target + PROPERTY_SOURCE_NAME_SEPARATOR + applicationName + PROPERTY_SOURCE_NAME_SEPARATOR + namespace; } @@ -201,8 +187,7 @@ public static MultipleSourcesContainer processNamedData(List hashByName = strippedSources.stream() .collect(Collectors.toMap(StrippedSourceContainer::name, Function.identity())); - LinkedHashSet foundSourceNames = new LinkedHashSet<>(); - Map data = new HashMap<>(); + LinkedHashMap> data = new LinkedHashMap<>(); // This is an ordered stream, and it means that non-profile-based sources will be // processed before profile-based sources. @@ -212,7 +197,6 @@ public static MultipleSourcesContainer processNamedData(List rawData = stripped.data(); if (decode) { @@ -237,7 +221,7 @@ public static MultipleSourcesContainer processNamedData(List activeProf .anyMatch(activeProfile -> ENDS_WITH_PROFILE_AND_EXTENSION.test(keyName, activeProfile))); } - static String sourceDataName(String target, LinkedHashSet sourceNames, String namespace) { + static String sourceDataName(String target, Set sourceNames, String namespace) { String sortedNames = sourceNames.stream().sorted().collect(Collectors.joining(PROPERTY_SOURCE_NAME_SEPARATOR)); return sourceName(target, sortedNames, namespace); } @@ -318,13 +302,11 @@ public static MultipleSourcesContainer processLabeledData(List sourceNames = new LinkedHashSet<>(); - Map data = new HashMap<>(); + LinkedHashMap> data = new LinkedHashMap<>(); all.forEach(source -> { String foundSourceName = source.name(); LOG.debug("Loaded source with name : '" + foundSourceName + " in namespace: '" + namespace + "'"); - sourceNames.add(foundSourceName); Map rawData = source.data(); if (decode) { @@ -335,7 +317,7 @@ public static MultipleSourcesContainer processLabeledData(List decodeData(Map data) { diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/LabeledSourceData.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/LabeledSourceData.java index 5a18a096dc..1ce77840d6 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/LabeledSourceData.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/LabeledSourceData.java @@ -17,7 +17,7 @@ package org.springframework.cloud.kubernetes.commons.config; import java.util.Arrays; -import java.util.LinkedHashSet; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -57,26 +57,24 @@ public final SourceData compute(Map labels, Prefix prefix, Strin profiles = Arrays.stream(activeProfiles).collect(Collectors.toSet()); } data = dataSupplier(labels, profiles); + LinkedHashMap> sourceData = data.data(); + sourceDataName = sourceDataName(target, sourceData.keySet(), namespace); - LinkedHashSet sourceNames = data.names(); - Map sourceDataForSourceName = data.data(); - sourceDataName = sourceDataName(target, sourceNames, namespace); - - if (sourceNames.isEmpty()) { + if (sourceData.isEmpty()) { return emptySourceData(labels, target, namespace); } if (prefix.getName().equals(Prefix.DEFAULT.getName())) { - return new SourceData(sourceDataName, defaultFlattenedSourceData(sourceNames, sourceDataForSourceName)); + return new SourceData(sourceDataName, defaultFlattenedSourceData(sourceData)); } if (prefix.getName().equals(Prefix.KNOWN.getName())) { return new SourceData(sourceDataName, - prefixFlattenedSourceData(sourceNames, sourceDataForSourceName, prefix.prefixProvider().get())); + prefixFlattenedSourceData(sourceData, prefix.prefixProvider().get())); } if (prefix.getName().equals(Prefix.DELAYED.getName())) { - return new SourceData(sourceDataName, nameFlattenedSourceData(sourceNames, sourceDataForSourceName)); + return new SourceData(sourceDataName, nameFlattenedSourceData(sourceData)); } throw new IllegalArgumentException("Unsupported prefix: " + prefix); @@ -84,7 +82,8 @@ public final SourceData compute(Map labels, Prefix prefix, Strin catch (Exception e) { LOG.warn("Failure in reading labeled sources"); onException(failFast, e); - return new SourceData(sourceDataName(target, data.names(), namespace), Map.of(ERROR_PROPERTY, "true")); + return new SourceData(sourceDataName(target, data.data().keySet(), namespace), + Map.of(ERROR_PROPERTY, "true")); } } diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSourceData.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSourceData.java index f87d078336..94b16cd065 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSourceData.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSourceData.java @@ -16,8 +16,10 @@ package org.springframework.cloud.kubernetes.commons.config; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.logging.Log; @@ -60,31 +62,29 @@ public final SourceData compute(String sourceName, Prefix prefix, String target, } data = dataSupplier(sourceNamesToSearchFor); - Map sourceDataForSourceName = data.data(); - LinkedHashSet sourceNamesFound = data.names(); - String sortedNames = data.names() - .stream() + LinkedHashMap> sourceData = data.data(); + + Set sourceNamesFound = sourceData.keySet(); + String sortedNames = sourceNamesFound.stream() .sorted() .collect(Collectors.joining(PROPERTY_SOURCE_NAME_SEPARATOR)); sourceDataName = generateSourceName(target, sortedNames, namespace, activeProfiles); - if (data.names().isEmpty()) { + if (sourceData.isEmpty()) { return emptySourceData(target, sourceName, namespace); } if (prefix.getName().equals(Prefix.DEFAULT.getName())) { - return new SourceData(sourceDataName, - defaultFlattenedSourceData(sourceNamesFound, sourceDataForSourceName)); + return new SourceData(sourceDataName, defaultFlattenedSourceData(sourceData)); } if (prefix.getName().equals(Prefix.KNOWN.getName())) { - return new SourceData(sourceDataName, prefixFlattenedSourceData(sourceNamesFound, - sourceDataForSourceName, prefix.prefixProvider().get())); + return new SourceData(sourceDataName, + prefixFlattenedSourceData(sourceData, prefix.prefixProvider().get())); } if (prefix.getName().equals(Prefix.DELAYED.getName())) { - return new SourceData(sourceDataName, - nameFlattenedSourceData(sourceNamesFound, sourceDataForSourceName)); + return new SourceData(sourceDataName, nameFlattenedSourceData(sourceData)); } throw new IllegalArgumentException("Unsupported prefix: " + prefix); @@ -93,7 +93,11 @@ public final SourceData compute(String sourceName, Prefix prefix, String target, catch (Exception e) { LOG.warn("Failure in reading named sources"); onException(failFast, e); - String names = data.names().stream().sorted().collect(Collectors.joining(PROPERTY_SOURCE_NAME_SEPARATOR)); + String names = data.data() + .keySet() + .stream() + .sorted() + .collect(Collectors.joining(PROPERTY_SOURCE_NAME_SEPARATOR)); return new SourceData(generateSourceName(target, names, namespace, activeProfiles), Map.of(ERROR_PROPERTY, "true")); } diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java index 0c795fe8e0..c63386a993 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataFlattener.java @@ -44,8 +44,7 @@ static Map defaultFlattenedSourceData(LinkedHashMap prefixFlattenedSourceData(LinkedHashMap> sourceData, String prefix) { Map flattenedData = new HashMap<>(); - sourceData.values().forEach(data -> - data.forEach((key, value) -> flattenedData.put(prefix + "." + key, value))); + sourceData.values().forEach(data -> data.forEach((key, value) -> flattenedData.put(prefix + "." + key, value))); return flattenedData; } @@ -55,8 +54,7 @@ static Map prefixFlattenedSourceData(LinkedHashMap nameFlattenedSourceData(LinkedHashMap> sourceData) { Map flattenedData = new HashMap<>(); - sourceData.forEach((name, data) -> - data.forEach((key, value) -> flattenedData.put(name + "." + key, value))); + sourceData.forEach((name, data) -> data.forEach((key, value) -> flattenedData.put(name + "." + key, value))); return flattenedData; } diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsProcessSourceTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsProcessSourceTests.java index ec18f1ca03..23ef551cfc 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsProcessSourceTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsProcessSourceTests.java @@ -80,10 +80,9 @@ void testProcessNamedDataOne() { MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames, namespace, decode, includeDefaultProfileData); Assertions.assertThat(result).isNotNull(); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("configmap-a"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("configmap-a"); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("configmap-a"); + Map data = result.data().get("configmap-a"); Assertions.assertThat(data).containsExactlyInAnyOrderEntriesOf(Map.of("one", "1")); } @@ -162,7 +161,7 @@ void testProcessNamedDataTwo(CapturedOutput output) { MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames, namespace, decode, includeDefaultProfileData); Assertions.assertThat(result).isNotNull(); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("account"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("account"); /** *
@@ -176,8 +175,7 @@ void testProcessNamedDataTwo(CapturedOutput output) {
 		 *			since 'k8s' is not an active profile.
 		 * 
*/ - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("account"); + Map data = result.data().get("account"); Assertions.assertThat(data) .containsExactlyInAnyOrderEntriesOf(Map.of("one", "1", "two", "2", "three", "3", "five", "5")); Assertions.assertThat(output.getOut()).contains("entry : account-k8s.properties will be skipped"); @@ -258,7 +256,7 @@ void testProcessNamedDataThree(CapturedOutput output) { MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames, namespace, decode, includeDefaultProfileData); Assertions.assertThat(result).isNotNull(); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("account-default"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("account-default"); /** *
@@ -274,8 +272,7 @@ void testProcessNamedDataThree(CapturedOutput output) {
 		 *		6. we do not have 'four=4' since we do not read 'account-k8s.properties'
 		 * 
*/ - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("account-default"); + Map data = result.data().get("account-default"); Assertions.assertThat(data) .containsExactlyInAnyOrderEntriesOf(Map.of("one", "1", "two", "2", "three", "3", "five", "5")); Assertions.assertThat(output.getOut()).contains("entry : account-k8s.properties will be skipped"); @@ -373,14 +370,13 @@ void testProcessNamedDataFive(CapturedOutput output) { MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames, namespace, decode, includeDefaultProfileData); Assertions.assertThat(result).isNotNull(); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("account"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("account"); /* *
 - we only read from 'account-k8s.properties' 
*/ - @SuppressWarnings("unchecked") - Map accountData = (Map) result.data().get("account"); + Map accountData = result.data().get("account"); Assertions.assertThat(accountData).containsExactlyInAnyOrderEntriesOf(Map.of("one", "1111", "four", "4")); Assertions.assertThat(output.getOut()).contains("entry : account.properties will be skipped"); Assertions.assertThat(output.getOut()).contains("entry : account-default.properties will be skipped"); @@ -462,7 +458,7 @@ void testProcessNamedDataSix(CapturedOutput output) { MultipleSourcesContainer result = ConfigUtils.processNamedData(strippedSources, environment, sourceNames, namespace, decode, includeDefaultProfileData); Assertions.assertThat(result).isNotNull(); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("account-k8s"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("account-k8s"); /** *
@@ -481,8 +477,7 @@ void testProcessNamedDataSix(CapturedOutput output) {
 		 *			(because 'prod' is not an active profile)
 		 * 
*/ - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("account-k8s"); + Map data = result.data().get("account-k8s"); Assertions.assertThat(data).containsExactlyInAnyOrderEntriesOf(Map.of("one", "1111", "five", "5")); Assertions.assertThat(output.getOut()).contains("entry : account-prod.properties will be skipped"); Assertions.assertThat(output.getOut()).contains("entry : account.properties will be skipped"); diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java index 6a40e4f0cc..a0a831c3fb 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java @@ -166,13 +166,11 @@ void testMerge() { new MockEnvironment(), sourceNames, "default", false); Assertions.assertThat(result.data().size()).isEqualTo(2); - @SuppressWarnings("unchecked") - Map one = (Map) result.data().get("configmap-one"); + Map one = result.data().get("configmap-one"); Assertions.assertThat(one.get("propA")).isEqualTo("A"); Assertions.assertThat(one.get("propB")).isEqualTo("B"); - @SuppressWarnings("unchecked") - Map oneKubernetes = (Map) result.data().get("configmap-one-kubernetes"); + Map oneKubernetes = result.data().get("configmap-one-kubernetes"); Assertions.assertThat(oneKubernetes.get("propA")).isEqualTo("AA"); Assertions.assertThat(oneKubernetes.get("propC")).isEqualTo("C"); @@ -205,7 +203,6 @@ void testKeysWithPrefixNonEmptyPrefix() { } @Test - @SuppressWarnings("unchecked") void testIssue1757() { StrippedSourceContainer containerA = new StrippedSourceContainer(Map.of("load", "true"), "client-1", @@ -217,14 +214,13 @@ void testIssue1757() { MultipleSourcesContainer container = ConfigUtils.processLabeledData(List.of(containerA, containerB), new MockEnvironment(), Map.of("load", "true"), "default", Set.of(), false); - System.out.println(container); - assertThat(container.names()).containsExactlyInAnyOrder("client-1", "client-2"); + assertThat(container.data().keySet()).containsExactlyInAnyOrder("client-1", "client-2"); - Map client1Data = (Map) container.data().get("client-1"); + Map client1Data = container.data().get("client-1"); assertThat(client1Data) .containsExactlyInAnyOrderEntriesOf(Map.of("client-id", "clientA", "client-secret", "a")); - Map client2Data = (Map) container.data().get("client-2"); + Map client2Data = container.data().get("client-2"); assertThat(client2Data) .containsExactlyInAnyOrderEntriesOf(Map.of("client-id", "clientB", "client-secret", "b")); diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java index 4be4ed2ea3..a5e88ff978 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigUtilsTests.java @@ -63,7 +63,7 @@ void testSecretDataByLabelsSecretNotFound() { MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByLabels(client, "spring-k8s", Map.of("color", "red"), new MockEnvironment(), Set.of()); Assertions.assertThat(result.data()).isEmpty(); - Assertions.assertThat(result.names()).isEmpty(); + Assertions.assertThat(result.data().keySet()).isEmpty(); } // secret "my-secret" is deployed with label {color:pink}; we search for it by same @@ -80,10 +80,9 @@ void testSecretDataByLabelsSecretFound() { MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByLabels(client, "spring-k8s", Map.of("color", "pink"), new MockEnvironment(), Set.of()); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("my-secret"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("my-secret"); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("my-secret"); + Map data = result.data().get("my-secret"); Assertions.assertThat(data).containsExactlyInAnyOrderEntriesOf(Map.of("property", "value")); } @@ -102,10 +101,9 @@ void testSecretDataByLabelsSecretFoundWithPropertyFile() { MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByLabels(client, "spring-k8s", Map.of("color", "pink"), new MockEnvironment(), Set.of()); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("my-secret"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("my-secret"); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("my-secret"); + Map data = result.data().get("my-secret"); Assertions.assertThat(data).containsExactlyInAnyOrderEntriesOf(Map.of("key1", "value1")); } @@ -132,15 +130,13 @@ void testSecretDataByLabelsTwoSecretsFound() { MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByLabels(client, "spring-k8s", Map.of("color", "pink"), new MockEnvironment(), Set.of()); - Assertions.assertThat(result.names()).contains("my-secret"); - Assertions.assertThat(result.names()).contains("my-secret-2"); + Assertions.assertThat(result.data().keySet()).contains("my-secret"); + Assertions.assertThat(result.data().keySet()).contains("my-secret-2"); - @SuppressWarnings("unchecked") - Map mySecretData = (Map) result.data().get("my-secret"); + Map mySecretData = result.data().get("my-secret"); Assertions.assertThat(mySecretData).containsExactlyInAnyOrderEntriesOf(Map.of("property", "value")); - @SuppressWarnings("unchecked") - Map mySecret2Data = (Map) result.data().get("my-secret-2"); + Map mySecret2Data = result.data().get("my-secret-2"); Assertions.assertThat(mySecret2Data).containsExactlyInAnyOrderEntriesOf(Map.of("property-2", "value-2")); } @@ -202,20 +198,17 @@ void testSecretDataByLabelsThreeSecretsFound() { MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByLabels(client, "spring-k8s", Map.of("tag", "fit", "color", "blue"), new MockEnvironment(), Set.of("k8s")); - Assertions.assertThat(result.names()).contains("blue-circle-secret"); - Assertions.assertThat(result.names()).contains("blue-square-secret"); - Assertions.assertThat(result.names()).contains("blue-square-secret-k8s"); + Assertions.assertThat(result.data().keySet()).contains("blue-circle-secret"); + Assertions.assertThat(result.data().keySet()).contains("blue-square-secret"); + Assertions.assertThat(result.data().keySet()).contains("blue-square-secret-k8s"); - @SuppressWarnings("unchecked") - Map dataBlueSecret = (Map) result.data().get("blue-circle-secret"); + Map dataBlueSecret = result.data().get("blue-circle-secret"); Assertions.assertThat(dataBlueSecret).containsExactlyInAnyOrderEntriesOf(Map.of("one", "1")); - @SuppressWarnings("unchecked") - Map dataSquareSecret = (Map) result.data().get("blue-square-secret"); + Map dataSquareSecret = result.data().get("blue-square-secret"); Assertions.assertThat(dataSquareSecret).containsExactlyInAnyOrderEntriesOf(Map.of("two", "2")); - @SuppressWarnings("unchecked") - Map dataSquareSecretK8s = (Map) result.data().get("blue-square-secret-k8s"); + Map dataSquareSecretK8s = result.data().get("blue-square-secret-k8s"); Assertions.assertThat(dataSquareSecretK8s).containsExactlyInAnyOrderEntriesOf(Map.of("four", "4")); } @@ -231,7 +224,7 @@ void testSecretDataByNameSecretNotFound() { names.add("nope"); MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByName(client, "spring-k8s", names, new MockEnvironment()); - Assertions.assertThat(result.names()).isEmpty(); + Assertions.assertThat(result.data()).isEmpty(); Assertions.assertThat(result.data()).isEmpty(); } @@ -249,10 +242,9 @@ void testSecretDataByNameSecretFound() { MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByName(client, "spring-k8s", names, new MockEnvironment()); - Assertions.assertThat(result.names().size()).isEqualTo(1); + Assertions.assertThat(result.data().size()).isEqualTo(1); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("my-secret"); + Map data = result.data().get("my-secret"); Assertions.assertThat(data.get("property")).isEqualTo("value"); } @@ -279,17 +271,15 @@ void testSecretDataByNameTwoSecretsFound() { MultipleSourcesContainer result = Fabric8ConfigUtils.secretsDataByName(client, "spring-k8s", names, new MockEnvironment()); - Assertions.assertThat(result.names()).contains("my-secret"); - Assertions.assertThat(result.names()).contains("my-secret-2"); + Assertions.assertThat(result.data().keySet()).contains("my-secret"); + Assertions.assertThat(result.data().keySet()).contains("my-secret-2"); Assertions.assertThat(result.data().size()).isEqualTo(2); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("my-secret"); + Map data = result.data().get("my-secret"); Assertions.assertThat(data.get("property")).isEqualTo("value"); - @SuppressWarnings("unchecked") - Map data2 = (Map) result.data().get("my-secret-2"); + Map data2 = result.data().get("my-secret-2"); Assertions.assertThat(data2.get("property-2")).isEqualTo("value-2"); } @@ -307,10 +297,9 @@ void testConfigMapsDataByNameFoundNoData() { MultipleSourcesContainer result = Fabric8ConfigUtils.configMapsDataByName(client, "spring-k8s", names, new MockEnvironment()); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("my-config-map"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("my-config-map"); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("my-config-map"); + Map data = result.data().get("my-config-map"); Assertions.assertThat(data).isEmpty(); } @@ -326,7 +315,7 @@ void testConfigMapsDataByNameNotFound() { names.add("my-config-map-not-found"); MultipleSourcesContainer result = Fabric8ConfigUtils.configMapsDataByName(client, "spring-k8s", names, new MockEnvironment()); - Assertions.assertThat(result.names()).isEmpty(); + Assertions.assertThat(result.data().keySet()).isEmpty(); Assertions.assertThat(result.data()).isEmpty(); } @@ -345,10 +334,9 @@ void testConfigMapDataByNameFound() { MultipleSourcesContainer result = Fabric8ConfigUtils.configMapsDataByName(client, "spring-k8s", names, new MockEnvironment()); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("my-config-map"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("my-config-map"); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("my-config-map"); + Map data = result.data().get("my-config-map"); Assertions.assertThat(data).containsExactlyInAnyOrderEntriesOf(Map.of("property", "value")); } @@ -368,10 +356,9 @@ void testConfigMapDataByNameFoundWithPropertyFile() { MultipleSourcesContainer result = Fabric8ConfigUtils.configMapsDataByName(client, "spring-k8s", names, new MockEnvironment()); - Assertions.assertThat(result.names()).containsExactlyInAnyOrder("my-config-map"); + Assertions.assertThat(result.data().keySet()).containsExactlyInAnyOrder("my-config-map"); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("my-config-map"); + Map data = result.data().get("my-config-map"); Assertions.assertThat(data).containsExactlyInAnyOrderEntriesOf(Map.of("key1", "value1")); } @@ -399,17 +386,15 @@ void testConfigMapDataByNameTwoFound() { MultipleSourcesContainer result = Fabric8ConfigUtils.configMapsDataByName(client, "spring-k8s", names, new MockEnvironment()); - Assertions.assertThat(result.names()).contains("my-config-map"); - Assertions.assertThat(result.names()).contains("my-config-map-2"); + Assertions.assertThat(result.data().keySet()).contains("my-config-map"); + Assertions.assertThat(result.data().keySet()).contains("my-config-map-2"); Assertions.assertThat(result.data().size()).isEqualTo(2); - @SuppressWarnings("unchecked") - Map data = (Map) result.data().get("my-config-map"); + Map data = result.data().get("my-config-map"); Assertions.assertThat(data).containsExactlyInAnyOrderEntriesOf(Map.of("property", "value")); - @SuppressWarnings("unchecked") - Map data2 = (Map) result.data().get("my-config-map-2"); + Map data2 = result.data().get("my-config-map-2"); Assertions.assertThat(data2).containsExactlyInAnyOrderEntriesOf(Map.of("property-2", "value-2")); }