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:
parent
1e82da6309
commit
9fb103641d
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue