Fix java.lang.UnsupportedOperationException in StateDescriptionFragmentBuilder (#1405)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
pull/1409/head
Christoph Weitkamp 2020-04-05 17:53:48 +02:00 committed by GitHub
parent 86dc92b6c8
commit 259af7aaef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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());
}
}

View File

@ -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