GroupMessage implements Message { public Builder toBuilder() { return new Builder(this); }  static Builder builder(String groupId); abstract String groupId(); @Nullable abstract Map<String, ?> traits(); Builder toBuilder();  }
@Test public void toBuilder() { GroupMessage original = GroupMessage.builder("groupId") .userId("userId") .traits(ImmutableMap.of("foo", "bar")) .build(); GroupMessage copy = original.toBuilder().build(); assertThat(copy.groupId()).isEqualTo("groupId"); assertThat(copy.traits()).isEqualTo(ImmutableMap.of("foo", "bar")); }