ShardedMessageEnvelope implements Jsonifiable<JsonObject>, WithDittoHeaders<ShardedMessageEnvelope>, WithId { @Override public JsonObject toJson() { return JsonObject.newBuilder() .set(JSON_ID, String.valueOf(id)) .set(JSON_TYPE, type) .set(JSON_MESSAGE, message) .set(JSON_DITTO_HEADERS, dittoHeaders.toJson()) .build(); } private  ShardedMessageEnvelope(final EntityId id,
            final String type,
            final JsonObject message,
            final DittoHeaders dittoHeaders); static ShardedMessageEnvelope of(final EntityId id,
            final String type,
            final JsonObject message,
            final DittoHeaders dittoHeaders); static ShardedMessageEnvelope fromJson(final JsonObject jsonObject); EntityId getEntityId(); String getType(); JsonObject getMessage(); @Override DittoHeaders getDittoHeaders(); @Override ShardedMessageEnvelope setDittoHeaders(final DittoHeaders dittoHeaders); @Override JsonObject toJson(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static final JsonFieldDefinition<String> JSON_ID; static final JsonFieldDefinition<String> JSON_TYPE; static final JsonFieldDefinition<JsonObject> JSON_MESSAGE; static final JsonFieldDefinition<JsonObject> JSON_DITTO_HEADERS; }
@Test public void serializeMessage() { final JsonObject actual = SHARDED_MESSAGE_ENVELOPE.toJson(); assertThat(actual).isEqualTo(SHARDED_MESSAGE_ENVELOPE_JSON); }