diff --git a/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java b/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java index 6776686110d..971d2274466 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java @@ -25,6 +25,7 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; import org.mockito.Answers; +import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.springframework.boot.context.properties.bind.BinderTests.ExampleEnum; @@ -64,6 +65,9 @@ public class MapBinderTests { private static final Bindable> STRING_OBJECT_MAP = Bindable .mapOf(String.class, Object.class); + private static final Bindable> STRING_ARRAY_MAP = Bindable + .mapOf(String.class, String[].class); + private List sources = new ArrayList<>(); private Binder binder; @@ -352,4 +356,21 @@ public class MapBinderTests { eq(target), any(), isA(Map.class)); } + @Test + public void bindToMapStringArrayShouldTriggerOnSuccess() throws Exception { + this.sources + .add(new MockConfigurationPropertySource("foo.bar", "a,b,c", "line1")); + BindHandler handler = mock(BindHandler.class, + withSettings().defaultAnswer(Answers.CALLS_REAL_METHODS)); + Bindable> target = STRING_ARRAY_MAP; + this.binder.bind("foo", target, handler); + InOrder inOrder = inOrder(handler); + ArgumentCaptor array = ArgumentCaptor.forClass(String[].class); + inOrder.verify(handler).onSuccess(eq(ConfigurationPropertyName.of("foo.bar")), + eq(Bindable.of(String[].class)), any(), array.capture()); + assertThat(array.getValue()).containsExactly("a", "b", "c"); + inOrder.verify(handler).onSuccess(eq(ConfigurationPropertyName.of("foo")), + eq(target), any(), isA(Map.class)); + } + }