|
65 | 65 | * |
66 | 66 | * @author Phillip Webb |
67 | 67 | * @author Madhura Bhave |
| 68 | + * @author Ahmed El Amraouiyine |
68 | 69 | */ |
69 | 70 | class MapBinderTests { |
70 | 71 |
|
@@ -274,6 +275,15 @@ void bindToMapWhenNoValueShouldReturnUnbound() { |
274 | 275 | assertThat(result.isBound()).isFalse(); |
275 | 276 | } |
276 | 277 |
|
| 278 | + @Test |
| 279 | + void bindToMapWhenEmptyStringShouldReturnEmptyMap() { |
| 280 | + MockConfigurationPropertySource source = new MockConfigurationPropertySource(); |
| 281 | + source.put("foo", ""); |
| 282 | + this.sources.add(source); |
| 283 | + Map<String, String> result = this.binder.bind("foo", STRING_STRING_MAP).get(); |
| 284 | + assertThat(result).isEmpty(); |
| 285 | + } |
| 286 | + |
277 | 287 | @Test |
278 | 288 | void bindToMapShouldConvertKey() { |
279 | 289 | MockConfigurationPropertySource source = new MockConfigurationPropertySource(); |
@@ -510,6 +520,17 @@ void nestedMapsShouldNotBindToNull() { |
510 | 520 | assertThat(foo2.getValue()).isEqualTo("three"); |
511 | 521 | } |
512 | 522 |
|
| 523 | + @Test |
| 524 | + void nestedMapsWhenEmptyStringShouldReturnEmptyMap() { |
| 525 | + MockConfigurationPropertySource source = new MockConfigurationPropertySource(); |
| 526 | + source.put("foo.value", "one"); |
| 527 | + source.put("foo.foos", ""); |
| 528 | + this.sources.add(source); |
| 529 | + BindResult<NestableFoo> foo = this.binder.bind("foo", NestableFoo.class); |
| 530 | + assertThat(foo.get().getValue()).isEqualTo("one"); |
| 531 | + assertThat(foo.get().getFoos()).isEmpty(); |
| 532 | + } |
| 533 | + |
513 | 534 | @Test |
514 | 535 | void bindToMapWithCustomConverter() { |
515 | 536 | DefaultConversionService conversionService = new DefaultConversionService(); |
|
0 commit comments