|
18 | 18 |
|
19 | 19 | import java.util.ArrayList;
|
20 | 20 | import java.util.Collections;
|
| 21 | +import java.util.EnumSet; |
21 | 22 | import java.util.HashSet;
|
22 | 23 | import java.util.LinkedList;
|
23 | 24 | import java.util.List;
|
|
27 | 28 | import org.junit.Before;
|
28 | 29 | import org.junit.Test;
|
29 | 30 |
|
| 31 | +import org.springframework.boot.context.properties.bind.BinderTests.ExampleEnum; |
30 | 32 | import org.springframework.boot.context.properties.bind.BinderTests.JavaBean;
|
31 | 33 | import org.springframework.boot.context.properties.source.ConfigurationProperty;
|
32 | 34 | import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
|
@@ -448,6 +450,17 @@ public void bindToBeanWithExceptionInGetterForExistingValue() {
|
448 | 450 | assertThat(result.getValues()).containsExactly("a", "b", "c");
|
449 | 451 | }
|
450 | 452 |
|
| 453 | + @Test |
| 454 | + public void bindToBeanWithEnumSetCollection() { |
| 455 | + MockConfigurationPropertySource source = new MockConfigurationPropertySource(); |
| 456 | + source.put("foo.values[0]", "foo-bar,bar-baz"); |
| 457 | + this.sources.add(source); |
| 458 | + BeanWithEnumsetCollection result = this.binder |
| 459 | + .bind("foo", Bindable.of(BeanWithEnumsetCollection.class)).get(); |
| 460 | + assertThat(result.getValues().get(0)).containsExactly(ExampleEnum.FOO_BAR, |
| 461 | + ExampleEnum.BAR_BAZ); |
| 462 | + } |
| 463 | + |
451 | 464 | public static class ExampleCollectionBean {
|
452 | 465 |
|
453 | 466 | private List<String> items = new ArrayList<>();
|
@@ -566,4 +579,18 @@ public List<String> getValues() {
|
566 | 579 |
|
567 | 580 | }
|
568 | 581 |
|
| 582 | + public static class BeanWithEnumsetCollection { |
| 583 | + |
| 584 | + private List<EnumSet<ExampleEnum>> values; |
| 585 | + |
| 586 | + public void setValues(List<EnumSet<ExampleEnum>> values) { |
| 587 | + this.values = values; |
| 588 | + } |
| 589 | + |
| 590 | + public List<EnumSet<ExampleEnum>> getValues() { |
| 591 | + return this.values; |
| 592 | + } |
| 593 | + |
| 594 | + } |
| 595 | + |
569 | 596 | }
|
0 commit comments