fix(接口定义、接口自动化、测试计划): #1006042【接口自动化】-批量复制的场景名称重复不会提示错误,提示复制成功,实际复制失败;#1006079 【接口定义】TCP 设置mock报错;#1006008 【测试计划】关联接口用例,用例路径为空

【【接口自动化】-批量复制的场景名称重复不会提示错误,提示复制成功,实际复制失败】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001006042;【【接口定义】TCP
设置mock报错】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001006079;【【测试计划】关联接口用例,用例路径为空】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001006008
This commit is contained in:
song-tianyang 2021-08-23 17:03:11 +08:00 committed by 刘瑞斌
parent 29763edbe9
commit fa1382ca67
10 changed files with 47 additions and 30 deletions

View File

@ -271,8 +271,9 @@ public class ApiAutomationController {
}
@PostMapping("/batchCopy")
public void batchCopy(@RequestBody ApiScenarioBatchRequest request) {
apiAutomationService.batchCopy(request);
public BatchOperaResponse batchCopy(@RequestBody ApiScenarioBatchRequest request) {
BatchOperaResponse response = apiAutomationService.batchCopy(request);
return response;
}

View File

@ -0,0 +1,10 @@
package io.metersphere.api.dto;
/**
* @author song.tianyang
* @Date 2021/8/23 4:17 下午
*/
public class BatchOperaResponse {
public boolean result = false;
public String errorMsg;
}

View File

@ -2364,11 +2364,12 @@ public class ApiAutomationService {
}
}
public void batchCopy(ApiScenarioBatchRequest batchRequest) {
public BatchOperaResponse batchCopy(ApiScenarioBatchRequest batchRequest) {
ServiceUtils.getSelectAllIds(batchRequest, batchRequest.getCondition(),
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
List<ApiScenarioWithBLOBs> apiScenarioList = extApiScenarioMapper.selectIds(batchRequest.getIds());
StringBuffer stringBuffer = new StringBuffer();
for (ApiScenarioWithBLOBs apiModel : apiScenarioList) {
long time = System.currentTimeMillis();
ApiScenarioWithBLOBs newModel = apiModel;
@ -2382,6 +2383,7 @@ public class ApiAutomationService {
example.createCriteria().andNameEqualTo(newModel.getName()).
andProjectIdEqualTo(newModel.getProjectId()).andStatusNotEqualTo("Trash").andIdNotEqualTo(newModel.getId());
if (apiScenarioMapper.countByExample(example) > 0) {
stringBuffer.append(newModel.getName()+";");
continue;
} else {
boolean insertFlag = true;
@ -2412,6 +2414,15 @@ public class ApiAutomationService {
}
}
}
BatchOperaResponse result = new BatchOperaResponse();
if(stringBuffer.length() == 0){
result.result = true;
}else {
result.result = false;
result.errorMsg = stringBuffer.substring(0,stringBuffer.length()-1);
}
return result;
}
public DeleteCheckResult checkBeforeDelete(ApiScenarioBatchRequest request) {

View File

@ -1168,11 +1168,9 @@ public class MockConfigService {
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
// builder.parse(message);
builder.parse(new InputSource(new ByteArrayInputStream(message.getBytes("utf-8"))));
isXml = true;
} catch (Exception e) {
e.printStackTrace();
}
return isXml;
}

View File

@ -269,9 +269,6 @@ public class TestPlanReportService {
TestPlanReportDTO returnDTO = new TestPlanReportDTO();
TestPlanReport report = testPlanReportMapper.selectByPrimaryKey(reportId);
if (report != null) {
// if (StringUtils.equalsIgnoreCase(report.getStatus(), TestPlanApiExecuteStatus.RUNNING.name())) {
// report = this.updateExecuteApis(reportId);
// }
TestPlanReportDataExample example = new TestPlanReportDataExample();
example.createCriteria().andTestPlanReportIdEqualTo(reportId);
List<TestPlanReportDataWithBLOBs> reportDataList = testPlanReportDataMapper.selectByExampleWithBLOBs(example);

View File

@ -1004,7 +1004,13 @@ export default {
let param = {};
this.buildBatchParam(param);
this.$post('/api/automation/batchCopy', param, response => {
this.$success(this.$t('api_test.definition.request.batch_copy_end'));
let copyResult = response.data;
if(copyResult.result){
this.$success(this.$t('api_test.definition.request.batch_copy_end'));
}else {
this.$error(this.$t('commons.already_exists')+":"+copyResult.errorMsg);
}
this.search();
});
}

View File

@ -23,13 +23,6 @@
label="ID"
width="80px"
sortable=true>
<!-- <template slot-scope="scope">-->
<!-- &lt;!&ndash; 判断为只读用户的话不可点击ID进行编辑操作 &ndash;&gt;-->
<!-- <span style="cursor:pointer" v-if="isReadOnly"> {{ scope.row.num }} </span>-->
<!-- <el-tooltip v-else content="编辑">-->
<!-- <a style="cursor:pointer" @click="editApi(scope.row)"> {{ scope.row.num }} </a>-->
<!-- </el-tooltip>-->
<!-- </template>-->
</ms-table-column>
<ms-table-column prop="name" width="160px" :label="$t('test_track.case.name')"/>
@ -51,12 +44,6 @@
width="180px"
:label="'API'+ $t('api_test.definition.api_path')"/>
<ms-table-column
sortable="custom"
prop="casePath"
width="180px"
:label="$t('api_test.definition.request.case')+ $t('api_test.definition.api_path')"/>
<ms-table-column prop="tags" width="120px" :label="$t('commons.tag')">
<template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"

View File

@ -250,7 +250,11 @@
this.$refs.changeHistory.open(this.httpForm.id);
},
mockSetting() {
this.$store.state.currentApiCase={mock : getUUID()};
if(this.basisData.id){
this.$store.state.currentApiCase={mock : getUUID()};
}else {
this.$alert(this.$t('api_test.mock.create_error'));
}
},
runTest() {
this.$refs['httpForm'].validate((valid) => {

View File

@ -218,7 +218,11 @@ export default {
});
},
mockSetting() {
this.$store.state.currentApiCase={mock : getUUID()};
if(this.basisData.id){
this.$store.state.currentApiCase={mock : getUUID()};
}else {
this.$alert(this.$t('api_test.mock.create_error'));
}
},
},
}

View File

@ -54,12 +54,11 @@ export let CUSTOM_TABLE_HEADER = {
{id: 'priority', key: '3', label: 'test_track.case.priority'},
{id: 'path', key: '4', label: 'api_test.definition.api_definition_path'},
{id: 'status', key: '5', label: 'test_track.plan_view.execute_result'},
{id: 'casePath', key: '6', label: 'api_test.definition.api_case_path'},
{id: 'passRate', key: '7', label: 'commons.pass_rate'},
{id: 'tags', key: '8', label: 'commons.tag'},
{id: 'createUser', key: '9', label: 'api_test.creator'},
{id: 'updateTime', key: '10', label: 'api_test.definition.api_last_time'},
{id: 'createTime', key: '11', label: 'commons.create_time'},
{id: 'passRate', key: '6', label: 'commons.pass_rate'},
{id: 'tags', key: '7', label: 'commons.tag'},
{id: 'createUser', key: '8', label: 'api_test.creator'},
{id: 'updateTime', key: '9', label: 'api_test.definition.api_last_time'},
{id: 'createTime', key: '10', label: 'commons.create_time'},
],
//场景测试
API_SCENARIO: [