ImmutableFilteredAcknowledgementRequest implements FilteredAcknowledgementRequest { @Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate) { final Predicate<JsonField> predicate = schemaVersion.and(thePredicate); final JsonObjectBuilder jsonObjectBuilder = JsonFactory.newObjectBuilder(); jsonObjectBuilder.set(JsonFields.INCLUDES, includes.stream() .map(AcknowledgementRequest::getLabel) .map(AcknowledgementLabel::toString) .map(JsonFactory::newValue) .collect(JsonCollectors.valuesToArray()), predicate); if (filter != null) { jsonObjectBuilder.set(JsonFields.FILTER, filter, predicate); } return jsonObjectBuilder.build(); } private  ImmutableFilteredAcknowledgementRequest(final Set<AcknowledgementRequest> includes,
            @Nullable final String filter); @Override Set<AcknowledgementRequest> getIncludes(); @Override Optional<String> getFilter(); static FilteredAcknowledgementRequest fromJson(final JsonObject jsonObject); @Override JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void toJsonReturnsExpected() { final JsonObject actual = FILTERED_ACKNOWLEDGEMENT_REQUEST.toJson(); assertThat(actual).isEqualTo(FILTERED_ACKNOWLEDGEMENT_REQUEST_JSON); }