Fix java.lang.UnsupportedOperationException in StateDescriptionFragmentBuilder (#1405)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>pull/1409/head
parent
86dc92b6c8
commit
259af7aaef
|
@ -46,7 +46,7 @@ public class StateDescriptionFragmentBuilder {
|
|||
this.pattern = legacy.getPattern();
|
||||
this.readOnly = Boolean.valueOf(legacy.isReadOnly());
|
||||
if (!legacy.getOptions().isEmpty()) {
|
||||
this.options = legacy.getOptions();
|
||||
this.options = new ArrayList<>(legacy.getOptions());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,8 @@ public class StateDescriptionFragmentBuilderTest {
|
|||
public void builderWithStateDescription() {
|
||||
StateDescription source = new StateDescription(BigDecimal.ZERO, BigDecimal.TEN, BigDecimal.ONE, "pattern", true,
|
||||
Collections.singletonList(new StateOption("value", "label")));
|
||||
StateDescriptionFragment fragment = StateDescriptionFragmentBuilder.create(source).build();
|
||||
StateDescriptionFragmentBuilder builder = StateDescriptionFragmentBuilder.create(source);
|
||||
StateDescriptionFragment fragment = builder.build();
|
||||
|
||||
assertThat(fragment.getMinimum(), is(source.getMinimum()));
|
||||
assertThat(fragment.getMaximum(), is(source.getMaximum()));
|
||||
|
@ -93,6 +94,8 @@ public class StateDescriptionFragmentBuilderTest {
|
|||
assertThat(fragment.getPattern(), is(source.getPattern()));
|
||||
assertThat(fragment.isReadOnly(), is(source.isReadOnly()));
|
||||
assertThat(fragment.getOptions(), is(source.getOptions()));
|
||||
|
||||
builder.withOption(new StateOption("NEW value", "NEW label"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue