Test Fix: Fix tests that can unintentionally fail in toXMLIncludesAllElements() and serializesPriorAuthenticationDetails() due to local time conversion #132
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The actual date in the output has been converted to the local time zone when compared to the expected date. As a result, these tests can fail depending on where they are run.
Below are examples where it fails under NonDex on line 49 in TransactionIndustryRequestTest.java and on line 235 in ThreeDSecureLookupRequestTest.java
(My timezone is CDT)
Click on to see more details on the error message when running both tests
To reproduce both, run these at the root directory:
The log output for both tests can be found here for your reference:
mvn-nondex-2-1729185623.log
mvn-nondex-1729184306.log
To resolve this, we need to ensure that the conversion to the local time zone doesn't occur when comparing with the expected date. To achieve this, we can explicitly set the Calendar's time zone to UTC.
After applying the fix, the test should now pass with NonDex as expected:
Please let me know if this approach works for you. If not, I'm happy to discuss alternatives and am willing to spend more time to address the test in the way you'd prefer. Thank you!