fix(接口测试): 修复jsonPath断言精度丢失问题

--bug=1026684 --user=王孝刚 【接口测试】github #24735 1.20.23LTS JSONPath断言
正则比对3260.00 != 3260.0 导致之前写的正则比对报错
https://www.tapd.cn/55049933/s/1386814
This commit is contained in:
wxg0103 2023-06-27 13:45:25 +08:00 committed by 刘瑞斌
parent 1e82da6309
commit 9fb103641d
1 changed files with 4 additions and 4 deletions

View File

@ -195,7 +195,7 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
List<Boolean> result = new ArrayList<>();
for (Object subj : value.toArray()) {
if (!StringUtils.equals(getOption(), "NOT_CONTAINS")) {
if (!StringUtils.equalsAnyIgnoreCase(getOption(), "NOT_CONTAINS","EQUALS")) {
if (subj == null && this.isExpectNull() || isEquals(subj)) {
return true;
}
@ -203,7 +203,7 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
result.add(isEquals(subj));
}
}
if (CollectionUtils.isNotEmpty(result) && StringUtils.equals(getOption(), "NOT_CONTAINS")) {
if (CollectionUtils.isNotEmpty(result) && StringUtils.equalsAnyIgnoreCase(getOption(), "NOT_CONTAINS", "EQUALS")) {
if (result.stream().filter(item -> item == true).collect(Collectors.toList()).size() == result.size()) {
return true;
} else {
@ -281,8 +281,8 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
private static boolean valueEquals(String v1, String v2) {
try {
Number number1 = NumberUtils.createNumber(v1);
Number number2 = NumberUtils.createNumber(v2);
Number number1 = NumberUtils.createBigDecimal(v1);
Number number2 = NumberUtils.createBigDecimal(v2);
return number1.equals(number2);
} catch (Exception e) {
return StringUtils.equals(v1, v2);