BaseReport { public JsonNode toJsonNode() { return uncheck(() -> mapper.valueToTree(this)); } @JsonCreator  BaseReport(@JsonProperty(CREATED_FIELD) Long createdMillisOrNull,
                      @JsonProperty(DESCRIPTION_FIELD) String descriptionOrNull,
                      @JsonProperty(TYPE_FIELD) Type typeOrNull);  BaseReport(Long createdMillisOrNull, String descriptionOrNull); @JsonGetter(CREATED_FIELD) final Long getCreatedMillisOrNull(); @JsonGetter(DESCRIPTION_FIELD) final String getDescriptionOrNull(); @JsonGetter(TYPE_FIELD) final Type getTypeOrNull(); Type getType(); boolean updates(BaseReport current); static boolean updates2(Optional<TNEW> newReport, Optional<TOLD> oldReport); static BaseReport fromJsonNode(JsonNode jsonNode); static R fromJsonNode(JsonNode jsonNode, Class<R> jacksonClass); static BaseReport fromJson(String json); static R fromJson(String json, Class<R> jacksonClass); JsonNode toJsonNode(); String toJson(); static final String CREATED_FIELD; static final String DESCRIPTION_FIELD; static final String TYPE_FIELD; }
@Test public void testSerialization1() { JsonTestHelper.assertJsonEquals(new BaseReport(1L, "desc", SOFT_FAIL).toJsonNode(), JSON_2); JsonTestHelper.assertJsonEquals(new BaseReport(null, "desc", SOFT_FAIL).toJsonNode(), "{\"description\": \"desc\", \"type\": \"SOFT_FAIL\"}"); JsonTestHelper.assertJsonEquals(new BaseReport(1L, null, SOFT_FAIL).toJsonNode(), "{\"createdMillis\": 1, \"type\": \"SOFT_FAIL\"}"); JsonTestHelper.assertJsonEquals(new BaseReport(null, null, SOFT_FAIL).toJsonNode(), "{\"type\": \"SOFT_FAIL\"}"); JsonTestHelper.assertJsonEquals(new BaseReport(1L, "desc", null).toJsonNode(), JSON_1); JsonTestHelper.assertJsonEquals(new BaseReport(null, "desc", null).toJsonNode(), "{\"description\": \"desc\"}"); JsonTestHelper.assertJsonEquals(new BaseReport(1L, null, null).toJsonNode(), "{\"createdMillis\": 1}"); JsonTestHelper.assertJsonEquals(new BaseReport(null, null, null).toJsonNode(), "{}"); }