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