feat(接口定义): 另存新用例 TAG问题修复
This commit is contained in:
parent
0070123bef
commit
91ded7f5ba
|
@ -8,7 +8,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
@Data
|
||||
public class MsExtractCommon extends MsExtractType{
|
||||
private String variable;
|
||||
private String value; // value: ${variable}
|
||||
private String value;
|
||||
private String expression;
|
||||
private String description;
|
||||
private boolean multipleMatching;
|
||||
|
|
|
@ -417,19 +417,34 @@ public class ApiTestCaseService {
|
|||
List<ApiTestCaseWithBLOBs> bloBs = apiTestCaseMapper.selectByExampleWithBLOBs(apiDefinitionExample);
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
bloBs.forEach(apiTestCase -> {
|
||||
MsHTTPSamplerProxy req = JSON.parseObject(apiTestCase.getRequest(), MsHTTPSamplerProxy.class);
|
||||
if (StringUtils.isNotEmpty(request.getMethod())) {
|
||||
req.setMethod(request.getMethod());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(request.getPath())) {
|
||||
req.setPath(request.getPath());
|
||||
try {
|
||||
JSONObject element = JSON.parseObject(apiTestCase.getRequest());
|
||||
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
||||
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>() {
|
||||
});
|
||||
req.setHashTree(elements);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(request.getMethod())) {
|
||||
req.setMethod(request.getMethod());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(request.getPath())) {
|
||||
req.setPath(request.getPath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LogUtil.error(e.getMessage());
|
||||
}
|
||||
String requestStr = JSON.toJSONString(req);
|
||||
apiTestCase.setRequest(requestStr);
|
||||
batchMapper.updateByPrimaryKeySelective(apiTestCase);
|
||||
});
|
||||
sqlSession.flushStatements();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
singleLoading: false,
|
||||
singleRunId: "",
|
||||
runData: [],
|
||||
batchData: [],
|
||||
selectdCases: [],
|
||||
reportId: "",
|
||||
projectId: "",
|
||||
testCaseId: "",
|
||||
|
@ -128,8 +128,6 @@
|
|||
this.projectId = getCurrentProjectID();
|
||||
if (this.createCase) {
|
||||
this.sysAddition();
|
||||
} else {
|
||||
this.getApiTest();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -153,11 +151,19 @@
|
|||
this.condition.projectId = this.projectId;
|
||||
this.condition.apiDefinitionId = this.api.id;
|
||||
this.$post("/api/testcase/list", this.condition, response => {
|
||||
for (let index in response.data) {
|
||||
let test = response.data[index];
|
||||
test.request = JSON.parse(test.request);
|
||||
}
|
||||
this.apiCaseList = response.data;
|
||||
this.apiCaseList.forEach(apiCase => {
|
||||
if (apiCase.tags && apiCase.tags.length > 0) {
|
||||
apiCase.tags = JSON.parse(apiCase.tags);
|
||||
this.$set(apiCase, 'selected', false);
|
||||
}
|
||||
if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() != 'object') {
|
||||
apiCase.request = JSON.parse(apiCase.request);
|
||||
}
|
||||
if (!apiCase.request.hashTree) {
|
||||
apiCase.request.hashTree = [];
|
||||
}
|
||||
})
|
||||
this.addCase();
|
||||
});
|
||||
},
|
||||
|
@ -200,24 +206,22 @@
|
|||
this.condition.apiDefinitionId = this.api.id;
|
||||
}
|
||||
this.result = this.$post("/api/testcase/list", this.condition, response => {
|
||||
for (let index in response.data) {
|
||||
let test = response.data[index];
|
||||
test.request = JSON.parse(test.request);
|
||||
if (!test.request.hashTree) {
|
||||
test.request.hashTree = [];
|
||||
}
|
||||
}
|
||||
this.apiCaseList = response.data;
|
||||
if (addCase && this.apiCaseList.length == 0 && !this.loaded) {
|
||||
this.addCase();
|
||||
}
|
||||
this.apiCaseList.forEach(apiCase => {
|
||||
if (apiCase.tags && apiCase.tags.length > 0) {
|
||||
apiCase.tags = JSON.parse(apiCase.tags);
|
||||
this.$set(apiCase, 'selected', false);
|
||||
}
|
||||
if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() != 'object') {
|
||||
apiCase.request = JSON.parse(apiCase.request);
|
||||
}
|
||||
if (!apiCase.request.hashTree) {
|
||||
apiCase.request.hashTree = [];
|
||||
}
|
||||
})
|
||||
|
||||
if (addCase && this.apiCaseList.length == 0 && !this.loaded) {
|
||||
this.addCase();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -293,11 +297,11 @@
|
|||
if (this.apiCaseList.length > 0) {
|
||||
this.apiCaseList.forEach(item => {
|
||||
if (item.selected && item.id) {
|
||||
this.batchData.push(item.id);
|
||||
this.selectdCases.push(item.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
if (this.batchData.length == 0) {
|
||||
if (this.selectdCases.length == 0) {
|
||||
this.$warning("请选择用例!");
|
||||
return;
|
||||
}
|
||||
|
@ -306,7 +310,7 @@
|
|||
batchEdit(form) {
|
||||
let param = {};
|
||||
param[form.type] = form.value;
|
||||
param.ids = this.batchData;
|
||||
param.ids = this.selectdCases;
|
||||
param.projectId = getCurrentProjectID();
|
||||
if (this.api) {
|
||||
param.protocol = this.api.protocol;
|
||||
|
@ -316,6 +320,7 @@
|
|||
param = Object.assign(param, this.condition);
|
||||
this.$post('/api/testcase/batch/editByParam', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.selectdCases = [];
|
||||
this.getApiTest();
|
||||
});
|
||||
},
|
||||
|
|
|
@ -413,19 +413,6 @@
|
|||
this.initTable();
|
||||
});
|
||||
return;
|
||||
// }
|
||||
// this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + apiCase.name + " ?", '', {
|
||||
// confirmButtonText: this.$t('commons.confirm'),
|
||||
// callback: (action) => {
|
||||
// if (action === 'confirm') {
|
||||
// let ids = [apiCase.id];
|
||||
// this.$post('/api/testcase/removeToGc/', ids, () => {
|
||||
// this.$success(this.$t('commons.delete_success'));
|
||||
// this.initTable();
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
},
|
||||
setEnvironment(data) {
|
||||
this.environmentId = data.id;
|
||||
|
|
Loading…
Reference in New Issue