StreamAck implements Jsonifiable { @Override public JsonValue toJson() { return JsonFactory.newObjectBuilder() .set(JsonFields.ELEMENT_ID, elementId) .set(JsonFields.STATUS, status.name()) .build(); } private  StreamAck(final String elementId, final Status status); static StreamAck success(final String elementId); static StreamAck failure(final String elementId); @Override JsonValue toJson(); static StreamAck fromJson(final JsonObject jsonObject); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void toJson() { final StreamAck original = StreamAck.success(KNOWN_ELEMENT_ID); final JsonValue serialized = original.toJson(); final StreamAck deserialized = StreamAck.fromJson(JsonFactory.newObject(serialized.toString())); assertThat(deserialized) .isEqualTo(original); }