refactor(UI自动化): 报告error代码可读性

This commit is contained in:
zhangdahai112 2022-09-13 19:14:29 +08:00 committed by f2c-ci-robot[bot]
parent bc6ed06cce
commit b97f224e0d

View File

@ -992,17 +992,19 @@ public class ApiScenarioReportService {
*/
private long getUiErrorSize(ResultDTO dto) {
int errorSize = 0;
boolean success = false;
String processType = null;
String cmdName = null;
for (RequestResult r : dto.getRequestResults()) {
if (StringUtils.isNotEmpty(r.getResponseResult().getHeaders())) {
JSONArray responseArr = JSONArray.parseArray(r.getResponseResult().getHeaders());
for (int i = 0; i < responseArr.size(); i++) {
JSONObject stepResult = responseArr.getJSONObject(i);
if (stepResult.containsKey("success") && !stepResult.getBoolean("success")) {
if ((stepResult.containsKey("processType") && StringUtils.equalsIgnoreCase("MAIN", stepResult.getString("processType")))
|| (stepResult.containsKey("cmdName")
&& ((stepResult.getString("cmdName").startsWith("verify")) || stepResult.getString("cmdName").startsWith("assert")))) {
errorSize++;
}
success = Optional.ofNullable(stepResult.getBoolean("success")).orElse(Boolean.FALSE);
processType = Optional.ofNullable(stepResult.getString("processType")).orElse("");
cmdName = Optional.ofNullable(stepResult.getString("cmdName")).orElse("");
if (!success && (StringUtils.equalsIgnoreCase("MAIN", processType) || cmdName.startsWith("verify") || cmdName.startsWith("assert"))) {
errorSize++;
}
}
}