BaseReport { public boolean updates(BaseReport current) { if (this == current) return false; if (this.getClass() != current.getClass()) return true; return !Objects.equals(description, current.description) || !Objects.equals(type, current.type); } @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 testShouldUpdate() { BaseReport report = new BaseReport(1L, "desc", SOFT_FAIL); assertFalse(report.updates(report)); assertFalse(new BaseReport(1L, "desc", SOFT_FAIL).updates(report)); assertFalse(new BaseReport(2L, "desc", SOFT_FAIL).updates(report)); assertFalse(new BaseReport(null, "desc", SOFT_FAIL).updates(report)); assertTrue(new BaseReport(1L, "desc 2", SOFT_FAIL).updates(report)); assertTrue(new BaseReport(1L, null, SOFT_FAIL).updates(report)); assertTrue(new BaseReport(1L, "desc", null).updates(report)); assertTrue(new BaseReport(1L, "desc", BaseReport.Type.HARD_FAIL).updates(report)); }