From 91939336ecc290f58d7753e37de13c61fd80e11f Mon Sep 17 00:00:00 2001 From: Yujia Yan Date: Mon, 6 Dec 2021 16:15:08 -0600 Subject: [PATCH] fix flaky json test --- .DS_Store | Bin 0 -> 6148 bytes pom.xml | 5 +++++ src/test/java/JsonTest.java | 9 +++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5172429f264de2441865cb4700216d4256da9242 GIT binary patch literal 6148 zcmeH~J!%6%427R!7lt%jx}3%b$PET#pTHLgIFQEJ;E>dF^gR7ES*H$5cmnB-G%I%Z zD|S`@Z2$T80!#olbXV*=%*>dt@PRwdU#I)^a=X5>;#J@&VrHyNnC;iLL0pQvfVyTmjO&;ssLc!1UOG})p;=82 zR;?Ceh}WZ?+UmMqI#RP8R>OzYoz15hnq@nzF`-!xQ4j$Um=RcIKKc27r2jVm&svm< zfC&6E0=7P!4tu^-ovjbA=k?dB`g+i*aXG_}p8zI)6mRKa+;6_1_R^8c3Qa!(fk8n8 H{*=HsM+*^= literal 0 HcmV?d00001 diff --git a/pom.xml b/pom.xml index 7836aaa..8c17f68 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,11 @@ + + org.skyscreamer + jsonassert + 1.5.0 + com.squareup.okhttp3 okhttp diff --git a/src/test/java/JsonTest.java b/src/test/java/JsonTest.java index 6c3811b..f5d46bb 100644 --- a/src/test/java/JsonTest.java +++ b/src/test/java/JsonTest.java @@ -1,7 +1,8 @@ import com.sankuai.groupmeal.base.util.JsonUtil; import com.sankuai.groupmeal.business.pay.PayCallbackParam; -import org.junit.Assert; import org.junit.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.json.JSONException; /** * @author zhengxiaoluo @@ -26,6 +27,10 @@ public void payCallBackParam() { PayCallbackParam param1 = JsonUtil.decode2Camel(json, PayCallbackParam.class); String json1 = JsonUtil.encode2UnderScore(param1); System.out.println(json1); - Assert.assertTrue(json.equals(json1)); + try { + JSONAssert.assertEquals(json, json1, false); + } catch (JSONException e) { + throw new IllegalArgumentException(e.getMessage()); + } } }