JsonCollectors { public static Collector<JsonObject, JsonObjectBuilder, JsonObject> objectsToObject() { return Collector.of(JsonFactory::newObjectBuilder, JsonObjectBuilder::setAll, JsonObjectBuilder::setAll, JsonObjectBuilder::build); } private  JsonCollectors(); static Collector<JsonField, JsonObjectBuilder, JsonObject> fieldsToObject(); static Collector<JsonObject, JsonObjectBuilder, JsonObject> objectsToObject(); static Collector<JsonField, JsonArrayBuilder, JsonArray> fieldKeysToArray(); static Collector<JsonField, JsonArrayBuilder, JsonArray> fieldValuesToArray(); static Collector<JsonValue, JsonArrayBuilder, JsonArray> valuesToArray();  }
@Test public void collectingObjectsReturnsExpectedObject() { final JsonObject anotherJsonObject = JsonFactory.newObjectBuilder() .set("Foo", "Bar") .build(); final JsonObject expectedObject = JsonFactory.newObjectBuilder() .setAll(KNOWN_JSON_OBJECT) .setAll(anotherJsonObject) .build(); final JsonObject actualObject = Stream.of(KNOWN_JSON_OBJECT, anotherJsonObject).collect(JsonCollectors.objectsToObject()); DittoJsonAssertions.assertThat(actualObject).isEqualTo(expectedObject); }