parent
efbf710ad7
commit
ecbdb4734c
|
@ -67,7 +67,7 @@ public class ErrorReportLibraryUtil {
|
|||
}
|
||||
|
||||
//根据配置来筛选断言、获取误报编码、获取接口状态是否是误报
|
||||
AssertionFilterResult filterResult = filterAssertions(passedErrorReportAssertionMap,successAssertionMessageMap,errorAssertionMessageMap,higherThanSuccess,higherThanError);
|
||||
AssertionFilterResult filterResult = filterAssertions(passedErrorReportAssertionMap, successAssertionMessageMap, errorAssertionMessageMap, result.isSuccess(), higherThanSuccess, higherThanError);
|
||||
int filteredSuccessAssertionCount = unMatchErrorReportAssertions.size() + filterResult.filteredSuccessAssertionList.size();
|
||||
unMatchErrorReportAssertions.addAll(filterResult.filteredSuccessAssertionList);
|
||||
unMatchErrorReportAssertions.addAll(filterResult.filteredErrorAssertionList);
|
||||
|
@ -118,7 +118,7 @@ public class ErrorReportLibraryUtil {
|
|||
private static AssertionFilterResult filterAssertions(Map<String, List<ResponseAssertionResult>> errorReportAssertionMap,
|
||||
Map<String, List<ResponseAssertionResult>> successAssertionMap,
|
||||
Map<String, List<ResponseAssertionResult>> errorAssertionMap,
|
||||
boolean higherThanSuccess, boolean higherThanError) {
|
||||
boolean resultIsSuccess, boolean higherThanSuccess, boolean higherThanError) {
|
||||
AssertionFilterResult result = new AssertionFilterResult();
|
||||
if (MapUtils.isNotEmpty(errorReportAssertionMap)) {
|
||||
List<ResponseAssertionResult> removedSuccessList = removeAssertions(errorReportAssertionMap, successAssertionMap, higherThanSuccess);
|
||||
|
@ -145,13 +145,7 @@ public class ErrorReportLibraryUtil {
|
|||
}
|
||||
|
||||
if (MapUtils.isNotEmpty(errorReportAssertionMap)) {
|
||||
if (MapUtils.isNotEmpty(errorAssertionMap)) {
|
||||
if(higherThanError){
|
||||
result.requestStatus = ExecuteResult.ERROR_REPORT_RESULT.toString();
|
||||
}
|
||||
}else if(higherThanSuccess){
|
||||
result.requestStatus = ExecuteResult.ERROR_REPORT_RESULT.toString();
|
||||
}else if(MapUtils.isEmpty(successAssertionMap)){
|
||||
if ((higherThanError && !resultIsSuccess) || (higherThanSuccess && resultIsSuccess)) {
|
||||
result.requestStatus = ExecuteResult.ERROR_REPORT_RESULT.toString();
|
||||
}
|
||||
}
|
||||
|
@ -161,26 +155,27 @@ public class ErrorReportLibraryUtil {
|
|||
|
||||
/**
|
||||
* 将匹配的断言移除
|
||||
* @param map1
|
||||
* @param map2
|
||||
* @param removeDataInMap2 是否移除map2中的数据?true:移除map2中的数据 false:移除map1中的数据
|
||||
*
|
||||
* @param firstMap
|
||||
* @param secondMap
|
||||
* @param removeDataInSecondMap 是否移除map2中的数据?true:移除map2中的数据 false:移除map1中的数据
|
||||
* @return
|
||||
*/
|
||||
private static List<ResponseAssertionResult> removeAssertions(Map<String, List<ResponseAssertionResult>> map1, Map<String, List<ResponseAssertionResult>> map2, boolean removeDataInMap2) {
|
||||
private static List<ResponseAssertionResult> removeAssertions(Map<String, List<ResponseAssertionResult>> firstMap, Map<String, List<ResponseAssertionResult>> secondMap, boolean removeDataInSecondMap) {
|
||||
List<ResponseAssertionResult> returnList = new ArrayList<>();
|
||||
if (MapUtils.isNotEmpty(map1) && MapUtils.isNotEmpty(map2)) {
|
||||
if (removeDataInMap2) {
|
||||
for (String regex : map1.keySet()) {
|
||||
if(map2.containsKey(regex)){
|
||||
returnList.addAll(map2.get(regex));
|
||||
map2.remove(regex);
|
||||
if (MapUtils.isNotEmpty(firstMap) && MapUtils.isNotEmpty(secondMap)) {
|
||||
if (removeDataInSecondMap) {
|
||||
for (String regex : firstMap.keySet()) {
|
||||
if (secondMap.containsKey(regex)) {
|
||||
returnList.addAll(secondMap.get(regex));
|
||||
secondMap.remove(regex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (String regex : map2.keySet()) {
|
||||
if(map1.containsKey(regex)){
|
||||
returnList.addAll(map1.get(regex));
|
||||
map1.remove(regex);
|
||||
for (String regex : secondMap.keySet()) {
|
||||
if (firstMap.containsKey(regex)) {
|
||||
returnList.addAll(firstMap.get(regex));
|
||||
firstMap.remove(regex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,6 +185,7 @@ public class ErrorReportLibraryUtil {
|
|||
|
||||
/**
|
||||
* 解析并重新格式化请求中的所有断言
|
||||
*
|
||||
* @param assertions
|
||||
* @return
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue