ImmutableReplyTarget implements ReplyTarget { @Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate) { final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); jsonObjectBuilder.set(JsonFields.ADDRESS, address); if (headerMapping != null) { jsonObjectBuilder.set(JsonFields.HEADER_MAPPING, headerMapping.toJson(schemaVersion, predicate), predicate); } jsonObjectBuilder.set(JsonFields.EXPECTED_RESPONSE_TYPES, expectedResponseTypes.stream() .map(ResponseType::getName) .map(JsonFactory::newValue) .collect(JsonCollectors.valuesToArray())); return jsonObjectBuilder.build(); } private  ImmutableReplyTarget(final Builder builder); @Override String getAddress(); @Override Optional<HeaderMapping> getHeaderMapping(); @Override Set<ResponseType> getExpectedResponseTypes(); @Override ReplyTarget.Builder toBuilder(); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> predicate); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void toJsonReturnsExpected() { final JsonObject actual = REPLY_TARGET.toJson(); assertThat(actual).isEqualTo(REPLY_TARGET_JSON); }