From b0f17d928e9d67ee799ba27ce4d0728efe9a8e32 Mon Sep 17 00:00:00 2001 From: chenfeng Date: Sun, 14 Apr 2024 19:20:04 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=A1=88=E4=BE=8B=EF=BC=8C=E6=A1=88=E4=BE=8B?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=AF=B9=E6=AF=94=E6=97=B6=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsondiff/test/MultAllArrayTest.java | 16 +- .../jsondiff/test/utils/FormatContent.java | 38 ++ .../src/main/resources/array/MultArrays.json | 512 +++++++++++------- .../main/resources/object/MultObjects.json | 16 +- 4 files changed, 373 insertions(+), 209 deletions(-) create mode 100644 json-diff-test/src/main/java/me/codeleep/jsondiff/test/utils/FormatContent.java diff --git a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java index c536d53..dfab1ee 100644 --- a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java +++ b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java @@ -1,10 +1,12 @@ package me.codeleep.jsondiff.test; import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONWriter; import me.codeleep.jsondiff.DefaultJsonDifference; import me.codeleep.jsondiff.common.model.JsonCompareResult; import me.codeleep.jsondiff.test.model.MetaData; import me.codeleep.jsondiff.test.dataFactory.ArrayDataFactory; +import me.codeleep.jsondiff.test.utils.FormatContent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -16,33 +18,30 @@ */ public class MultAllArrayTest { private static final Logger logger = LoggerFactory.getLogger(MultAllArrayTest.class); + private final DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); @Test(dataProvider = "right", dataProviderClass = ArrayDataFactory.class) public void noOptionRightTest(MetaData metaData) { - DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); logger.info(metaData.getCaseName()); logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()); JsonCompareResult jsonCompareResult = defaultJsonDifference .detectDiff(JSON.toJSONString(metaData.getExpect()) , JSON.toJSONString(metaData.getActual())); if (metaData.getRet() != null) - { Assert.assertEquals( JSON.toJSONString(jsonCompareResult),JSON.toJSONString(metaData.getRet()));} + { Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult),FormatContent.formatComparisonContent(metaData.getRet().toString()));} else - { Assert.assertEquals( JSON.toJSONString(jsonCompareResult),"{\"match\":true}");} + { Assert.assertEquals( FormatContent.formatComparisonContent(jsonCompareResult),FormatContent.formatComparisonContent("{\"match\":true}"));} } @Test(dataProvider = "err", dataProviderClass = ArrayDataFactory.class) public void noOptionErrTest(MetaData metaData) { - DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); logger.info(metaData.getCaseName()); logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()+"\n"+metaData.getOption()); JsonCompareResult jsonCompareResult = defaultJsonDifference .detectDiff(JSON.toJSONString(metaData.getExpect()) , JSON.toJSONString(metaData.getActual())); - Assert.assertEquals(JSON.toJSONString(jsonCompareResult),JSON.toJSONString(metaData.getRet())); - + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult),FormatContent.formatComparisonContent(metaData.getRet().toString())); } @Test(dataProvider = "optionRight", dataProviderClass = ArrayDataFactory.class) public void optionRight(MetaData metaData) { - DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); logger.info(metaData.getCaseName()); logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()+"\n"); JsonCompareResult jsonCompareResult = defaultJsonDifference @@ -58,12 +57,11 @@ public void optionRight(MetaData metaData) { @Test(dataProvider = "optionErr", dataProviderClass = ArrayDataFactory.class) public void optionErr(MetaData metaData) { - DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); logger.info(metaData.getCaseName()); logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()+"\n"); JsonCompareResult jsonCompareResult = defaultJsonDifference .option(metaData.getOption()) .detectDiff(JSON.toJSONString(metaData.getExpect()) , JSON.toJSONString(metaData.getActual())); - Assert.assertEquals(JSON.toJSONString(jsonCompareResult),JSON.toJSONString(metaData.getRet())); + Assert.assertEquals(JSON.toJSONString(jsonCompareResult, JSONWriter.Feature.PrettyFormat),JSON.toJSONString(metaData.getRet(), JSONWriter.Feature.PrettyFormat)); } } diff --git a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/utils/FormatContent.java b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/utils/FormatContent.java new file mode 100644 index 0000000..94ea94c --- /dev/null +++ b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/utils/FormatContent.java @@ -0,0 +1,38 @@ +package me.codeleep.jsondiff.test.utils; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.alibaba.fastjson2.JSONWriter; +import me.codeleep.jsondiff.common.model.JsonCompareResult; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author: chenfeng + * @createTime: 2024/4/14 10:55 + * @description: 格式化内容 + */ +public class FormatContent { + private static final String REGEX = "[a-zA-Z]+(\\.[a-zA-Z]+)+"; + private static final Pattern pattern = Pattern.compile(REGEX); + + /** + * 将返回的JsonCompareResult类转化为格式化的JSON字符串 并将其中的关于类型的部分去除 例如java.math.BigDecimal + * @param jsonCompareContent JsonCompareResult 执行对比后返回的内容 + * @return String 格式化后的JSON字符串 + */ + public static String formatComparisonContent(JsonCompareResult jsonCompareContent) { + return formatComparisonContent(JSON.toJSONString(jsonCompareContent)); + } + /** + * 将String字符串转化为格式化的JSON字符串 并将其中的关于类型的部分去除 例如java.math.BigDecimal + * @param content String 需要格式化的字符串内容 + * @return String 格式化后的JSON字符串 + */ + public static String formatComparisonContent(String content) { + Matcher matcher = pattern.matcher(content); + JSONObject jsonObject = JSON.parseObject(matcher.replaceAll("")); + return JSON.toJSONString(jsonObject, JSONWriter.Feature.PrettyFormat); + } +} diff --git a/json-diff-test/src/main/resources/array/MultArrays.json b/json-diff-test/src/main/resources/array/MultArrays.json index 8167b74..511cfd8 100644 --- a/json-diff-test/src/main/resources/array/MultArrays.json +++ b/json-diff-test/src/main/resources/array/MultArrays.json @@ -2169,13 +2169,13 @@ "ret": { "defectsList": [ { - "actual": 4123, - "expect": 12345545, + "actual": "4123", + "expect": "12345545", "illustrate": "The expect('12345545') data is inconsistent with the actual('4123') data", "travelPath": { - "abstractTravelPath": "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", - "actualTravelPath": "root[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", - "expectTravelPath": "root[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + "abstractTravelPath": "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", + "actualTravelPath": "$[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", + "expectTravelPath": "$[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" } } ], @@ -2289,9 +2289,9 @@ "expect": "高温 17.0℃", "illustrate": "The expect('高温 17.0℃') data is inconsistent with the actual('123') data", "travelPath": { - "abstractTravelPath": "root[].high", - "actualTravelPath": "root[0].high", - "expectTravelPath": "root[0].high" + "abstractTravelPath": "$[*].high", + "actualTravelPath": "$[0].high", + "expectTravelPath": "$[0].high" } }, { @@ -2299,9 +2299,9 @@ "expect": "21日星期四", "illustrate": "The expect('21日星期四') data is inconsistent with the actual('21星期四') data", "travelPath": { - "abstractTravelPath": "root[].date", - "actualTravelPath": "root[1].date", - "expectTravelPath": "root[1].date" + "abstractTravelPath": "$[*].date", + "actualTravelPath": "$[1].date", + "expectTravelPath": "$[1].date" } }, { @@ -2309,9 +2309,9 @@ "expect": "高温 17.0℃", "illustrate": "The expect('高温 17.0℃') data is inconsistent with the actual('124') data", "travelPath": { - "abstractTravelPath": "root[].high", - "actualTravelPath": "root[1].high", - "expectTravelPath": "root[1].high" + "abstractTravelPath": "$[*].high", + "actualTravelPath": "$[1].high", + "expectTravelPath": "$[1].high" } }, { @@ -2319,9 +2319,9 @@ "expect": "高温 17.0℃", "illustrate": "The expect('高温 17.0℃') data is inconsistent with the actual('125') data", "travelPath": { - "abstractTravelPath": "root[].high", - "actualTravelPath": "root[2].high", - "expectTravelPath": "root[2].high" + "abstractTravelPath": "$[*].high", + "actualTravelPath": "$[2].high", + "expectTravelPath": "$[2].high" } } ], @@ -2345,21 +2345,21 @@ "ret": { "defectsList": [ { - "expect": 1, + "expect": "1", "illustrate": "Only one set of keys exists expect('b'),actual('null')", "travelPath": { - "abstractTravelPath": "root[].b", - "actualTravelPath": "root[0].null", - "expectTravelPath": "root[0].b" + "abstractTravelPath": "$[*].b", + "actualTravelPath": "$[0].null", + "expectTravelPath": "$[0].b" } }, { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('a')", "travelPath": { - "abstractTravelPath": "root[].a", - "actualTravelPath": "root[0].a", - "expectTravelPath": "root[0].null" + "abstractTravelPath": "$[*].a", + "actualTravelPath": "$[0].a", + "expectTravelPath": "$[0].null" } } ], @@ -2377,13 +2377,13 @@ "ret": { "defectsList": [ { - "actual": {}, - "expect": [], - "illustrate": "The expect type ('com.alibaba.fastjson2.JSONArray') is inconsistent with the actual type ('com.alibaba.fastjson2.JSONObject')", + "actual": "{}", + "expect": "[]", + "illustrate": "The expect type ('me.codeleep.jsondiff.impl.jackson.JacksonArray') is inconsistent with the actual type ('me.codeleep.jsondiff.impl.jackson.JacksonObject')", "travelPath": { - "abstractTravelPath": "root[]", - "actualTravelPath": "root[0]", - "expectTravelPath": "root[0]" + "abstractTravelPath": "$[*]", + "actualTravelPath": "$[0]", + "expectTravelPath": "$[0]" } } ], @@ -2405,7 +2405,7 @@ "expect": 1.1234, "illustrate": "The expect type ('java.math.BigDecimal') is inconsistent with the actual type ('java.lang.String')", "travelPath": { - "abstractTravelPath": "root[]", + "abstractTravelPath": "$[*]", "actualTravelPath": "root[0]", "expectTravelPath": "root[0]" } @@ -2652,7 +2652,7 @@ "option": { "ignoreOrder": false, "ignorePath": [ - "root[].a" + "$[*].a" ] } }, @@ -2706,7 +2706,7 @@ ], "option": { "ignorePath": [ - "root[][].a" + "$[*][].a" ] } }, @@ -3064,7 +3064,7 @@ ], "option": { "ignorePath": [ - "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a" + "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a" ] } }, @@ -3138,7 +3138,7 @@ ], "option": { "ignorePath": [ - "root[][].a.a" + "$[*][].a.a" ] } }, @@ -3672,7 +3672,7 @@ ], "option": { "ignorePath": [ - "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a" + "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a" ] } }, @@ -4286,7 +4286,7 @@ ], "option": { "ignorePath": [ - "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" ] } }, @@ -4339,7 +4339,7 @@ ], "option": { "ignorePath": [ - "root[][]" + "$[*][]" ] } }, @@ -4371,7 +4371,7 @@ ], "option": { "ignorePath": [ - "root[][].a[].b" + "$[*][].a[].b" ] } }, @@ -5732,7 +5732,7 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root[].c" + "$[*].c" ] } }, @@ -5850,7 +5850,7 @@ ], "option": { "ignorePath": [ - "root[].n" + "$[*].n" ], "ignoreKey": [ "f" @@ -5893,7 +5893,7 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ] } }, @@ -5941,7 +5941,7 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ] }, "ret": { @@ -6026,7 +6026,7 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ], "ignoreKey": [ "n" @@ -6068,7 +6068,7 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root[].c" + "$[*].c" ], "ignoreKey": [ "k" @@ -6109,7 +6109,7 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root[].c" + "$[*].c" ] } }, @@ -6268,7 +6268,7 @@ ], "option": { "ignorePath": [ - "root[].n" + "$[*].n" ], "ignoreKey": [ "f" @@ -6311,7 +6311,7 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ] } }, @@ -6352,7 +6352,7 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ] } }, @@ -6434,7 +6434,7 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ], "ignoreKey": [ "n" @@ -6476,7 +6476,7 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root[].c" + "$[*].c" ], "ignoreKey": [ "k" @@ -6486,7 +6486,7 @@ ], "optionErr": [ { - "caseName": "配置忽略数组顺序 不等长数组,数组顺序不符合,object对不匹配 TODO", + "caseName": "配置忽略数组顺序 不等长数组,数组顺序不符合,object对不匹配", "actual": [ { "a": false, @@ -6532,10 +6532,24 @@ "option": { "ignoreOrder": true }, - "ret": {"defectsList":[{"actual":"a","expect":"b","illustrate":"The expect('b') data is inconsistent with the actual('a') data","travelPath":{"abstractTravelPath":"root[][]","actualTravelPath":"root[2][1]","expectTravelPath":"root[3][1]"}}],"match":false} + "ret": { + "defectsList": [ + { + "actual": "a", + "expect": "b", + "illustrate": "The expect('b') data is inconsistent with the actual('a') data", + "travelPath": { + "abstractTravelPath": "$[*][*]", + "actualTravelPath": "$[2][1]", + "expectTravelPath": "$[3][1]" + } + } + ], + "match": false + } }, { - "caseName": "忽略单层数组内制定对象的key 存在规则外的其他key不匹配", + "caseName": "忽略单层数组内指定的对象的key 存在规则外的其他key不匹配", "actual": [ { "a": [ @@ -6718,33 +6732,33 @@ ] ], "ret": { - "defectsList": [ + "defectsList":[ { - "actual": 1, - "illustrate": "Only one set of keys exists expect('null'),actual('b')", - "travelPath": { - "abstractTravelPath": "root[].b", - "actualTravelPath": "root[0].b", - "expectTravelPath": "root[0].null" + "actual":"1", + "illustrate":"Only one set of keys exists expect('null'),actual('b')", + "travelPath":{ + "abstractTravelPath":"$[*].b", + "actualTravelPath":"$[0].b", + "expectTravelPath":"$[0].null" } }, { - "actual": "08020094", - "expect": "08020093", - "illustrate": "The expect('08020093') data is inconsistent with the actual('08020094') data", - "travelPath": { - "abstractTravelPath": "root[][][]", - "actualTravelPath": "root[1][0][0]", - "expectTravelPath": "root[1][0][0]" + "actual":"08020094", + "expect":"08020093", + "illustrate":"The expect('08020093') data is inconsistent with the actual('08020094') data", + "travelPath":{ + "abstractTravelPath":"$[*][*][*]", + "actualTravelPath":"$[1][0][0]", + "expectTravelPath":"$[1][0][0]" } } ], - "match": false + "match":false }, "option": { "ignoreOrder": false, "ignorePath": [ - "root[].a" + "$[*].a" ] } }, @@ -6804,19 +6818,19 @@ ], "option": { "ignorePath": [ - "root[][].a" + "$[*][*].a" ] }, "ret": { "defectsList": [ { - "actual": 2, - "expect": 3, + "actual": "2", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('2') data", "travelPath": { - "abstractTravelPath": "root[][].b", - "actualTravelPath": "root[0][1].b", - "expectTravelPath": "root[0][1].b" + "abstractTravelPath": "$[*][*].b", + "actualTravelPath": "$[0][1].b", + "expectTravelPath": "$[0][1].b" } } ], @@ -7185,27 +7199,27 @@ ], "option": { "ignorePath": [ - "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a" + "$.[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a" ] }, "ret": { "defectsList": [ { - "actual": 3, - "expect": 2, + "actual": "3", + "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('3') data", "travelPath": { - "abstractTravelPath": "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].b", + "abstractTravelPath": "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].b", "actualTravelPath": "root[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b", "expectTravelPath": "root[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b" } }, { - "actual": 1, - "expect": 3, + "actual": "1", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('1') data", "travelPath": { - "abstractTravelPath": "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].C", + "abstractTravelPath": "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].C", "actualTravelPath": "root[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C", "expectTravelPath": "root[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C" } @@ -7288,29 +7302,29 @@ ], "option": { "ignorePath": [ - "root[][].a.a" + "$[*][*].a.a" ] }, "ret": { "defectsList": [ { - "actual": 2, - "expect": 3, + "actual": "2", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('2') data", "travelPath": { - "abstractTravelPath": "root[][].a.b", - "actualTravelPath": "root[3][0].a.b", - "expectTravelPath": "root[3][0].a.b" + "abstractTravelPath": "$[*][*].a.b", + "actualTravelPath": "$[3][0].a.b", + "expectTravelPath": "$[3][0].a.b" } }, { - "actual": 3, - "expect": 2, + "actual": "3", + "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('3') data", "travelPath": { - "abstractTravelPath": "root[][].c", - "actualTravelPath": "root[3][0].c", - "expectTravelPath": "root[3][0].c" + "abstractTravelPath": "$[*][*].c", + "actualTravelPath": "$[3][0].c", + "expectTravelPath": "$[3][0].c" } } ], @@ -7861,19 +7875,19 @@ ], "option": { "ignorePath": [ - "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a" - ] + "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a" + ] }, "ret": { "defectsList": [ { - "actual": 1, - "expect": 3, + "actual": "1", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('1') data", "travelPath": { - "abstractTravelPath": "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].b[].c", - "actualTravelPath": "root[3][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b[0].c", - "expectTravelPath": "root[3][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b[0].c" + "abstractTravelPath": "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].b[*].c", + "actualTravelPath": "$[3][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b[0].c", + "expectTravelPath": "$[3][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b[0].c" } } ], @@ -8492,27 +8506,27 @@ ], "option": { "ignorePath": [ - "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" ] }, "ret": { "defectsList": [ { - "actual": 22, + "actual": "22", "illustrate": "Only one set of keys exists expect('null'),actual('b')", "travelPath": { - "abstractTravelPath": "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", - "actualTravelPath": "root[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", - "expectTravelPath": "root[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.null" + "abstractTravelPath": "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", + "actualTravelPath": "$[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", + "expectTravelPath": "$[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.null" } }, { - "actual": 3, + "actual": "3", "illustrate": "Only one set of keys exists expect('null'),actual('b')", "travelPath": { - "abstractTravelPath": "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", - "actualTravelPath": "root[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", - "expectTravelPath": "root[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.null" + "abstractTravelPath": "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", + "actualTravelPath": "$[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", + "expectTravelPath": "$[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.null" } } ], @@ -8546,7 +8560,7 @@ "expect": [], "option": { "ignorePath": [ - "root" + "$" ] }, "ret": { @@ -8567,12 +8581,12 @@ ], "expect": [ { - "a": 1 + "a": 12 } ], "option": { "ignorePath": [ - "root[][]" + "$[*][0]" ] } }, @@ -8609,27 +8623,27 @@ ], "option": { "ignorePath": [ - "root[][].a[].b" + "$[*][*].a[*].b" ] }, "ret": { "defectsList": [ { - "actual": 2, + "actual": "2", "illustrate": "Only one set of keys exists expect('null'),actual('v')", "travelPath": { - "abstractTravelPath": "root[][].a[].v", - "actualTravelPath": "root[0][0].a[0].v", - "expectTravelPath": "root[0][0].a[0].null" + "abstractTravelPath": "$[*][*].a[*].v", + "actualTravelPath": "$[0][0].a[0].v", + "expectTravelPath": "$[0][0].a[0].null" } }, { - "actual": 12, + "actual": "12", "illustrate": "Only one set of keys exists expect('null'),actual('a')", "travelPath": { - "abstractTravelPath": "root[][].a[].a", - "actualTravelPath": "root[0][0].a[1].a", - "expectTravelPath": "root[0][0].a[1].null" + "abstractTravelPath": "$[*][*].a[*].a", + "actualTravelPath": "$[0][0].a[1].a", + "expectTravelPath": "$[0][0].a[1].null" } } ], @@ -9783,10 +9797,12 @@ "b": "a" } }, - "ret": {"match":true} + "ret": { + "match": true + } }, { - "caseName": "数组对象中key不一致对应 TODO", + "caseName": "数组对象中key不一致对应", "actual": [ { "a": 1 @@ -9808,16 +9824,16 @@ "b": "a" } }, - "ret" : { + "ret": { "defectsList": [ { - "actual": 2, - "expect": 3, + "actual": "2", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('2') data", "travelPath": { - "abstractTravelPath": "root[].a", - "actualTravelPath": "root[1].b", - "expectTravelPath": "root[1].a" + "abstractTravelPath": "$[*].a", + "actualTravelPath": "$[1].b", + "expectTravelPath": "$[1].a" } } ], @@ -9845,7 +9861,21 @@ "c": "d" } }, - "ret" :{"defectsList":[{"actual":3,"expect":4,"illustrate":"The expect('4') data is inconsistent with the actual('3') data","travelPath":{"abstractTravelPath":"root[].d","actualTravelPath":"root[0].c","expectTravelPath":"root[0].d"}}],"match":false} + "ret": { + "defectsList": [ + { + "actual": "3", + "expect": "4", + "illustrate": "The expect('4') data is inconsistent with the actual('3') data", + "travelPath": { + "abstractTravelPath": "$[*].d", + "actualTravelPath": "$[0].c", + "expectTravelPath": "$[0].d" + } + } + ], + "match": false + } }, { "caseName": "配置mapping 将a指定为b 指定后值不一致", @@ -9867,13 +9897,13 @@ "ret": { "defectsList": [ { - "actual": 1, - "expect": 2, + "actual": "1", + "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('1') data", "travelPath": { - "abstractTravelPath": "root[].b", - "actualTravelPath": "root[0].a", - "expectTravelPath": "root[0].b" + "abstractTravelPath": "$[*].b", + "actualTravelPath": "$[0].a", + "expectTravelPath": "$[0].b" } } ], @@ -9903,7 +9933,29 @@ "a": "b" } }, - "ret": {"defectsList":[{"expect":3,"illustrate":"Only one set of keys exists expect('c'),actual('null')","travelPath":{"abstractTravelPath":"root[].c","actualTravelPath":"root[1].null","expectTravelPath":"root[1].c"}},{"actual":3,"illustrate":"Only one set of keys exists expect('null'),actual('a')","travelPath":{"abstractTravelPath":"root[].a","actualTravelPath":"root[1].a","expectTravelPath":"root[1].null"}}],"match":false} + "ret": { + "defectsList": [ + { + "expect": "3", + "illustrate": "Only one set of keys exists expect('c'),actual('null')", + "travelPath": { + "abstractTravelPath": "$[*].c", + "actualTravelPath": "$[1].null", + "expectTravelPath": "$[1].c" + } + }, + { + "actual": "3", + "illustrate": "Only one set of keys exists expect('null'),actual('a')", + "travelPath": { + "abstractTravelPath": "$[*].a", + "actualTravelPath": "$[1].a", + "expectTravelPath": "$[1].null" + } + } + ], + "match": false + } }, { "caseName": "忽略单个key key不匹配 ", @@ -9949,12 +10001,12 @@ "ret": { "defectsList": [ { - "expect": 3, + "expect": "3", "illustrate": "Only one set of keys exists expect('b'),actual('null')", "travelPath": { - "abstractTravelPath": "root[].b", - "actualTravelPath": "root[4].null", - "expectTravelPath": "root[4].b" + "abstractTravelPath": "$[*].b", + "actualTravelPath": "$[4].null", + "expectTravelPath": "$[4].b" } } ], @@ -10006,13 +10058,13 @@ "ret": { "defectsList": [ { - "actual": 1, - "expect": 2, + "actual": "1", + "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('1') data", "travelPath": { - "abstractTravelPath": "root[].c", - "actualTravelPath": "root[4].c", - "expectTravelPath": "root[4].c" + "abstractTravelPath": "$[*].c", + "actualTravelPath": "$[4].c", + "expectTravelPath": "$[4].c" } } ], @@ -10061,7 +10113,29 @@ "b": "c" } }, - "ret": {"defectsList":[{"expect":1,"illustrate":"Only one set of keys exists expect('d'),actual('null')","travelPath":{"abstractTravelPath":"root[].d","actualTravelPath":"root[4].null","expectTravelPath":"root[4].d"}},{"actual":1,"illustrate":"Only one set of keys exists expect('null'),actual('b')","travelPath":{"abstractTravelPath":"root[].b","actualTravelPath":"root[4].b","expectTravelPath":"root[4].null"}}],"match":false} + "ret": { + "defectsList": [ + { + "expect": "1", + "illustrate": "Only one set of keys exists expect('d'),actual('null')", + "travelPath": { + "abstractTravelPath": "$[*].d", + "actualTravelPath": "$[4].null", + "expectTravelPath": "$[4].d" + } + }, + { + "actual": "1", + "illustrate": "Only one set of keys exists expect('null'),actual('b')", + "travelPath": { + "abstractTravelPath": "$[*].b", + "actualTravelPath": "$[4].b", + "expectTravelPath": "$[4].null" + } + } + ], + "match": false + } }, { "caseName": "配置ignoreOrder和ignorePath 增加不匹配字段", @@ -10099,18 +10173,18 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root[].c" + "$[*].c" ] }, "ret": { "defectsList": [ { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('d')", "travelPath": { - "abstractTravelPath": "root[].d", - "actualTravelPath": "root[0].d", - "expectTravelPath": "root[0].null" + "abstractTravelPath": "$[*].d", + "actualTravelPath": "$[0].d", + "expectTravelPath": "$[0].null" } } ], @@ -10161,12 +10235,12 @@ "ret": { "defectsList": [ { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('d')", "travelPath": { - "abstractTravelPath": "root[].d", - "actualTravelPath": "root[2].d", - "expectTravelPath": "root[1].null" + "abstractTravelPath": "$[*].d", + "actualTravelPath": "$[2].d", + "expectTravelPath": "$[1].null" } } ], @@ -10213,7 +10287,29 @@ "f" ] }, - "ret": {"defectsList":[{"expect":1,"illustrate":"Only one set of keys exists expect('c'),actual('null')","travelPath":{"abstractTravelPath":"root[].c","actualTravelPath":"root[3].null","expectTravelPath":"root[3].c"}},{"actual":1,"illustrate":"Only one set of keys exists expect('null'),actual('d')","travelPath":{"abstractTravelPath":"root[].d","actualTravelPath":"root[3].d","expectTravelPath":"root[3].null"}}],"match":false} + "ret": { + "defectsList": [ + { + "expect": "1", + "illustrate": "Only one set of keys exists expect('c'),actual('null')", + "travelPath": { + "abstractTravelPath": "$[*].c", + "actualTravelPath": "$[3].null", + "expectTravelPath": "$[3].c" + } + }, + { + "actual": "1", + "illustrate": "Only one set of keys exists expect('null'),actual('d')", + "travelPath": { + "abstractTravelPath": "$[*].d", + "actualTravelPath": "$[3].d", + "expectTravelPath": "$[3].null" + } + } + ], + "match": false + } }, { "caseName": "配置ignorePath和ignoreKey 增加不同位置忽略字段 增加不匹配字段", @@ -10252,7 +10348,7 @@ ], "option": { "ignorePath": [ - "root[].n" + "$[*].n" ], "ignoreKey": [ "f" @@ -10264,9 +10360,9 @@ "actual": "f", "illustrate": "Only one set of keys exists expect('null'),actual('F')", "travelPath": { - "abstractTravelPath": "root[].F", - "actualTravelPath": "root[3].F", - "expectTravelPath": "root[3].null" + "abstractTravelPath": "$[*].F", + "actualTravelPath": "$[3].F", + "expectTravelPath": "$[3].null" } } ], @@ -10302,7 +10398,7 @@ "c": 2 }, { - "c": 1 + "c": 2 } ], "option": { @@ -10310,7 +10406,7 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ] } }, @@ -10359,10 +10455,23 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ] }, - "ret": {"defectsList":[{"expect":1,"illustrate":"Only one set of keys exists expect('e'),actual('null')","travelPath":{"abstractTravelPath":"root[].e","actualTravelPath":"root[0].null","expectTravelPath":"root[2].e"}}],"match":false} + "ret": { + "defectsList": [ + { + "expect": "1", + "illustrate": "Only one set of keys exists expect('e'),actual('null')", + "travelPath": { + "abstractTravelPath": "$[*].e", + "actualTravelPath": "$[0].null", + "expectTravelPath": "$[2].e" + } + } + ], + "match": false + } }, { "caseName": "配置mapping和ignoreOrder和ignoreKey 在预期中存在替换的字段 TODO", @@ -10408,28 +10517,37 @@ ] }, "ret": { - "defectsList":[ + "defectsList": [ { - "actual":2, - "illustrate":"The expect type ('null') is inconsistent with the actual type ('java.lang.Integer')", - "travelPath":{ - "abstractTravelPath":"root[].b", - "actualTravelPath":"root[2].null", - "expectTravelPath":"root[1].b" + "actual": "2", + "illustrate": "The expect type ('null') is inconsistent with the actual type ('java.lang.Integer')", + "travelPath": { + "abstractTravelPath": "$[*].c", + "actualTravelPath": "$[2].c", + "expectTravelPath": "$[1].null" } }, { - "actual":1, - "expect":2, - "illustrate":"The expect('2') data is inconsistent with the actual('1') data", - "travelPath":{ - "abstractTravelPath":"root[].a", - "actualTravelPath":"root[2].a", - "expectTravelPath":"root[1].a" + "actual": "1", + "illustrate": "The expect type ('null') is inconsistent with the actual type ('java.lang.Integer')", + "travelPath": { + "abstractTravelPath": "$[*].b", + "actualTravelPath": "$[2].null", + "expectTravelPath": "$[1].b" + } + }, + { + "actual": "1", + "expect": "2", + "illustrate": "The expect('2') data is inconsistent with the actual('1') data", + "travelPath": { + "abstractTravelPath": "$[*].a", + "actualTravelPath": "root[2].a", + "expectTravelPath": "root[1].a" } } ], - "match":false + "match": false } }, { @@ -10473,13 +10591,35 @@ "b": "c" }, "ignorePath": [ - "root[].f" + "$[*].f" ], "ignoreKey": [ "n" ] }, - "ret": {"defectsList":[{"actual":1,"illustrate":"Only one set of keys exists expect('null'),actual('m')","travelPath":{"abstractTravelPath":"root[].m","actualTravelPath":"root[0].m","expectTravelPath":"root[0].null"}},{"actual":1,"illustrate":"Only one set of keys exists expect('null'),actual('m')","travelPath":{"abstractTravelPath":"root[].m","actualTravelPath":"root[2].m","expectTravelPath":"root[2].null"}}],"match":false} + "ret": { + "defectsList": [ + { + "actual": "1", + "illustrate": "Only one set of keys exists expect('null'),actual('m')", + "travelPath": { + "abstractTravelPath": "$[*].m", + "actualTravelPath": "$[0].m", + "expectTravelPath": "$[0].null" + } + }, + { + "actual": "1", + "illustrate": "Only one set of keys exists expect('null'),actual('m')", + "travelPath": { + "abstractTravelPath": "$[*].m", + "actualTravelPath": "$[2].m", + "expectTravelPath": "$[2].null" + } + } + ], + "match": false + } }, { "caseName": "配置ignoreOrder和ignorePath和ignoreKey 增加不同位置的内容 TODO", @@ -10518,13 +10658,15 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root[].c" + "$[*].c" ], "ignoreKey": [ "k" ] }, - "ret": {"match":true} + "ret": { + "match": true + } } ] } \ No newline at end of file diff --git a/json-diff-test/src/main/resources/object/MultObjects.json b/json-diff-test/src/main/resources/object/MultObjects.json index 7ca7af0..b2eebb5 100644 --- a/json-diff-test/src/main/resources/object/MultObjects.json +++ b/json-diff-test/src/main/resources/object/MultObjects.json @@ -2781,21 +2781,7 @@ ] ] }, - "ret": { - "defectsList": [ - { - "actual": 4123, - "expect": 12345545, - "illustrate": "The expect('12345545') data is inconsistent with the actual('4123') data", - "travelPath": { - "abstractTravelPath": "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", - "actualTravelPath": "root.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", - "expectTravelPath": "root.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" - } - } - ], - "match": false - } + "ret": {"defectsList":[{"actual":"4123","expect":"12345545","illustrate":"The expect('12345545') data is inconsistent with the actual('4123') data","travelPath":{"abstractTravelPath":"$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a","actualTravelPath":"$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a","expectTravelPath":"$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a"}}],"match":false} }, { "caseName": "特殊内容对比", From 4a02032a7fa180d06dba4a03ccfb635975964f36 Mon Sep 17 00:00:00 2001 From: chenfeng Date: Sun, 14 Apr 2024 20:12:58 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96json=E5=AD=97=E7=AC=A6=E4=B8=B2=EF=BC=8C=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsondiff/test/MultAllArrayTest.java | 41 ++++++++++--------- .../jsondiff/test/MultAllObjectTest.java | 28 ++++++------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java index dfab1ee..cfd2096 100644 --- a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java +++ b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java @@ -1,7 +1,6 @@ package me.codeleep.jsondiff.test; import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONWriter; import me.codeleep.jsondiff.DefaultJsonDifference; import me.codeleep.jsondiff.common.model.JsonCompareResult; import me.codeleep.jsondiff.test.model.MetaData; @@ -11,57 +10,59 @@ import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.Test; + /** * @author: chenfeng * @createTime: 2023/3/2 21:55 * @description: 数组类型的测试类 */ public class MultAllArrayTest { - private static final Logger logger = LoggerFactory.getLogger(MultAllArrayTest.class); + private static final Logger logger = LoggerFactory.getLogger(MultAllArrayTest.class); private final DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); + @Test(dataProvider = "right", dataProviderClass = ArrayDataFactory.class) public void noOptionRightTest(MetaData metaData) { logger.info(metaData.getCaseName()); - logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()); + logger.debug("\n" + metaData.getExpect().toString() + "\n" + metaData.getActual().toString()); JsonCompareResult jsonCompareResult = defaultJsonDifference - .detectDiff(JSON.toJSONString(metaData.getExpect()) , JSON.toJSONString(metaData.getActual())); - if (metaData.getRet() != null) - { Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult),FormatContent.formatComparisonContent(metaData.getRet().toString()));} - else - { Assert.assertEquals( FormatContent.formatComparisonContent(jsonCompareResult),FormatContent.formatComparisonContent("{\"match\":true}"));} + .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); + if (metaData.getRet() != null) { + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); + } else { + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent("{\"match\":true}")); + } } @Test(dataProvider = "err", dataProviderClass = ArrayDataFactory.class) public void noOptionErrTest(MetaData metaData) { logger.info(metaData.getCaseName()); - logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()+"\n"+metaData.getOption()); + logger.debug("\n" + metaData.getExpect().toString() + "\n" + metaData.getActual().toString() + "\n" + metaData.getOption()); JsonCompareResult jsonCompareResult = defaultJsonDifference - .detectDiff(JSON.toJSONString(metaData.getExpect()) , JSON.toJSONString(metaData.getActual())); - Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult),FormatContent.formatComparisonContent(metaData.getRet().toString())); + .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); } @Test(dataProvider = "optionRight", dataProviderClass = ArrayDataFactory.class) public void optionRight(MetaData metaData) { logger.info(metaData.getCaseName()); - logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()+"\n"); + logger.debug("\n" + metaData.getExpect().toString() + "\n" + metaData.getActual().toString() + "\n"); JsonCompareResult jsonCompareResult = defaultJsonDifference .option(metaData.getOption()) - .detectDiff(JSON.toJSONString(metaData.getExpect()) , JSON.toJSONString(metaData.getActual())); + .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); if (metaData.getRet() != null) { - Assert.assertEquals(JSON.toJSONString(jsonCompareResult), JSON.toJSONString(metaData.getRet())); - } - else { - Assert.assertEquals(JSON.toJSONString(jsonCompareResult), "{\"match\":true}"); + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); + } else { + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent("{\"match\":true}")); } } @Test(dataProvider = "optionErr", dataProviderClass = ArrayDataFactory.class) public void optionErr(MetaData metaData) { logger.info(metaData.getCaseName()); - logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()+"\n"); + logger.debug("\n" + metaData.getExpect().toString() + "\n" + metaData.getActual().toString() + "\n"); JsonCompareResult jsonCompareResult = defaultJsonDifference .option(metaData.getOption()) - .detectDiff(JSON.toJSONString(metaData.getExpect()) , JSON.toJSONString(metaData.getActual())); - Assert.assertEquals(JSON.toJSONString(jsonCompareResult, JSONWriter.Feature.PrettyFormat),JSON.toJSONString(metaData.getRet(), JSONWriter.Feature.PrettyFormat)); + .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); } } diff --git a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllObjectTest.java b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllObjectTest.java index 565aa59..9329dac 100644 --- a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllObjectTest.java +++ b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllObjectTest.java @@ -5,6 +5,7 @@ import me.codeleep.jsondiff.DefaultJsonDifference; import me.codeleep.jsondiff.test.dataFactory.ObjectDataFactory; import me.codeleep.jsondiff.test.model.MetaData; +import me.codeleep.jsondiff.test.utils.FormatContent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -22,15 +23,13 @@ public class MultAllObjectTest { public void noOptionRightTest(MetaData metaData) { DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); logger.info(metaData.getCaseName()); - logger.debug(metaData.getExpect().toString()+"\n"+metaData.getActual().toString()); + logger.debug(metaData.getExpect().toString() + "\n" + metaData.getActual().toString()); JsonCompareResult jsonCompareResult = defaultJsonDifference .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); if (metaData.getRet() != null) { - Assert.assertEquals(JSON.toJSONString(jsonCompareResult), JSON.toJSONString(metaData.getRet())); - } - - else { - Assert.assertEquals(JSON.toJSONString(jsonCompareResult), "{\"match\":true}"); + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); + } else { + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent("{\"match\":true}")); } } @@ -38,25 +37,24 @@ public void noOptionRightTest(MetaData metaData) { public void noOptionErrTest(MetaData metaData) { DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); logger.info(metaData.getCaseName()); - logger.debug(metaData.getExpect().toString()+"\n"+metaData.getActual().toString()); + logger.debug(metaData.getExpect().toString() + "\n" + metaData.getActual().toString()); JsonCompareResult jsonCompareResult = defaultJsonDifference .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); - Assert.assertEquals(JSON.toJSONString(jsonCompareResult),JSON.toJSONString(metaData.getRet())); + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); } @Test(dataProvider = "optionRight", dataProviderClass = ObjectDataFactory.class) public void optionRight(MetaData metaData) { DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); logger.info(metaData.getCaseName()); - logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()+"\n"); + logger.debug("\n" + metaData.getExpect().toString() + "\n" + metaData.getActual().toString() + "\n"); JsonCompareResult jsonCompareResult = defaultJsonDifference .option(metaData.getOption()) .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); if (metaData.getRet() != null) { - Assert.assertEquals(JSON.toJSONString(jsonCompareResult), JSON.toJSONString(metaData.getRet())); - } - else { - Assert.assertEquals(JSON.toJSONString(jsonCompareResult), "{\"match\":true}"); + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); + } else { + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent("{\"match\":true}")); } } @@ -64,10 +62,10 @@ public void optionRight(MetaData metaData) { public void optionErr(MetaData metaData) { DefaultJsonDifference defaultJsonDifference = new DefaultJsonDifference(); logger.info(metaData.getCaseName()); - logger.debug("\n"+metaData.getExpect().toString()+"\n"+metaData.getActual().toString()+"\n"); + logger.debug("\n" + metaData.getExpect().toString() + "\n" + metaData.getActual().toString() + "\n"); JsonCompareResult jsonCompareResult = defaultJsonDifference .option(metaData.getOption()) .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); - Assert.assertEquals( JSON.toJSONString(jsonCompareResult),JSON.toJSONString(metaData.getRet())); + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); } } From 78c5c7e83d21940fa4cf84a4ae36984d937c5b64 Mon Sep 17 00:00:00 2001 From: local-li <2939634393@qq.com> Date: Sun, 14 Apr 2024 20:59:35 +0800 Subject: [PATCH 03/11] =?UTF-8?q?fix-to(return):=20=E4=BF=AE=E5=A4=8Dclass?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handle/other/ComplexOtherJsonNeat.java | 9 +++++ .../primitive/ComplexPrimitiveJsonNeat.java | 9 +++++ .../jsondiff/core/utils/ClassUtil.java | 39 ------------------- 3 files changed, 18 insertions(+), 39 deletions(-) diff --git a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/other/ComplexOtherJsonNeat.java b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/other/ComplexOtherJsonNeat.java index d7621d0..98b0e3a 100644 --- a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/other/ComplexOtherJsonNeat.java +++ b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/other/ComplexOtherJsonNeat.java @@ -35,6 +35,15 @@ protected JsonCompareResult diff1() { result.addDefects(defects); return result; } + if (!ClassUtil.isSameClass(expect.getOther(), actual.getOther())) { + Defects defects = new Defects() + .setActual(actual) + .setExpect(expect) + .setTravelPath(travelPath) + .setIllustrateTemplate(DATA_TYPE_INCONSISTENT, ClassUtil.getClassName(expect.getOther()), ClassUtil.getClassName(actual.getOther())); + result.addDefects(defects); + return result; + } if (expect.isEquals(actual)) { return result; } diff --git a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/primitive/ComplexPrimitiveJsonNeat.java b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/primitive/ComplexPrimitiveJsonNeat.java index 8211421..5466393 100644 --- a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/primitive/ComplexPrimitiveJsonNeat.java +++ b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/primitive/ComplexPrimitiveJsonNeat.java @@ -35,6 +35,15 @@ protected JsonCompareResult diff1() { result.addDefects(defects); return result; } + if (!ClassUtil.isSameClass(expect.getTarget(), actual.getTarget())) { + Defects defects = new Defects() + .setActual(actual) + .setExpect(expect) + .setTravelPath(travelPath) + .setIllustrateTemplate(DATA_TYPE_INCONSISTENT, ClassUtil.getClassName(expect.getTarget()), ClassUtil.getClassName(actual.getTarget())); + result.addDefects(defects); + return result; + } if (expect.isEquals(actual)) { return result; } diff --git a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/utils/ClassUtil.java b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/utils/ClassUtil.java index 441ef96..cc4aac6 100644 --- a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/utils/ClassUtil.java +++ b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/utils/ClassUtil.java @@ -1,9 +1,5 @@ package me.codeleep.jsondiff.core.utils; -import me.codeleep.jsondiff.common.exception.JsonDiffException; -import me.codeleep.jsondiff.common.model.neat.JsonDiffArray; -import me.codeleep.jsondiff.common.model.neat.JsonDiffObject; - import static me.codeleep.jsondiff.common.model.Constant.NULL; /** @@ -26,33 +22,6 @@ public static boolean isSameClass(Object obj1, Object obj2) { return obj1 == null && obj2 == null; } - /** - * 判断当前对象是否为json数据格式中的基本类型 - * @param obj 判断的对象 - * @return 是否为基本类型 - */ - public static boolean isPrimitiveType(Object obj){ - if(obj == null){ - return true; - } - - if(obj instanceof JsonDiffArray || obj instanceof JsonDiffObject){ - return false; - } - - if (String.class.isAssignableFrom(obj.getClass())) { - return true; - } - if (obj instanceof Number) { - return true; - } - try { - return ((Class)obj.getClass().getField("TYPE").get(null)).isPrimitive(); - } catch (Exception e) { - return false; - } - } - /** * 获取className @@ -65,12 +34,4 @@ public static String getClassName(Object obj) { } return obj.getClass().getName(); } - - public static T getClassNameInstance(Class clazz) { - try { - return clazz.newInstance(); - } catch (Exception e) { - throw new JsonDiffException(String.format("无法实例化: %s", clazz), e); - } - } } From 6c797fdc8f6d5b26ea5db2d8ea029de6df2519a0 Mon Sep 17 00:00:00 2001 From: local-li <2939634393@qq.com> Date: Sun, 14 Apr 2024 21:15:41 +0800 Subject: [PATCH 04/11] =?UTF-8?q?fix-to(test):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=B5=8B=E8=AF=95case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/array/MultArrays.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/json-diff-test/src/main/resources/array/MultArrays.json b/json-diff-test/src/main/resources/array/MultArrays.json index 511cfd8..f64dda4 100644 --- a/json-diff-test/src/main/resources/array/MultArrays.json +++ b/json-diff-test/src/main/resources/array/MultArrays.json @@ -2706,7 +2706,7 @@ ], "option": { "ignorePath": [ - "$[*][].a" + "$[*][*].a" ] } }, @@ -3064,7 +3064,7 @@ ], "option": { "ignorePath": [ - "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a" + "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a" ] } }, @@ -3138,7 +3138,7 @@ ], "option": { "ignorePath": [ - "$[*][].a.a" + "$[*][*].a.a" ] } }, @@ -3672,7 +3672,7 @@ ], "option": { "ignorePath": [ - "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a" + "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a" ] } }, @@ -4286,7 +4286,7 @@ ], "option": { "ignorePath": [ - "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" ] } }, @@ -4316,7 +4316,7 @@ "expect": [], "option": { "ignorePath": [ - "root" + "$" ] } }, @@ -4371,7 +4371,7 @@ ], "option": { "ignorePath": [ - "$[*][].a[].b" + "$[*][*].a[*].b" ] } }, From 0201bdcd681b5a396ce72ff9546da4f93ecbd1a4 Mon Sep 17 00:00:00 2001 From: local-li <2939634393@qq.com> Date: Sun, 14 Apr 2024 21:33:09 +0800 Subject: [PATCH 05/11] =?UTF-8?q?fix-to(object):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=BF=BD=E7=95=A5path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsondiff/core/handle/object/ComplexObjectJsonNeat.java | 4 +++- json-diff-test/src/main/resources/array/MultArrays.json | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java index 578f036..4472477 100644 --- a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java +++ b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java @@ -79,7 +79,9 @@ private void keySetConversion(Set expectKeys, Set actualKeys) { List mappingKeys = keyMap.stream().filter(mappingKey -> { String actualTravelPath = PathUtil.getObjectPath(travelPath.getActualTravelPath()) + mappingKey.getActualKey(); String expectTravelPath = PathUtil.getObjectPath(travelPath.getExpectTravelPath()) + mappingKey.getExpectKey(); - if (ignorePath.contains(actualTravelPath) || ignorePath.contains(expectTravelPath) ) { + String abstractActualTravelPath = PathUtil.getObjectPath(travelPath.getAbstractTravelPath()) + mappingKey.getActualKey(); + String abstractExpectTravelPath = PathUtil.getObjectPath(travelPath.getAbstractTravelPath()) + mappingKey.getExpectKey(); + if (ignorePath.contains(abstractActualTravelPath) || ignorePath.contains(abstractExpectTravelPath) || ignorePath.contains(actualTravelPath) || ignorePath.contains(expectTravelPath) ) { return false; } return true; diff --git a/json-diff-test/src/main/resources/array/MultArrays.json b/json-diff-test/src/main/resources/array/MultArrays.json index f64dda4..03239fd 100644 --- a/json-diff-test/src/main/resources/array/MultArrays.json +++ b/json-diff-test/src/main/resources/array/MultArrays.json @@ -4322,6 +4322,7 @@ }, { "caseName": "忽略根下的数组 后续改进【目前不支持】", + "skip": true, "actual": [ [ { @@ -4339,7 +4340,7 @@ ], "option": { "ignorePath": [ - "$[*][]" + "$[*][*]" ] } }, From 7be0b5ba450bd2e667cd34848c7c1c8bb9c53abf Mon Sep 17 00:00:00 2001 From: local-li <2939634393@qq.com> Date: Sun, 14 Apr 2024 22:02:15 +0800 Subject: [PATCH 06/11] =?UTF-8?q?fix-to(array):=20=E4=BF=AE=E5=A4=8Dcase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handle/object/ComplexObjectJsonNeat.java | 21 +++++-- .../jsondiff/test/MultAllArrayTest.java | 6 +- .../src/main/resources/array/MultArrays.json | 62 +++++++------------ 3 files changed, 42 insertions(+), 47 deletions(-) diff --git a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java index 4472477..fa57b07 100644 --- a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java +++ b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java @@ -77,12 +77,21 @@ private void keySetConversion(Set expectKeys, Set actualKeys) { // 移除忽略的Path HashSet ignorePath = RunTimeDataFactory.getOptionInstance().getIgnorePath(); List mappingKeys = keyMap.stream().filter(mappingKey -> { - String actualTravelPath = PathUtil.getObjectPath(travelPath.getActualTravelPath()) + mappingKey.getActualKey(); - String expectTravelPath = PathUtil.getObjectPath(travelPath.getExpectTravelPath()) + mappingKey.getExpectKey(); - String abstractActualTravelPath = PathUtil.getObjectPath(travelPath.getAbstractTravelPath()) + mappingKey.getActualKey(); - String abstractExpectTravelPath = PathUtil.getObjectPath(travelPath.getAbstractTravelPath()) + mappingKey.getExpectKey(); - if (ignorePath.contains(abstractActualTravelPath) || ignorePath.contains(abstractExpectTravelPath) || ignorePath.contains(actualTravelPath) || ignorePath.contains(expectTravelPath) ) { - return false; + String actualKey = mappingKey.getActualKey(); + if (actualKey != null) { + String actualTravelPath = PathUtil.getObjectPath(travelPath.getActualTravelPath()) + mappingKey.getActualKey(); + String abstractActualTravelPath = PathUtil.getObjectPath(travelPath.getAbstractTravelPath()) + mappingKey.getActualKey(); + if (ignorePath.contains(actualTravelPath) || ignorePath.contains(abstractActualTravelPath)) { + return false; + } + } + String expectKey = mappingKey.getExpectKey(); + if (expectKey != null) { + String expectTravelPath = PathUtil.getObjectPath(travelPath.getExpectTravelPath()) + mappingKey.getExpectKey(); + String abstractExpectTravelPath = PathUtil.getObjectPath(travelPath.getAbstractTravelPath()) + mappingKey.getExpectKey(); + if (ignorePath.contains(expectTravelPath) || ignorePath.contains(abstractExpectTravelPath)) { + return false; + } } return true; }).collect(Collectors.toList()); diff --git a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java index cfd2096..775c8ca 100644 --- a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java +++ b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java @@ -63,6 +63,10 @@ public void optionErr(MetaData metaData) { JsonCompareResult jsonCompareResult = defaultJsonDifference .option(metaData.getOption()) .detectDiff(JSON.toJSONString(metaData.getExpect()), JSON.toJSONString(metaData.getActual())); - Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); + if (metaData.getRet() != null) { + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent(metaData.getRet().toString())); + } else { + Assert.assertEquals(FormatContent.formatComparisonContent(jsonCompareResult), FormatContent.formatComparisonContent("{\"match\":true}")); + } } } diff --git a/json-diff-test/src/main/resources/array/MultArrays.json b/json-diff-test/src/main/resources/array/MultArrays.json index 03239fd..054e837 100644 --- a/json-diff-test/src/main/resources/array/MultArrays.json +++ b/json-diff-test/src/main/resources/array/MultArrays.json @@ -2402,12 +2402,12 @@ "defectsList": [ { "actual": "1.1234", - "expect": 1.1234, + "expect": "1.1234", "illustrate": "The expect type ('java.math.BigDecimal') is inconsistent with the actual type ('java.lang.String')", "travelPath": { "abstractTravelPath": "$[*]", - "actualTravelPath": "root[0]", - "expectTravelPath": "root[0]" + "actualTravelPath": "$[0]", + "expectTravelPath": "$[0]" } } ], @@ -7200,7 +7200,7 @@ ], "option": { "ignorePath": [ - "$.[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a" + "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a" ] }, "ret": { @@ -7209,20 +7209,20 @@ "actual": "3", "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('3') data", - "travelPath": { - "abstractTravelPath": "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].b", - "actualTravelPath": "root[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b", - "expectTravelPath": "root[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b" + "travelPath":{ + "abstractTravelPath":"$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].b", + "actualTravelPath":"$[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b", + "expectTravelPath":"$[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b" } }, { "actual": "1", "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('1') data", - "travelPath": { - "abstractTravelPath": "$[*][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].C", - "actualTravelPath": "root[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C", - "expectTravelPath": "root[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C" + "travelPath":{ + "abstractTravelPath":"$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].C", + "actualTravelPath":"$[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C", + "expectTravelPath":"$[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C" } } ], @@ -8587,7 +8587,7 @@ ], "option": { "ignorePath": [ - "$[*][0]" + "$[*][*]" ] } }, @@ -10518,37 +10518,19 @@ ] }, "ret": { - "defectsList": [ - { - "actual": "2", - "illustrate": "The expect type ('null') is inconsistent with the actual type ('java.lang.Integer')", - "travelPath": { - "abstractTravelPath": "$[*].c", - "actualTravelPath": "$[2].c", - "expectTravelPath": "$[1].null" - } - }, - { - "actual": "1", - "illustrate": "The expect type ('null') is inconsistent with the actual type ('java.lang.Integer')", - "travelPath": { - "abstractTravelPath": "$[*].b", - "actualTravelPath": "$[2].null", - "expectTravelPath": "$[1].b" - } - }, + "defectsList":[ { - "actual": "1", - "expect": "2", - "illustrate": "The expect('2') data is inconsistent with the actual('1') data", - "travelPath": { - "abstractTravelPath": "$[*].a", - "actualTravelPath": "root[2].a", - "expectTravelPath": "root[1].a" + "actual":"1", + "expect":"2", + "illustrate":"The expect('2') data is inconsistent with the actual('1') data", + "travelPath":{ + "abstractTravelPath":"$[*].a", + "actualTravelPath":"$[2].a", + "expectTravelPath":"$[1].a" } } ], - "match": false + "match":false } }, { From e1737ae764a3d059e38dee4cc47ba21bf10d83a4 Mon Sep 17 00:00:00 2001 From: local-li <2939634393@qq.com> Date: Sun, 14 Apr 2024 22:33:38 +0800 Subject: [PATCH 07/11] =?UTF-8?q?fix-to(array):=20=E4=BF=AE=E5=A4=8Dcase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsondiff/core/handle/array/ComplexArrayJsonNeat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/array/ComplexArrayJsonNeat.java b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/array/ComplexArrayJsonNeat.java index b359f5d..5f54926 100644 --- a/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/array/ComplexArrayJsonNeat.java +++ b/json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/array/ComplexArrayJsonNeat.java @@ -39,7 +39,7 @@ protected JsonCompareResult ignoreOrder(JsonDiffArray expect, JsonDiffArray actu continue; } TravelPath nextTravelPath = new TravelPath(this.travelPath, expectIndex, actualIndex); - JsonNeat jsonNeat = RunTimeDataFactory.getOptionInstance().getJsonNeatFactory().generate( expect.get(expectIndex), actual.get(actualIndex), nextTravelPath); + JsonNeat jsonNeat = RunTimeDataFactory.getOptionInstance().getJsonNeatFactory().generate(expect.get(expectIndex), actual.get(actualIndex), nextTravelPath); if (jsonNeat == null) { continue; } From 0894f11d832c33f3bc06db7c3ec7e04edb921b26 Mon Sep 17 00:00:00 2001 From: local-li <2939634393@qq.com> Date: Sun, 14 Apr 2024 22:35:53 +0800 Subject: [PATCH 08/11] update-readme(readme): update-readme --- Readme.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 2b397f3..4fde8d5 100644 --- a/Readme.md +++ b/Readme.md @@ -102,12 +102,12 @@ public class UseExample { ### 2.配置 -| 配置 | 类型 | 备注 | -| ---------------- | ------------------------------ | ------------------------------------------------------------ | -| ignoreOrder | boolean | 是否比较过程中忽略数组顺序 | -| mapping | Map | 将真实字段映射到期望字段,key是真实字段name,value是期望的字段name | -| ignorePath | Set\ | 当对比的路径完全匹配时会被跳过。遇到数组使用 `[]` 即可。无需填入下标 | -| ignoreKey | Set\ | 对比object时。或忽略该key。对整个json生效 | +| 配置 | 类型 | 备注 | +| ---------------- | ------------------------------ |------------------------------------------------------------------------| +| ignoreOrder | boolean | 是否比较过程中忽略数组顺序 | +| mapping | Map | 将真实字段映射到期望字段,key是真实字段name,value是期望的字段name.当真实字段和期望的字段对应的key都存在时,该配置才生效 | +| ignorePath | Set\ | 当对比的路径完全匹配时会被跳过。遇到数组使用 `[]` 即可。无需填入下标 | +| ignoreKey | Set\ | 对比object时。或忽略该key。对整个json生效 | > 在 `2.0.1-RC1-RELEASE` 之后版本中移除了 `keyFunction` 配置参数。可以使用 `ignorePath` 来代替达到同样的效果。 From 4a728a4a234d2fde92ad1c86760b2ea691f5f087 Mon Sep 17 00:00:00 2001 From: local-li <2939634393@qq.com> Date: Sun, 14 Apr 2024 22:37:26 +0800 Subject: [PATCH 09/11] update-readme(readme): update-readme --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 4fde8d5..c24e6e1 100644 --- a/Readme.md +++ b/Readme.md @@ -106,7 +106,7 @@ public class UseExample { | ---------------- | ------------------------------ |------------------------------------------------------------------------| | ignoreOrder | boolean | 是否比较过程中忽略数组顺序 | | mapping | Map | 将真实字段映射到期望字段,key是真实字段name,value是期望的字段name.当真实字段和期望的字段对应的key都存在时,该配置才生效 | -| ignorePath | Set\ | 当对比的路径完全匹配时会被跳过。遇到数组使用 `[]` 即可。无需填入下标 | +| ignorePath | Set\ | 当对比的路径完全匹配时会被跳过。标准的json-path | | ignoreKey | Set\ | 对比object时。或忽略该key。对整个json生效 | > 在 `2.0.1-RC1-RELEASE` 之后版本中移除了 `keyFunction` 配置参数。可以使用 `ignorePath` 来代替达到同样的效果。 From a2b3fe94f5f91239669f829c3ba6b91e20ea4d2e Mon Sep 17 00:00:00 2001 From: chenfeng Date: Sun, 14 Apr 2024 22:41:55 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8DREGEX=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E4=B8=8D=E5=AE=8C=E6=95=B4=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/codeleep/jsondiff/test/utils/FormatContent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/utils/FormatContent.java b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/utils/FormatContent.java index 94ea94c..689ace6 100644 --- a/json-diff-test/src/main/java/me/codeleep/jsondiff/test/utils/FormatContent.java +++ b/json-diff-test/src/main/java/me/codeleep/jsondiff/test/utils/FormatContent.java @@ -14,7 +14,7 @@ * @description: 格式化内容 */ public class FormatContent { - private static final String REGEX = "[a-zA-Z]+(\\.[a-zA-Z]+)+"; + private static final String REGEX = "[a-zA-Z]+(\\.[a-zA-Z0-9]+)+"; private static final Pattern pattern = Pattern.compile(REGEX); /** From 8164dfe0e07604e900c9d470f80e40c25bd866ad Mon Sep 17 00:00:00 2001 From: chenfeng Date: Sun, 14 Apr 2024 22:56:05 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9object=E6=A1=88?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/array/MultArrays.json | 30 +- .../main/resources/object/MultObjects.json | 1192 +++++++++-------- 2 files changed, 664 insertions(+), 558 deletions(-) diff --git a/json-diff-test/src/main/resources/array/MultArrays.json b/json-diff-test/src/main/resources/array/MultArrays.json index 054e837..a963745 100644 --- a/json-diff-test/src/main/resources/array/MultArrays.json +++ b/json-diff-test/src/main/resources/array/MultArrays.json @@ -4322,7 +4322,6 @@ }, { "caseName": "忽略根下的数组 后续改进【目前不支持】", - "skip": true, "actual": [ [ { @@ -8589,6 +8588,29 @@ "ignorePath": [ "$[*][*]" ] + }, + "ret": { + "defectsList": [ + { + "actual": "2", + "illustrate": "Only one set of keys exists expect('null'),actual('v')", + "travelPath": { + "abstractTravelPath": "$[*][*].a[*].v", + "actualTravelPath": "$[0][0].a[0].v", + "expectTravelPath": "$[0][0].a[0].null" + } + }, + { + "actual": "12", + "illustrate": "Only one set of keys exists expect('null'),actual('a')", + "travelPath": { + "abstractTravelPath": "$[*][*].a[*].a", + "actualTravelPath": "$[0][0].a[1].a", + "expectTravelPath": "$[0][0].a[1].null" + } + } + ], + "match": false } }, { @@ -9183,6 +9205,9 @@ "mapping": { "a": "b" } + }, + "ret": { + "match": true } }, { @@ -10409,7 +10434,8 @@ "ignorePath": [ "$[*].f" ] - } + }, + "ret": {} }, { "caseName": "配置mapping和ignoreOrder和ignorePath 预期中存在实际没有得值e TODO", diff --git a/json-diff-test/src/main/resources/object/MultObjects.json b/json-diff-test/src/main/resources/object/MultObjects.json index b2eebb5..c5d5c86 100644 --- a/json-diff-test/src/main/resources/object/MultObjects.json +++ b/json-diff-test/src/main/resources/object/MultObjects.json @@ -2781,7 +2781,21 @@ ] ] }, - "ret": {"defectsList":[{"actual":"4123","expect":"12345545","illustrate":"The expect('12345545') data is inconsistent with the actual('4123') data","travelPath":{"abstractTravelPath":"$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a","actualTravelPath":"$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a","expectTravelPath":"$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a"}}],"match":false} + "ret": { + "defectsList": [ + { + "actual": "4123", + "expect": "12345545", + "illustrate": "The expect('12345545') data is inconsistent with the actual('4123') data", + "travelPath": { + "abstractTravelPath": "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", + "actualTravelPath": "$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", + "expectTravelPath": "$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + } + } + ], + "match": false + } }, { "caseName": "特殊内容对比", @@ -2890,9 +2904,9 @@ "expect": "高温 17.0℃", "illustrate": "The expect('高温 17.0℃') data is inconsistent with the actual('123') data", "travelPath": { - "abstractTravelPath": "root.a.high", - "actualTravelPath": "root.a.high", - "expectTravelPath": "root.a.high" + "abstractTravelPath": "$.a.high", + "actualTravelPath": "$.a.high", + "expectTravelPath": "$.a.high" } }, { @@ -2900,9 +2914,9 @@ "expect": "21日星期四", "illustrate": "The expect('21日星期四') data is inconsistent with the actual('21星期四') data", "travelPath": { - "abstractTravelPath": "root.b.date", - "actualTravelPath": "root.b.date", - "expectTravelPath": "root.b.date" + "abstractTravelPath": "$.b.date", + "actualTravelPath": "$.b.date", + "expectTravelPath": "$.b.date" } }, { @@ -2910,9 +2924,9 @@ "expect": "高温 17.0℃", "illustrate": "The expect('高温 17.0℃') data is inconsistent with the actual('124') data", "travelPath": { - "abstractTravelPath": "root.b.high", - "actualTravelPath": "root.b.high", - "expectTravelPath": "root.b.high" + "abstractTravelPath": "$.b.high", + "actualTravelPath": "$.b.high", + "expectTravelPath": "$.b.high" } }, { @@ -2920,9 +2934,9 @@ "expect": "高温 17.0℃", "illustrate": "The expect('高温 17.0℃') data is inconsistent with the actual('125') data", "travelPath": { - "abstractTravelPath": "root.c.high", - "actualTravelPath": "root.c.high", - "expectTravelPath": "root.c.high" + "abstractTravelPath": "$.c.high", + "actualTravelPath": "$.c.high", + "expectTravelPath": "$.c.high" } } ], @@ -2946,21 +2960,21 @@ "ret": { "defectsList": [ { - "expect": 1, + "expect": "1", "illustrate": "Only one set of keys exists expect('b'),actual('null')", "travelPath": { - "abstractTravelPath": "root.a.b", - "actualTravelPath": "root.a.null", - "expectTravelPath": "root.a.b" + "abstractTravelPath": "$.a.b", + "actualTravelPath": "$.a.null", + "expectTravelPath": "$.a.b" } }, { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('a')", "travelPath": { - "abstractTravelPath": "root.a.a", - "actualTravelPath": "root.a.a", - "expectTravelPath": "root.a.null" + "abstractTravelPath": "$.a.a", + "actualTravelPath": "$.a.a", + "expectTravelPath": "$.a.null" } } ], @@ -2975,7 +2989,21 @@ "expect": { "a": [] }, - "ret": {"defectsList":[{"actual":{},"expect":{},"illustrate":"The expect type ('me.codeleep.jsondiff.impl.fastjson2.FastJson2Array') is inconsistent with the actual type ('me.codeleep.jsondiff.impl.fastjson2.FastJson2Object')","travelPath":{"abstractTravelPath":"root.a","actualTravelPath":"root.a","expectTravelPath":"root.a"}}],"match":false} + "ret": { + "defectsList": [ + { + "actual": "{}", + "expect": "[]", + "illustrate": "The expect type ('me.codeleep.jsondiff.impl.fastjson2.FastJson2Array') is inconsistent with the actual type ('me.codeleep.jsondiff.impl.fastjson2.FastJson2Object')", + "travelPath": { + "abstractTravelPath": "$.a", + "actualTravelPath": "$.a", + "expectTravelPath": "$.a" + } + } + ], + "match": false + } }, { "caseName": "内容相同 类型不同", @@ -2989,12 +3017,12 @@ "defectsList": [ { "actual": "1.1234", - "expect": 1.1234, + "expect": "1.1234", "illustrate": "The expect type ('java.math.BigDecimal') is inconsistent with the actual type ('java.lang.String')", "travelPath": { - "abstractTravelPath": "root.a", - "actualTravelPath": "root.a", - "expectTravelPath": "root.a" + "abstractTravelPath": "$.a", + "actualTravelPath": "$.a", + "expectTravelPath": "$.a" } } ], @@ -3247,7 +3275,7 @@ "option": { "ignoreOrder": false, "ignorePath": [ - "root.a[].a" + "$.a[*].a" ] } }, @@ -3301,7 +3329,7 @@ }, "option": { "ignorePath": [ - "root[][].a" + "$[][*].a" ] } }, @@ -3455,7 +3483,7 @@ }, "option": { "ignorePath": [ - "root.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + "$.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" ] } }, @@ -3533,7 +3561,7 @@ }, "option": { "ignorePath": [ - "root.a[][].a.a" + "$.a[*][*].a.a" ] } }, @@ -4079,7 +4107,7 @@ }, "option": { "ignorePath": [ - "root.a.b.c[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a" + "$.a.b.c[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a" ] } }, @@ -4697,7 +4725,7 @@ }, "option": { "ignorePath": [ - "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" ] } }, @@ -4729,7 +4757,7 @@ "expect": {}, "option": { "ignorePath": [ - "root" + "$" ] } }, @@ -4765,7 +4793,7 @@ }, "option": { "ignorePath": [ - "root.a[][].a[].b" + "$.a[*][*].a[*].b" ] } }, @@ -5383,8 +5411,11 @@ }, "option": { "mapping": { - "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b": "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b": "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" } + }, + "ret": { + "match": true } }, { @@ -5409,6 +5440,9 @@ "mapping": { "b": "a" } + }, + "ret": { + "match": true } }, { @@ -5431,6 +5465,9 @@ "mapping": { "c": "d" } + }, + "ret": { + "match": true } }, { @@ -5610,7 +5647,7 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root.l[].c" + "$.l[*].c" ] } }, @@ -5738,7 +5775,7 @@ }, "option": { "ignorePath": [ - "root.l[].n" + "$.l[*].n" ], "ignoreKey": [ "f" @@ -5785,7 +5822,7 @@ "b": "c" }, "ignorePath": [ - "root.l[].f" + "$.l[*].f" ] } }, @@ -5837,7 +5874,7 @@ "b": "c" }, "ignorePath": [ - "root.l[].f" + "$.l[*].f" ] } }, @@ -5927,7 +5964,7 @@ "b": "c" }, "ignorePath": [ - "root.l[].f" + "$.l[*].f" ], "ignoreKey": [ "n" @@ -5973,7 +6010,7 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root.l[].c" + "$.l[*].c" ], "ignoreKey": [ "k" @@ -6018,7 +6055,7 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root.l[].c" + "$.l[*].c" ] } }, @@ -6193,7 +6230,7 @@ }, "option": { "ignorePath": [ - "root.l[].n" + "$.l[*].n" ], "ignoreKey": [ "f" @@ -6240,7 +6277,7 @@ "b": "c" }, "ignorePath": [ - "root.l[].f" + "$.l[*].f" ] } }, @@ -6285,7 +6322,7 @@ "b": "c" }, "ignorePath": [ - "root.l[].f" + "$.l[*].f" ] } }, @@ -6375,7 +6412,7 @@ "b": "c" }, "ignorePath": [ - "root.l[].f" + "$.l[*].f" ], "ignoreKey": [ "n" @@ -6421,7 +6458,7 @@ "option": { "ignoreOrder": true, "ignorePath": [ - "root.l[].c" + "$.l[*].c" ], "ignoreKey": [ "k" @@ -6471,7 +6508,7 @@ }, [ "a", - "a", + "b", "c" ] ] @@ -6524,19 +6561,19 @@ "ignoreOrder": true }, "ret": { - "defectsList": [ + "defectsList":[ { - "actual": "a", - "expect": "b", - "illustrate": "The expect('b') data is inconsistent with the actual('a') data", - "travelPath": { - "abstractTravelPath": "root[][]", - "actualTravelPath": "root[2][0]", - "expectTravelPath": "root[2][0]" + "actual":"b", + "expect":"a", + "illustrate":"The expect('a') data is inconsistent with the actual('b') data", + "travelPath":{ + "abstractTravelPath":"$.b[*][*]", + "actualTravelPath":"$.b[3][1]", + "expectTravelPath":"$.b[3][1]" } } ], - "match": false + "match":false } }, { @@ -6729,12 +6766,12 @@ "ret": { "defectsList": [ { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('b')", "travelPath": { - "abstractTravelPath": "root.a[].b", - "actualTravelPath": "root.a[0].b", - "expectTravelPath": "root.a[0].null" + "abstractTravelPath": "$.a[*].b", + "actualTravelPath": "$.a[0].b", + "expectTravelPath": "$.a[0].null" } }, { @@ -6742,9 +6779,9 @@ "expect": "08020093", "illustrate": "The expect('08020093') data is inconsistent with the actual('08020094') data", "travelPath": { - "abstractTravelPath": "root.a[][][]", - "actualTravelPath": "root.a[1][0][0]", - "expectTravelPath": "root.a[1][0][0]" + "abstractTravelPath": "$.a[*][*][*]", + "actualTravelPath": "$.a[1][0][0]", + "expectTravelPath": "$.a[1][0][0]" } } ], @@ -6753,7 +6790,7 @@ "option": { "ignoreOrder": false, "ignorePath": [ - "root.a[].a" + "$.a[*].a" ] } }, @@ -6817,19 +6854,19 @@ }, "option": { "ignorePath": [ - "root.a[][].a" + "$.a[*][*].a" ] }, "ret": { "defectsList": [ { - "actual": 2, - "expect": 3, + "actual": "2", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('2') data", "travelPath": { - "abstractTravelPath": "root.a[][].b", - "actualTravelPath": "root.a[0][1].b", - "expectTravelPath": "root.a[0][1].b" + "abstractTravelPath": "$.a[*][*].b", + "actualTravelPath": "$.a[0][1].b", + "expectTravelPath": "$.a[0][1].b" } } ], @@ -7202,29 +7239,29 @@ }, "option": { "ignorePath": [ - "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a" + "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a" ] }, "ret": { "defectsList": [ { - "actual": 3, - "expect": 2, + "actual": "3", + "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('3') data", "travelPath": { - "abstractTravelPath": "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].b", - "actualTravelPath": "root.a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b", - "expectTravelPath": "root.a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b" + "abstractTravelPath": "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].b", + "actualTravelPath": "$.a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b", + "expectTravelPath": "$.a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b" } }, { - "actual": 1, - "expect": 3, + "actual": "1", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('1') data", "travelPath": { - "abstractTravelPath": "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].C", - "actualTravelPath": "root.a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C", - "expectTravelPath": "root.a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C" + "abstractTravelPath": "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].C", + "actualTravelPath": "$.a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C", + "expectTravelPath": "$.a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][1].C" } } ], @@ -7309,29 +7346,29 @@ }, "option": { "ignorePath": [ - "root.a[][].a.a" + "$.a[*][*].a.a" ] }, "ret": { "defectsList": [ { - "actual": 2, - "expect": 3, + "actual": "2", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('2') data", "travelPath": { - "abstractTravelPath": "root.a[][].a.b", - "actualTravelPath": "root.a[3][0].a.b", - "expectTravelPath": "root.a[3][0].a.b" + "abstractTravelPath": "$.a[*][*].a.b", + "actualTravelPath": "$.a[3][0].a.b", + "expectTravelPath": "$.a[3][0].a.b" } }, { - "actual": 3, - "expect": 2, + "actual": "3", + "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('3') data", "travelPath": { - "abstractTravelPath": "root.a[][].c", - "actualTravelPath": "root.a[3][0].c", - "expectTravelPath": "root.a[3][0].c" + "abstractTravelPath": "$.a[*][*].c", + "actualTravelPath": "$.a[3][0].c", + "expectTravelPath": "$.a[3][0].c" } } ], @@ -7886,19 +7923,19 @@ }, "option": { "ignorePath": [ - "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a" + "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a" ] }, "ret": { "defectsList": [ { - "actual": 1, - "expect": 3, + "actual": "1", + "expect": "3", "illustrate": "The expect('3') data is inconsistent with the actual('1') data", "travelPath": { - "abstractTravelPath": "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].b[].c", - "actualTravelPath": "root.a[3][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b[0].c", - "expectTravelPath": "root.a[3][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b[0].c" + "abstractTravelPath": "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].b[*].c", + "actualTravelPath": "$.a[3][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b[0].c", + "expectTravelPath": "$.a[3][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].b[0].c" } } ], @@ -8521,27 +8558,27 @@ }, "option": { "ignorePath": [ - "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" + "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" ] }, "ret": { "defectsList": [ { - "actual": 22, + "actual": "22", "illustrate": "Only one set of keys exists expect('null'),actual('b')", "travelPath": { - "abstractTravelPath": "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", - "actualTravelPath": "root.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", - "expectTravelPath": "root.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.null" + "abstractTravelPath": "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", + "actualTravelPath": "$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", + "expectTravelPath": "$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.null" } }, { - "actual": 3, + "actual": "3", "illustrate": "Only one set of keys exists expect('null'),actual('b')", "travelPath": { - "abstractTravelPath": "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", - "actualTravelPath": "root.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", - "expectTravelPath": "root.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.null" + "abstractTravelPath": "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", + "actualTravelPath": "$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.b", + "expectTravelPath": "$.a[3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0].a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.null" } } ], @@ -8577,7 +8614,7 @@ "expect": {}, "option": { "ignorePath": [ - "root" + "$" ] }, "ret": { @@ -8607,8 +8644,11 @@ }, "option": { "ignorePath": [ - "root.a[][]" + "$.a[*][*]" ] + }, + "ret": { + "match": true } }, { @@ -8648,27 +8688,27 @@ }, "option": { "ignorePath": [ - "root.a[][].a[].b" + "$.a[*][*].a[*].b" ] }, "ret": { "defectsList": [ { - "actual": 2, + "actual": "2", "illustrate": "Only one set of keys exists expect('null'),actual('v')", "travelPath": { - "abstractTravelPath": "root.a[][].a[].v", - "actualTravelPath": "root.a[0][0].a[0].v", - "expectTravelPath": "root.a[0][0].a[0].null" + "abstractTravelPath": "$.a[*][*].a[*].v", + "actualTravelPath": "$.a[0][0].a[0].v", + "expectTravelPath": "$.a[0][0].a[0].null" } }, { - "actual": 12, + "actual": "12", "illustrate": "Only one set of keys exists expect('null'),actual('a')", "travelPath": { - "abstractTravelPath": "root.a[][].a[].a", - "actualTravelPath": "root.a[0][0].a[1].a", - "expectTravelPath": "root.a[0][0].a[1].null" + "abstractTravelPath": "$.a[*][*].a[*].a", + "actualTravelPath": "$.a[0][0].a[1].a", + "expectTravelPath": "$.a[0][0].a[1].null" } } ], @@ -9209,8 +9249,11 @@ }, "option": { "mapping": { - "root.a[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.a": "root[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][].a.b" + "$.a[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.a": "$[*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*][*].a.b" } + }, + "ret": { + "match": true } }, { @@ -9829,6 +9872,9 @@ "mapping": { "b": "a" } + }, + "ret": { + "match": true } }, { @@ -9855,8 +9901,11 @@ }, "option": { "mapping": { - "root.a[].b": "root.a[].a" + "$.a[*].b": "$.a[*].a" } + }, + "ret": { + "match": true } }, { @@ -9881,8 +9930,11 @@ }, "option": { "mapping": { - "root.a[].c": "root.a[].d" + "$.a[*].c": "$.a[*].d" } + }, + "ret": { + "match": true } }, { @@ -9909,13 +9961,13 @@ "ret": { "defectsList": [ { - "actual": 1, - "expect": 2, + "actual": "1", + "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('1') data", "travelPath": { - "abstractTravelPath": "root.k[].b", - "actualTravelPath": "root.k[0].a", - "expectTravelPath": "root.k[0].b" + "abstractTravelPath": "$.k[*].b", + "actualTravelPath": "$.k[0].a", + "expectTravelPath": "$.k[0].b" } } ], @@ -9949,7 +10001,29 @@ "a": "b" } }, - "ret": {"defectsList":[{"expect":3,"illustrate":"Only one set of keys exists expect('c'),actual('null')","travelPath":{"abstractTravelPath":"root.t[].c","actualTravelPath":"root.t[1].null","expectTravelPath":"root.t[1].c"}},{"actual":3,"illustrate":"Only one set of keys exists expect('null'),actual('a')","travelPath":{"abstractTravelPath":"root.t[].a","actualTravelPath":"root.t[1].a","expectTravelPath":"root.t[1].null"}}],"match":false} + "ret": { + "defectsList": [ + { + "expect": "3", + "illustrate": "Only one set of keys exists expect('c'),actual('null')", + "travelPath": { + "abstractTravelPath": "$.t[*].c", + "actualTravelPath": "$.t[1].null", + "expectTravelPath": "$.t[1].c" + } + }, + { + "actual": "3", + "illustrate": "Only one set of keys exists expect('null'),actual('a')", + "travelPath": { + "abstractTravelPath": "$.t[*].a", + "actualTravelPath": "$.t[1].a", + "expectTravelPath": "$.t[1].null" + } + } + ], + "match": false + } }, { "caseName": "忽略单个key key不匹配 ", @@ -9999,12 +10073,12 @@ "ret": { "defectsList": [ { - "expect": 3, + "expect": "3", "illustrate": "Only one set of keys exists expect('b'),actual('null')", "travelPath": { - "abstractTravelPath": "root.k[].b", - "actualTravelPath": "root.k[4].null", - "expectTravelPath": "root.k[4].b" + "abstractTravelPath": "$.k[*].b", + "actualTravelPath": "$.k[4].null", + "expectTravelPath": "$.k[4].b" } } ], @@ -10060,13 +10134,13 @@ "ret": { "defectsList": [ { - "actual": 1, - "expect": 2, + "actual": "1", + "expect": "2", "illustrate": "The expect('2') data is inconsistent with the actual('1') data", "travelPath": { - "abstractTravelPath": "root.k[].c", - "actualTravelPath": "root.k[4].c", - "expectTravelPath": "root.k[4].c" + "abstractTravelPath": "$.k[*].c", + "actualTravelPath": "$.k[4].c", + "expectTravelPath": "$.k[4].c" } } ], @@ -10075,44 +10149,44 @@ }, { "caseName": "配置mapping和ignoreOrder 预期增加不存在参数 ", - "actual": {"t": - [ - { - "a": 2 - }, - { - "a": 1 - }, - { - "b": 2 - }, - { - "b": 1 - }, - { - "b": 1 - } - ] - }, - "expect": {"t": - [ - { - "a": 1 - }, - { - "c": 2 - }, - { - "a": 2 + "actual": { + "t": [ + { + "a": 2 + }, + { + "a": 1 + }, + { + "b": 2 + }, + { + "b": 1 + }, + { + "b": 1 + } + ] }, - { - "c": 1 + "expect": { + "t": [ + { + "a": 1 + }, + { + "c": 2 + }, + { + "a": 2 + }, + { + "c": 1 + }, + { + "d": 1 + } + ] }, - { - "d": 1 - } - ] - }, "option": { "ignoreOrder": true, "mapping": { @@ -10120,81 +10194,81 @@ } }, "ret": { - "defectsList":[ + "defectsList": [ { - "expect":1, - "illustrate":"Only one set of keys exists expect('d'),actual('null')", - "travelPath":{ - "abstractTravelPath":"root.t[].d", - "actualTravelPath":"root.t[4].null", - "expectTravelPath":"root.t[4].d" + "expect": "1", + "illustrate": "Only one set of keys exists expect('d'),actual('null')", + "travelPath": { + "abstractTravelPath": "$.t[*].d", + "actualTravelPath": "$.t[4].null", + "expectTravelPath": "$.t[4].d" } }, { - "actual":1, - "illustrate":"Only one set of keys exists expect('null'),actual('b')", - "travelPath":{ - "abstractTravelPath":"root.t[].b", - "actualTravelPath":"root.t[4].b", - "expectTravelPath":"root.t[4].null" + "actual": "1", + "illustrate": "Only one set of keys exists expect('null'),actual('b')", + "travelPath": { + "abstractTravelPath": "$.t[*].b", + "actualTravelPath": "$.t[4].b", + "expectTravelPath": "$.t[4].null" } } ], - "match":false + "match": false } }, { "caseName": "配置ignoreOrder和ignorePath 增加不匹配字段", - "actual": {"t": - [ - { - "a": 2, - "c": 3, - "d": 1 - }, - { - "a": 1 - }, - { - "b": 2 - }, - { - "b": 1, - "c": 2 - } - ] - }, - "expect": {"t": - [ - { - "a": 2 - }, - { - "b": 2 + "actual": { + "t": [ + { + "a": 2, + "c": 3, + "d": 1 + }, + { + "a": 1 + }, + { + "b": 2 + }, + { + "b": 1, + "c": 2 + } + ] }, - { - "a": 1 + "expect": { + "t": [ + { + "a": 2 + }, + { + "b": 2 + }, + { + "a": 1 + }, + { + "b": 1 + } + ] }, - { - "b": 1 - } - ] - }, "option": { "ignoreOrder": true, "ignorePath": [ - "root.t[].c" + "$.t[*].c" ] }, "ret": { "defectsList": [ { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('d')", "travelPath": { - "abstractTravelPath": "root.t[].d", - "actualTravelPath": "root.t[0].d", - "expectTravelPath": "root.t[0].null" + "abstractTravelPath": "$.t[*].d", + "actualTravelPath": "$.t[0].d", + "expectTravelPath": "$.t[0].null" } } ], @@ -10203,42 +10277,42 @@ }, { "caseName": "配置ignoreOrder和ignoreKey 增加不匹配字段 并增加忽略字段不同类型", - "actual": {"t": - [ - { - "a": 2, - "c": 3, - "f": 2 - }, - { - "a": 1, - "c": "f" - }, - { - "b": 2, - "d": 1 - }, - { - "b": 1 - } - ] - }, - "expect": {"t": - [ - { - "a": 2 - }, - { - "b": 2 + "actual": { + "t": [ + { + "a": 2, + "c": 3, + "f": 2 + }, + { + "a": 1, + "c": "f" + }, + { + "b": 2, + "d": 1 + }, + { + "b": 1 + } + ] }, - { - "a": 1 + "expect": { + "t": [ + { + "a": 2 + }, + { + "b": 2 + }, + { + "a": 1 + }, + { + "b": 1 + } + ] }, - { - "b": 1 - } - ] - }, "option": { "ignoreOrder": true, "ignoreKey": [ @@ -10249,12 +10323,12 @@ "ret": { "defectsList": [ { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('d')", "travelPath": { - "abstractTravelPath": "root.t[].d", - "actualTravelPath": "root.t[2].d", - "expectTravelPath": "root.t[1].null" + "abstractTravelPath": "$.t[*].d", + "actualTravelPath": "$.t[2].d", + "expectTravelPath": "$.t[1].null" } } ], @@ -10263,40 +10337,40 @@ }, { "caseName": "配置mapping和ignoreKey 增加不满足的d字段", - "actual": {"t": - [ - { - "a": 2, - "f": 2 - }, - { - "a": 1 - }, - { - "b": 2 - }, - { - "d": 1, - "f": "c" - } - ] - }, - "expect": {"t": - [ - { - "a": 2 - }, - { - "a": 1 + "actual": { + "t": [ + { + "a": 2, + "f": 2 + }, + { + "a": 1 + }, + { + "b": 2 + }, + { + "d": 1, + "f": "c" + } + ] }, - { - "c": 2 + "expect": { + "t": [ + { + "a": 2 + }, + { + "a": 1 + }, + { + "c": 2 + }, + { + "c": 1 + } + ] }, - { - "c": 1 - } - ] - }, "option": { "mapping": { "b": "c" @@ -10306,71 +10380,71 @@ ] }, "ret": { - "defectsList":[ + "defectsList": [ { - "expect":1, - "illustrate":"Only one set of keys exists expect('c'),actual('null')", - "travelPath":{ - "abstractTravelPath":"root.t[].c", - "actualTravelPath":"root.t[3].null", - "expectTravelPath":"root.t[3].c" + "expect": "1", + "illustrate": "Only one set of keys exists expect('c'),actual('null')", + "travelPath": { + "abstractTravelPath": "$.t[*].c", + "actualTravelPath": "$.t[3].null", + "expectTravelPath": "$.t[3].c" } }, { - "actual":1, - "illustrate":"Only one set of keys exists expect('null'),actual('d')", - "travelPath":{ - "abstractTravelPath":"root.t[].d", - "actualTravelPath":"root.t[3].d", - "expectTravelPath":"root.t[3].null" + "actual": "1", + "illustrate": "Only one set of keys exists expect('null'),actual('d')", + "travelPath": { + "abstractTravelPath": "$.t[*].d", + "actualTravelPath": "$.t[3].d", + "expectTravelPath": "$.t[3].null" } } ], - "match":false + "match": false } }, { "caseName": "配置ignorePath和ignoreKey 增加不同位置忽略字段 增加不匹配字段 ", - "actual": {"t": - [ - { - "a": 2, - "f": 2, - "n": 4 - }, - { - "a": 1, - "n": "F" - }, - { - "b": 2, - "f": 2 - }, - { - "b": 1, - "F": "f" - } - ] - }, - "expect": {"t": - [ - { - "a": 2 - }, - { - "a": 1 - }, - { - "b": 2 - }, - { - "b": 1 - } - ] - }, + "actual": { + "t": [ + { + "a": 2, + "f": 2, + "n": 4 + }, + { + "a": 1, + "n": "F" + }, + { + "b": 2, + "f": 2 + }, + { + "b": 1, + "F": "f" + } + ] + }, + "expect": { + "t": [ + { + "a": 2 + }, + { + "a": 1 + }, + { + "b": 2 + }, + { + "b": 1 + } + ] + }, "option": { "ignorePath": [ - "root.a[].n" + "$.t[*].n" ], "ignoreKey": [ "f" @@ -10382,9 +10456,9 @@ "actual": "f", "illustrate": "Only one set of keys exists expect('null'),actual('F')", "travelPath": { - "abstractTravelPath": "root.t[].F", - "actualTravelPath": "root.t[3].F", - "expectTravelPath": "root.t[3].null" + "abstractTravelPath": "$.t[*].F", + "actualTravelPath": "$.t[3].F", + "expectTravelPath": "$.t[3].null" } } ], @@ -10393,141 +10467,156 @@ }, { "caseName": "配置mapping和ignorePath", - "actual": {"t": - [ - { - "a": 2, - "f": 2 - }, - { - "a": 1 - }, - { - "b": 2 - }, - { - "b": 1 - } - ] - }, - "expect": {"t": - [ - { - "a": 2 - }, - { - "a": 1 + "actual": { + "t": [ + { + "a": 2, + "f": 2 + }, + { + "a": 1 + }, + { + "b": 2 + }, + { + "b": 1 + } + ] }, - { - "c": 2 + "expect": { + "t": [ + { + "a": 2 + }, + { + "a": 1 + }, + { + "c": 2 + }, + { + "c": 1 + } + ] }, - { - "c": 1 - } - ] - }, "option": { "mapping": { "b": "c" }, "ignorePath": [ - "root.t[].f" + "$.t[*].f" ] }, - "ret": {"match":true} + "ret": { + "match": true + } }, { "caseName": "配置mapping和ignoreOrder和ignorePath 预期中存在实际没有得值e ", - "actual": {"t": - [ - { - "a": 2, - "f": 4 - }, - { - "a": 1 - }, - { - "b": 2 - }, - { - "b": 1, - "f": 1 - }, - { - "c": 1 - } - ] - }, - "expect": {"t": - [ - { - "a": 1 - }, - { - "c": 2 - }, - { - "a": 2, - "e": 1 + "actual": { + "t": [ + { + "a": 2, + "f": 4 + }, + { + "a": 1 + }, + { + "b": 2 + }, + { + "b": 1, + "f": 1 + }, + { + "c": 1 + } + ] }, - { - "c": 1 + "expect": { + "t": [ + { + "a": 1 + }, + { + "c": 2 + }, + { + "a": 2, + "e": 1 + }, + { + "c": 1 + }, + { + "c": 1 + } + ] }, - { - "c": 1 - } - ] - }, "option": { "ignoreOrder": true, "mapping": { "b": "c" }, "ignorePath": [ - "root.t[].f" + "$.t[*].f" ] }, - "ret":{"defectsList":[{"expect":1,"illustrate":"Only one set of keys exists expect('e'),actual('null')","travelPath":{"abstractTravelPath":"root.t[].e","actualTravelPath":"root.t[0].null","expectTravelPath":"root.t[2].e"}}],"match":false} + "ret": { + "defectsList": [ + { + "expect": "1", + "illustrate": "Only one set of keys exists expect('e'),actual('null')", + "travelPath": { + "abstractTravelPath": "$.t[*].e", + "actualTravelPath": "$.t[0].null", + "expectTravelPath": "$.t[2].e" + } + } + ], + "match": false + } }, { "caseName": "配置mapping和ignoreOrder和ignoreKey 在预期中存在替换的字段", - "actual": {"t": - [ - { - "a": 2, - "f": 5 - }, - { - "a": 1 - }, - { - "b": 2, - "a": 1, - "f": 1 - }, - { - "b": 1 - } - ] - }, - "expect": {"t": - [ - { - "a": 1 - }, - { - "b": 2, - "a": 2 + "actual": { + "t": [ + { + "a": 2, + "f": 5 + }, + { + "a": 1 + }, + { + "b": 2, + "a": 1, + "f": 1 + }, + { + "b": 1 + } + ] }, - { - "a": 2 + "expect": { + "t": [ + { + "a": 1 + }, + { + "b": 2, + "a": 2 + }, + { + "a": 2 + }, + { + "c": 1 + } + ] }, - { - "c": 1 - } - ] - }, "option": { "ignoreOrder": true, "mapping": { @@ -10538,76 +10627,67 @@ ] }, "ret": { - "defectsList": [ - { - "actual": 2, - "illustrate": "The expect type ('null') is inconsistent with the actual type ('java.lang.Integer')", - "travelPath": { - "abstractTravelPath": "root.t[].b", - "actualTravelPath": "root.t[1].null", - "expectTravelPath": "root.t[1].b" - } - }, + "defectsList":[ { - "actual": 1, - "expect": 2, - "illustrate": "The expect('2') data is inconsistent with the actual('1') data", - "travelPath": { - "abstractTravelPath": "root.t[].a", - "actualTravelPath": "root.t[2].a", - "expectTravelPath": "root.t[1].a" + "actual":"1", + "expect":"2", + "illustrate":"The expect('2') data is inconsistent with the actual('1') data", + "travelPath":{ + "abstractTravelPath":"$.t[*].a", + "actualTravelPath":"$.t[2].a", + "expectTravelPath":"$.t[1].a" } } ], - "match": false + "match":false } }, { "caseName": "配置mapping和ignorePath和ignoreKey 忽略是对预期和实际都忽略", - "actual": {"t": - [ - { - "a": 2, - "f": 2, - "n": 5, - "m": 1 - }, - { - "a": 1, - "f": 2 - }, - { - "b": 2, - "m": 1 - }, - { - "b": 1 - } - ] - }, - "expect": {"t": - [ - { - "a": 2 - }, - { - "a": 1, - "f": 1 + "actual": { + "t": [ + { + "a": 2, + "f": 2, + "n": 5, + "m": 1 + }, + { + "a": 1, + "f": 2 + }, + { + "b": 2, + "m": 1 + }, + { + "b": 1 + } + ] }, - { - "c": 2 + "expect": { + "t": [ + { + "a": 2 + }, + { + "a": 1, + "f": 1 + }, + { + "c": 2 + }, + { + "c": 1 + } + ] }, - { - "c": 1 - } - ] - }, "option": { "mapping": { "b": "c" }, "ignorePath": [ - "root.t[].f" + "$.t[*].f" ], "ignoreKey": [ "n" @@ -10616,21 +10696,21 @@ "ret": { "defectsList": [ { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('m')", "travelPath": { - "abstractTravelPath": "root.t[].m", - "actualTravelPath": "root.t[0].m", - "expectTravelPath": "root.t[0].null" + "abstractTravelPath": "$.t[*].m", + "actualTravelPath": "$.t[0].m", + "expectTravelPath": "$.t[0].null" } }, { - "actual": 1, + "actual": "1", "illustrate": "Only one set of keys exists expect('null'),actual('m')", "travelPath": { - "abstractTravelPath": "root.t[].m", - "actualTravelPath": "root.t[2].m", - "expectTravelPath": "root.t[2].null" + "abstractTravelPath": "$.t[*].m", + "actualTravelPath": "$.t[2].m", + "expectTravelPath": "$.t[2].null" } } ], @@ -10639,46 +10719,46 @@ }, { "caseName": "配置ignoreOrder和ignorePath和ignoreKey 增加不同位置的内容 ", - "actual": {"t": - [ - { - "a": 2, - "c": 3, - "k": "12312" - }, - { - "a": 1 - }, - { - "b": 2, - "k": 3 - }, - { - "b": 1, - "c": 2 - } - ] - }, - "expect": {"t": - [ - { - "a": 2 - }, - { - "b": 2 + "actual": { + "t": [ + { + "a": 2, + "c": 3, + "k": "12312" + }, + { + "a": 1 + }, + { + "b": 2, + "k": 3 + }, + { + "b": 1, + "c": 2 + } + ] }, - { - "a": 1 + "expect": { + "t": [ + { + "a": 2 + }, + { + "b": 2 + }, + { + "a": 1 + }, + { + "b": 1 + } + ] }, - { - "b": 1 - } - ] - }, "option": { "ignoreOrder": true, "ignorePath": [ - "root.t[].c" + "$.t[*].c" ], "ignoreKey": [ "k"