Dhairya-007 commented on PR #29569:
URL: https://github.com/apache/camel/pull/29569#issuecomment-6774237533

   Added `NowSearchTermTest` with the equals/hashCode contract test, thanks. 
Four cases: equal terms are equal and hash the same, and terms differing only 
in `comparison`, only in `offset`, or only in `sentDate` are not equal.
   
   Verified against both versions of `NowSearchTerm` — on `main` three of the 
four fail, with the fix all four pass:
   
   ```
   main:                                      with the fix:
   testEqualTermsAreEqual()            PASS   PASS
   testDifferentComparisonIsNotEqual() FAIL   PASS   expected: not equal but 
was: NowSearchTerm@6
   testDifferentOffsetIsNotEqual()     FAIL   PASS   expected: not equal but 
was: NowSearchTerm@1
   testDifferentSentDateIsNotEqual()   FAIL   PASS   expected: not equal but 
was: <1>
   ```
   
   The `sentDate` case is interesting: the old `equals` did compare `sentDate`, 
so it's the `hashCode` half that fails there — `hashCode()` returned the 
shadowed field, so two terms differing only in `sentDate` hashed identically. 
The other two fail on `equals` because `super.equals` compared `0 == 0` while 
the real operator sat in the shadowing field.
   
   It needs no mail server, so it runs in the normal `camel-mail` test phase.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to