Test binding of Set

Add a test to ensure that the new binder can bind correctly to a
Set.

Closes gh-1415
This commit is contained in:
Madhura Bhave 2017-04-26 15:15:31 -07:00
parent 25f0b3482c
commit ac9f380c55
1 changed files with 14 additions and 0 deletions

View File

@ -48,6 +48,9 @@ public class CollectionBinderTests {
private static final Bindable<List<String>> STRING_LIST = Bindable
.listOf(String.class);
private static final Bindable<Set<String>> STRING_SET = Bindable
.setOf(String.class);
private List<ConfigurationPropertySource> sources = new ArrayList<>();
private Binder binder;
@ -68,6 +71,17 @@ public class CollectionBinderTests {
assertThat(result).containsExactly(1, 2, 3);
}
@Test
public void bindToSetShouldReturnPopulatedCollection() throws Exception {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo[0]", "a");
source.put("foo[1]", "b");
source.put("foo[2]", "c");
this.sources.add(source);
Set<String> result = this.binder.bind("foo", STRING_SET).get();
assertThat(result).containsExactly("a", "b", "c");
}
@Test
public void bindToCollectionWhenNestedShouldReturnPopulatedCollection()
throws Exception {