Create a deep copy of the first found fragment before merging other fragments into it (#2412)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>pull/2413/head
parent
8e3f87a212
commit
57c716bf80
|
@ -75,7 +75,8 @@ public class StateDescriptionServiceImpl implements StateDescriptionService {
|
||||||
|
|
||||||
// we pick up the first valid StateDescriptionFragment here:
|
// we pick up the first valid StateDescriptionFragment here:
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = (StateDescriptionFragmentImpl) fragment;
|
// create a deep copy of the first found fragment before merging other fragments into it
|
||||||
|
result = new StateDescriptionFragmentImpl((StateDescriptionFragmentImpl) fragment);
|
||||||
} else {
|
} else {
|
||||||
result.merge(fragment);
|
result.merge(fragment);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class StateDescriptionServiceImplTest {
|
||||||
|
|
||||||
StateDescription stateDescription = item.getStateDescription();
|
StateDescription stateDescription = item.getStateDescription();
|
||||||
|
|
||||||
assertThat(stateDescription.isReadOnly(), is(stateDescriptionFragment1.isReadOnly()));
|
assertThat(stateDescription.isReadOnly(), is(stateDescriptionFragment2.isReadOnly()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -167,8 +167,7 @@ public class StateDescriptionServiceImplTest {
|
||||||
.withMinimum(BigDecimal.ZERO) //
|
.withMinimum(BigDecimal.ZERO) //
|
||||||
.withMaximum(BigDecimal.TEN) //
|
.withMaximum(BigDecimal.TEN) //
|
||||||
.withPattern("pattern") //
|
.withPattern("pattern") //
|
||||||
.withReadOnly(Boolean.TRUE) //
|
.withReadOnly(Boolean.TRUE).build();
|
||||||
.withOptions(options).build();
|
|
||||||
registerStateDescriptionFragmentProvider(stateDescriptionFragment1, -1);
|
registerStateDescriptionFragmentProvider(stateDescriptionFragment1, -1);
|
||||||
|
|
||||||
StateDescriptionFragment stateDescriptionFragment2 = StateDescriptionFragmentBuilder.create()
|
StateDescriptionFragment stateDescriptionFragment2 = StateDescriptionFragmentBuilder.create()
|
||||||
|
@ -187,6 +186,8 @@ public class StateDescriptionServiceImplTest {
|
||||||
assertThat(stateDescription.getPattern(), is("pattern"));
|
assertThat(stateDescription.getPattern(), is("pattern"));
|
||||||
assertThat(stateDescription.isReadOnly(), is(true));
|
assertThat(stateDescription.isReadOnly(), is(true));
|
||||||
assertThat(stateDescription.getOptions(), is(options));
|
assertThat(stateDescription.getOptions(), is(options));
|
||||||
|
// check that fragement2 is not merged into fragement1
|
||||||
|
assertThat(stateDescriptionFragment1.getOptions().size(), is(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerStateDescriptionFragmentProvider(StateDescriptionFragment stateDescriptionFragment,
|
private void registerStateDescriptionFragmentProvider(StateDescriptionFragment stateDescriptionFragment,
|
||||||
|
|
Loading…
Reference in New Issue