fix(接口测试): 符合误报要求的接口案例执行时将状态码的颜色与误报颜色进行匹配

--bug=1009864 --user=宋天阳 【误报库】接口执行结果为误报时,状态码颜色不对
https://www.tapd.cn/55049933/s/1096230
This commit is contained in:
song-tianyang 2022-01-22 15:23:39 +08:00 committed by song-tianyang
parent ac142ee15f
commit 0899186dc6
5 changed files with 43 additions and 35 deletions

View File

@ -211,13 +211,14 @@ public class ApiDefinitionExecResultService {
for (RequestResult item : requestResults) {
if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
//对响应内容进行进一步解析如果有附加信息比如误报库信息则根据附加信息内的数据进行其他判读
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(item);
ApiDefinitionExecResult reportResult = this.save(item, dto.getReportId(), dto.getConsole(), countExpectProcessResultCount, dto.getRunMode(), dto.getTestId(), isFirst);
String status = item.isSuccess() ? "success" : "error";
if (reportResult != null) {
status = reportResult.getStatus();
}
//对响应内容进行进一步解析如果有附加信息比如误报库信息则根据附加信息内的数据进行其他判读
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(item);
if (MapUtils.isNotEmpty(expandDTO.getAttachInfoMap())) {
status = expandDTO.getStatus();
}
@ -345,11 +346,9 @@ public class ApiDefinitionExecResultService {
if (StringUtils.isEmpty(saveResult.getActuator())) {
saveResult.setActuator("LOCAL");
}
String status = item.isSuccess() ? ExecuteResult.success.name() : ExecuteResult.error.name();
//对响应内容进行进一步解析如果有附加信息比如误报库信息则根据附加信息内的数据进行其他判读
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(item);
String status = item.isSuccess() ? ExecuteResult.success.name() : ExecuteResult.error.name();
if (MapUtils.isNotEmpty(expandDTO.getAttachInfoMap())) {
status = expandDTO.getStatus();
saveResult.setContent(JSON.toJSONString(expandDTO));

View File

@ -50,9 +50,9 @@ public class ShareInfoService {
if (request.getProjectId() == null) {
List<String> shareIdList = this.selectShareIdByShareInfoId(request.getShareId());
request.setApiIdList(shareIdList);
if(shareIdList.isEmpty()){
if (shareIdList.isEmpty()) {
return new ArrayList<>();
}else {
} else {
return extShareInfoMapper.findApiDocumentSimpleInfoByRequest(request);
}
} else {
@ -100,14 +100,14 @@ public class ShareInfoService {
if (apiModel.getRequest() != null) {
JSONObject requestObj = this.genJSONObject(apiModel.getRequest());
if(requestObj!=null){
if (requestObj != null) {
if (requestObj.containsKey("headers")) {
JSONArray requestHeadDataArr = new JSONArray();
//head赋值
JSONArray headArr = requestObj.getJSONArray("headers");
for (int index = 0; index < headArr.size(); index++) {
JSONObject headObj = headArr.getJSONObject(index);
if (headObj.containsKey("name") && headObj.containsKey("value")) {
if (headObj != null && headObj.containsKey("name") && headObj.containsKey("value")) {
requestHeadDataArr.add(headObj);
}
}
@ -116,20 +116,20 @@ public class ShareInfoService {
//url参数赋值
JSONArray urlParamArr = new JSONArray();
if (requestObj.containsKey("arguments")) {
try{
try {
JSONArray headArr = requestObj.getJSONArray("arguments");
for (int index = 0; index < headArr.size(); index++) {
JSONObject headObj = headArr.getJSONObject(index);
if (headObj.containsKey("name") && headObj.containsKey("value")) {
urlParamArr.add(headObj);
}
JSONObject headObj = headArr.getJSONObject(index);
if (headObj.containsKey("name") && headObj.containsKey("value")) {
urlParamArr.add(headObj);
}
}
}catch (Exception e){
} catch (Exception e) {
}
}
if (requestObj.containsKey("rest")) {
try{
try {
//urlParam -- rest赋值
JSONArray headArr = requestObj.getJSONArray("rest");
for (int index = 0; index < headArr.size(); index++) {
@ -138,13 +138,13 @@ public class ShareInfoService {
urlParamArr.add(headObj);
}
}
}catch (Exception e){
} catch (Exception e) {
}
}
apiInfoDTO.setUrlParams(urlParamArr.toJSONString());
//请求体参数类型
if (requestObj.containsKey("body")) {
try{
try {
JSONObject bodyObj = requestObj.getJSONObject("body");
if (bodyObj.containsKey("type")) {
String type = bodyObj.getString("type");
@ -168,7 +168,7 @@ public class ShareInfoService {
if (isJsonSchema) {
apiInfoDTO.setRequestBodyParamType("JSON-SCHEMA");
apiInfoDTO.setJsonSchemaBody(bodyObj);
if(bodyObj.containsKey("jsonSchema")){
if (bodyObj.containsKey("jsonSchema")) {
JSONObject jsonSchemaObj = bodyObj.getJSONObject("jsonSchema");
apiInfoDTO.setRequestPreviewData(JSON.parse(JSONSchemaGenerator.getJson(jsonSchemaObj.toJSONString())));
}
@ -195,7 +195,7 @@ public class ShareInfoService {
JSONObject kv = kvsArr.getJSONObject(i);
if (kv.containsKey("name")) {
String value = "";
if(kv.containsKey("value")){
if (kv.containsKey("value")) {
value = String.valueOf(kv.get("value"));
}
bodyParamArr.add(kv);
@ -238,7 +238,7 @@ public class ShareInfoService {
}
}
}
}catch (Exception e){
} catch (Exception e) {
}
@ -249,8 +249,8 @@ public class ShareInfoService {
//赋值响应头
if (apiModel.getResponse() != null) {
JSONObject responseJsonObj = this.genJSONObject(apiModel.getResponse());
if (responseJsonObj!=null && responseJsonObj.containsKey("headers")) {
try{
if (responseJsonObj != null && responseJsonObj.containsKey("headers")) {
try {
JSONArray responseHeadDataArr = new JSONArray();
JSONArray headArr = responseJsonObj.getJSONArray("headers");
for (int index = 0; index < headArr.size(); index++) {
@ -260,12 +260,12 @@ public class ShareInfoService {
}
}
apiInfoDTO.setResponseHead(responseHeadDataArr.toJSONString());
}catch (Exception e){
} catch (Exception e) {
}
}
// 赋值响应体
if (responseJsonObj!=null && responseJsonObj.containsKey("body")) {
if (responseJsonObj != null && responseJsonObj.containsKey("body")) {
try {
JSONObject bodyObj = responseJsonObj.getJSONObject("body");
if (bodyObj.containsKey("type")) {
@ -343,13 +343,13 @@ public class ShareInfoService {
}
}
}
}catch (Exception e){
} catch (Exception e) {
}
}
// 赋值响应码
if (responseJsonObj!=null && responseJsonObj.containsKey("statusCode")) {
if (responseJsonObj != null && responseJsonObj.containsKey("statusCode")) {
try {
JSONArray responseStatusDataArr = new JSONArray();
JSONArray statusArr = responseJsonObj.getJSONArray("statusCode");
@ -360,13 +360,13 @@ public class ShareInfoService {
}
}
apiInfoDTO.setResponseCode(responseStatusDataArr.toJSONString());
}catch (Exception e){
} catch (Exception e) {
}
}
}
}
if(!previewJsonArray.isEmpty()){
if (!previewJsonArray.isEmpty()) {
apiInfoDTO.setRequestPreviewData(previewJsonArray);
}
apiInfoDTO.setSelectedFlag(true);
@ -375,9 +375,9 @@ public class ShareInfoService {
private JSONObject genJSONObject(String request) {
JSONObject returnObj = null;
try{
try {
returnObj = JSONObject.parseObject(request);
}catch (Exception e){
} catch (Exception e) {
}
return returnObj;
}
@ -417,6 +417,7 @@ public class ShareInfoService {
/**
* 生成分享连接
* 如果该数据有连接则返回已有的连接不做有效期判断
*
* @param request
* @return
*/
@ -504,12 +505,13 @@ public class ShareInfoService {
* 若在当前类中调用请使用如下方式调用否则该方法的事务注解不生效
* ShareInfoService shareInfoService = CommonBeanFactory.getBean(ShareInfoService.class);
* shareInfoService.validateExpired(shareInfo);
*
* @param shareInfo
*/
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void validateExpired(ShareInfo shareInfo) {
// 有效期24小时
if (shareInfo == null || System.currentTimeMillis() - shareInfo.getUpdateTime() > 1000*60*60*24) {
if (shareInfo == null || System.currentTimeMillis() - shareInfo.getUpdateTime() > 1000 * 60 * 60 * 24) {
shareInfoMapper.deleteByPrimaryKey(shareInfo.getId());
MSException.throwException("连接已失效,请重新获取!");
}

View File

@ -7,7 +7,11 @@
v-if="responseResult.responseCode"
:content="responseResult.responseCode"
placement="top">
<div class="node-title" :class="response && response.success ?'ms-req-success':'ms-req-error'">
<div v-if="response.attachInfoMap && response.attachInfoMap.errorReportResult" class="node-title" :class="'ms-req-error-report-result'">
{{ responseResult && responseResult.responseCode ? responseResult.responseCode : '0' }}
</div>
<div v-else class="node-title" :class="response && response.success ?'ms-req-success':'ms-req-error'">
{{ responseResult && responseResult.responseCode ? responseResult.responseCode : '0' }}
</div>
</el-tooltip>

View File

@ -134,7 +134,10 @@
<el-link v-else-if="scope.row.execResult && scope.row.execResult === 'success'"
type="primary"
@click="getReportResult(scope.row)" v-text="getResult(scope.row.execResult)">
</el-link>
<el-link v-else-if="scope.row.execResult && scope.row.execResult === 'errorReportResult'"
style="color: #F6972A"
@click="getReportResult(scope.row)" v-text="getResult(scope.row.execResult)">
</el-link>
<div v-else v-text="getResult(scope.row.execResult)"/>

View File

@ -142,7 +142,7 @@
<el-link type="danger" @click="showReport(row)" v-if="row.lastResult === 'Fail'">
{{ $t('api_test.automation.fail') }}
</el-link>
<el-link type="danger" @click="showReport(row)" v-if="row.lastResult === 'errorReportResult'">
<el-link style="color: #F6972A" @click="showReport(row)" v-if="row.lastResult === 'errorReportResult'">
{{ $t('error_report_library.option.name') }}
</el-link>
</template>