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:
parent
25f0b3482c
commit
ac9f380c55
|
@ -48,6 +48,9 @@ public class CollectionBinderTests {
|
||||||
private static final Bindable<List<String>> STRING_LIST = Bindable
|
private static final Bindable<List<String>> STRING_LIST = Bindable
|
||||||
.listOf(String.class);
|
.listOf(String.class);
|
||||||
|
|
||||||
|
private static final Bindable<Set<String>> STRING_SET = Bindable
|
||||||
|
.setOf(String.class);
|
||||||
|
|
||||||
private List<ConfigurationPropertySource> sources = new ArrayList<>();
|
private List<ConfigurationPropertySource> sources = new ArrayList<>();
|
||||||
|
|
||||||
private Binder binder;
|
private Binder binder;
|
||||||
|
@ -68,6 +71,17 @@ public class CollectionBinderTests {
|
||||||
assertThat(result).containsExactly(1, 2, 3);
|
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
|
@Test
|
||||||
public void bindToCollectionWhenNestedShouldReturnPopulatedCollection()
|
public void bindToCollectionWhenNestedShouldReturnPopulatedCollection()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue