Add test showing composing Modifiable objects into a builder or other Modifiable doesn't work
@@ -231,4 +231,30 @@ public class ModifiablesTest {
.putMap("key", null)
.addList((String) null);
}
+
+ @Test
+ public void composeBuilders() {
+ final ModifiableBeanFriendly first = new ModifiableBeanFriendly();
+ first.setPrimary(true);
+ first.setId(42);
+ final ModifiableBeanFriendly second = new ModifiableBeanFriendly();
+ second.setPrimary(false);
+ second.setDescription("foo");
+ final ImmutableBeanFriendly result = ImmutableBeanFriendly.builder()
+ .from(first)
+ .from(second)
+ .build();
+ check(result.getId()).is(42);
+ check(!result.isPrimary());
+ check(result.getDescription()).is("foo");
+ }
+
+ @Test
+ public void copyPartialModifiable() {
+ final ModifiableBeanFriendly first = new ModifiableBeanFriendly();
+ first.setPrimary(true);
+ first.setId(42);
+ final ModifiableBeanFriendly second = new ModifiableBeanFriendly().from(first);
+ check(second.getId()).is(42);
+ }
}
