facebook / facebook-java-business-sdk

Java SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
393 stars 324 forks source link

Fixed Flaky Test: CustomDataParametersTest #440

Open deekshacheruku opened 9 months ago

deekshacheruku commented 9 months ago

Fixed the flaky test CustomDataParametersTest inside src/test/java/com/facebook/ads/ServerSideTest class.

Root Cause The test CustomDataParametersTest has been reported as flaky when ran with the NonDex tool. The test failed because it is trying to check if it contains a string or not which is actually nothing but a String Values of List, Hash Map. The HashMap/List in Java is implemented in such a way that it does not store the order in which the keys and/or values are inserted. As a result, when the expected string (which is hard-coded) is compared with the actual one, it failed.

Fix The simplest fix is to check if all the patterns of expected String in actual String serialisedPayload. Since there were only two possible order changes, it was easy to hardcode the expected patterns and fix the flakiness.

How this has been tested?

Java: openjdk version "11.0.20.1" Maven: Apache Maven 3.6.3

Module build: Successful Command used: mvn install -am -DskipTests

Regular test: Successful Command used: mvn test -Dtest=com.facebook.ads.ServerSideTest#CustomDataParametersTest

NonDex test: Failed Command used: mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=com.facebook.ads.ServerSideTest#CustomDataParametersTest

NonDex test passed after the fix.

Let me know if you have any further questions

facebook-github-bot commented 9 months ago

Hi @deekshacheruku!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!