From be7fe85b55a04f3bee38943b3bf48635675a99b1 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Wed, 6 May 2020 15:35:44 -0700 Subject: [PATCH] Polish --- .../SystemEnvironmentPropertyMapperTests.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java index 01458c2d21..0800f12e33 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapperTests.java @@ -78,17 +78,29 @@ class SystemEnvironmentPropertyMapperTests extends AbstractPropertyMapperTests { @Test void isAncestorOfConsidersLegacyNames() { ConfigurationPropertyName name = ConfigurationPropertyName.of("my.spring-boot"); - assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.spring-boot.property"))).isTrue(); - assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.springboot.property"))).isTrue(); - assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.boot.property"))).isFalse(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.adapt("MY_SPRING_BOOT_PROPERTY", '_'))) + .isTrue(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.adapt("MY_SPRINGBOOT_PROPERTY", '_'))) + .isTrue(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.adapt("MY_BOOT_PROPERTY", '_'))).isFalse(); } @Test - void isAncestorOfWhenCamelCaseSourceConsidersLegacyNames() { + void isAncestorOfWhenNonCanonicalSource() { ConfigurationPropertyName name = ConfigurationPropertyName.adapt("my.springBoot", '.'); assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.spring-boot.property"))).isTrue(); assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.springboot.property"))).isTrue(); assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.boot.property"))).isFalse(); } + @Test + void isAncestorOfWhenNonCanonicalAndDashedSource() { + ConfigurationPropertyName name = ConfigurationPropertyName.adapt("my.springBoot.input-value", '.'); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.spring-boot.input-value.property"))) + .isTrue(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.springboot.inputvalue.property"))) + .isTrue(); + assertThat(getMapper().isAncestorOf(name, ConfigurationPropertyName.of("my.boot.property"))).isFalse(); + } + }