bmk15897 opened a new pull request, #681: URL: https://github.com/apache/camel-spring-boot/pull/681
### Description Flaky Tests found using [NonDex](https://github.com/TestingResearchIllinois/NonDex) by running the commands - ` mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.apache.camel.component.gson.springboot.GsonFieldNamePolicyTest#testMarshalPojo ` ` mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.apache.camel.component.gson.springboot.GsonMarshalExclusionTest#testMarshalAndUnmarshalPojoWithAnotherExclusion ` ` mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.apache.camel.component.gson.springboot.SpringGsonFieldNamePolicyTest#testMarshalPojo ` The logged failures were- ``` [WARNING] Flakes: [WARNING] org.apache.camel.component.gson.springboot.GsonFieldNamePolicyTest.testMarshalPojo [ERROR] Run 1: GsonFieldNamePolicyTest.testMarshalPojo:76 expected: <{"id":123,"first_name":"Donald","last_name":"Duck"}> but was: <{"id":123,"last_name":"Duck","first_name":"Donald"}> [INFO] Run 2: PASS ``` ``` [ERROR] [WARNING] Flakes: [WARNING] org.apache.camel.component.gson.springboot.GsonMarshalExclusionTest.testMarshalAndUnmarshalPojoWithAnotherExclusion [ERROR] Run 1: GsonMarshalExclusionTest.testMarshalAndUnmarshalPojoWithAnotherExclusion:98 expected: <{"height":190,"weight":70}> but was: <{"weight":70,"height":190}> [INFO] Run 2: PASS ``` ``` [WARNING] Flakes: [WARNING] org.apache.camel.component.gson.springboot.SpringGsonFieldNamePolicyTest.testMarshalPojo [ERROR] Run 1: SpringGsonFieldNamePolicyTest.testMarshalPojo:87 expected: <{"id":123,"first_name":"Donald","last_name":"Duck"}> but was: <{"last_name":"Duck","id":123,"first_name":"Donald"}> [INFO] Run 2: PASS ``` ### Investigation The tests fail with a comparison error while comparing an expected JSON String and the result from the value returned by the funtion template.requestBody(...). The function of the that converts given Pojo Object to String does not guarantee the order of the fields in the Pojos. This makes the test outcome non-deterministic, and the test fails whenever the function returns a mismatch in order of the elements in the JSON String. To fix this, the expected and actual keys should be checked in a more deterministic way so that the assertions do not fail. ### Fix Expected and actual arrays can be compared without making assumptions about the order of the keys in these JSON Strings. Instead of using assertEquals for the complete JSON String, using contains for every subpart of the expected String makes the test more deterministic and ensures that the flakiness from the test is removed. The PR does not introduce a breaking change. -- 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: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org