diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java index fc9eb2d8315..861b6af4d4c 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java @@ -100,7 +100,7 @@ public final class TestPropertyValues { * @since 2.4.0 */ public TestPropertyValues and(@Nullable Map map) { - return (map != null) ? and(map.entrySet().stream(), Pair::fromMapEntry) : this; + return (map != null) ? and(map.entrySet().stream(), Pair::fromNonNullValueMapEntry) : this; } /** @@ -257,7 +257,7 @@ public final class TestPropertyValues { * @return the new instance */ public static TestPropertyValues of(@Nullable Map map) { - return (map != null) ? of(map.entrySet().stream(), Pair::fromMapEntry) : empty(); + return (map != null) ? of(map.entrySet().stream(), Pair::fromNonNullValueMapEntry) : empty(); } /** @@ -363,6 +363,10 @@ public final class TestPropertyValues { return of(entry.getKey(), entry.getValue()); } + private static Pair fromNonNullValueMapEntry(Map.Entry entry) { + return of(entry.getKey(), entry.getValue()); + } + /** * Factory method to create a {@link Pair} from a name and value. * @param name the name