Skip to content

Conversation

@anthonyx24
Copy link

@anthonyx24 anthonyx24 commented Dec 3, 2025

Issue

Hello, this is a direct follow-up to my previous PR: #1546 . These tests all may be nondeterministic due to the same reason, which is JSON parameter ordering not guaranteed by Jackson's default ObjectMapper.

Again, these tests were detected via the Nondex tool, which flags Java tests that are potentially nondeterministic due to underlying assumptions regarding the Java API. In total, 11 tests were flagged (10 fixed here, 1 fixed in the previous PR):

org.telegram.telegrambots.meta.api.methods.send.TestSendMediaGroup.test
org.telegram.telegrambots.meta.api.methods.stories.TestDeleteStory.testJsonSerialization
org.telegram.telegrambots.meta.api.methods.stories.TestEditStory.testJsonSerialization
org.telegram.telegrambots.meta.api.methods.TestGetUpdates.testGetUpdatesMustBeSerializable
org.telegram.telegrambots.meta.api.methods.TestSetGameScore.TestGetUpdatesMustBeSerializable
org.telegram.telegrambots.meta.api.objects.stories.area.TestStoryAreaTypeSuggestedReaction.testJsonSerialization
org.telegram.telegrambots.meta.api.objects.stories.area.TestStoryAreaTypeWeather.testJsonSerialization
org.telegram.telegrambots.meta.api.objects.stories.input.TestInputStoryContentVideo.testJsonSerialization
org.telegram.telegrambots.meta.api.objects.TestDocument.testSerialization
org.telegram.telegrambots.meta.test.TestSerialization.testAnswerInlineLocation
org.telegram.telegrambots.meta.test.TestSerialization.testSendLocation

Potential Fix

As detailed in the other PR's description, the fix I implemented is to explicitly configure the ObjectMapper to sort the JSON parameters alphabetically during serialization. Then, I manually sort the parameters of the expected JSON strings. The tests still pass (verified with mvn clean test), and Nondex also shows a passing result now.

I know this seems like quite a large PR, but I'm just applying the same approach 10 times. Please let me know regarding feedback or questions. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant