fix(接口用例): 接口用例创建性能测试失败、json-schema转换报错
修复接口用例创建性能测试失败、json-schema转换报错的问题
This commit is contained in:
parent
8912941bea
commit
d926da8124
|
@ -289,12 +289,26 @@ public class JSONSchemaGenerator {
|
|||
}
|
||||
|
||||
private static List<Object> analyzeEnumProperty(JsonObject object) {
|
||||
JsonArray enumValues = object.get("enum").getAsJsonArray();
|
||||
List<Object> list = new LinkedList<>();
|
||||
String jsonStr = null;
|
||||
JsonArray enumValues = null;
|
||||
try {
|
||||
enumValues = object.get("enum").getAsJsonArray();
|
||||
for (JsonElement enumValueElem : enumValues) {
|
||||
String enumValue = enumValueElem.getAsString();
|
||||
list.add(enumValue);
|
||||
}
|
||||
}catch (Exception e){
|
||||
jsonStr = object.get("enum").getAsString();
|
||||
}
|
||||
|
||||
if(jsonStr != null && list.isEmpty()){
|
||||
String [] arrs = jsonStr.split("\n");
|
||||
for (String str: arrs) {
|
||||
list.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -370,6 +370,7 @@ export default {
|
|||
this.selectedNode = node;
|
||||
this.$store.state.selectStep = data;
|
||||
this.buttonData = buttons(this);
|
||||
this.reload();
|
||||
this.initPlugins();
|
||||
},
|
||||
suggestClick(node) {
|
||||
|
|
|
@ -206,7 +206,7 @@ import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
|
|||
import MsBatchEdit from "../basis/BatchEdit";
|
||||
import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
|
||||
|
||||
import {getBodyUploadFiles, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
import {getBodyUploadFiles, getCurrentProjectID, getUUID, strMapToObj} from "@/common/js/utils";
|
||||
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
|
||||
import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns";
|
||||
import MsReferenceView from "../reference/ReferenceView";
|
||||
|
@ -230,6 +230,7 @@ import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOpe
|
|||
import ApiCaseBatchRun from "@/business/components/api/definition/components/list/ApiCaseBatchRun";
|
||||
import MsRequestResultTail from "../../../../api/definition/components/response/RequestResultTail";
|
||||
import {editApiTestCaseOrder} from "@/network/api";
|
||||
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||
|
||||
export default {
|
||||
name: "ApiCaseSimpleList",
|
||||
|
@ -960,6 +961,18 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
sortHashTree(stepArray) {
|
||||
if (stepArray) {
|
||||
for (let i in stepArray) {
|
||||
if (!stepArray[i].clazzName) {
|
||||
stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type);
|
||||
}
|
||||
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
|
||||
this.sortHashTree(stepArray[i].hashTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
createPerformance(row, environment) {
|
||||
/**
|
||||
* 思路:调用后台创建性能测试的方法,把当前案例的hashTree在后台转化为jmx并文件创建性能测试。
|
||||
|
@ -972,6 +985,7 @@ export default {
|
|||
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||
return;
|
||||
}
|
||||
let projectId = getCurrentProjectID();
|
||||
let runData = [];
|
||||
let singleLoading = true;
|
||||
row.request = JSON.parse(row.request);
|
||||
|
@ -983,17 +997,28 @@ export default {
|
|||
runData.push(row.request);
|
||||
/*触发执行操作*/
|
||||
let testPlan = new TestPlan();
|
||||
testPlan.clazzName = TYPE_TO_C.get(testPlan.type);
|
||||
let threadGroup = new ThreadGroup();
|
||||
threadGroup.clazzName = TYPE_TO_C.get(threadGroup.type);
|
||||
threadGroup.hashTree = [];
|
||||
testPlan.hashTree = [threadGroup];
|
||||
runData.forEach(item => {
|
||||
item.projectId = projectId;
|
||||
if (!item.clazzName) {
|
||||
item.clazzName = TYPE_TO_C.get(item.type);
|
||||
}
|
||||
threadGroup.hashTree.push(item);
|
||||
});
|
||||
this.sortHashTree(testPlan.hashTree);
|
||||
let reqObj = {
|
||||
id: row.id,
|
||||
testElement: testPlan,
|
||||
clazzName: this.clazzName ? this.clazzName : TYPE_TO_C.get(this.type),
|
||||
name: row.name,
|
||||
projectId: this.projectId,
|
||||
environmentMap: new Map([
|
||||
[projectId, environment.id]
|
||||
]),
|
||||
};
|
||||
let bodyFiles = getBodyUploadFiles(reqObj, runData);
|
||||
reqObj.reportId = "run";
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
<script>
|
||||
import MsReferenceView from "./ReferenceView";
|
||||
import MsTestPlanList from "../../../automation/scenario/testplan/TestPlanList";
|
||||
import {getBodyUploadFiles, getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
import {getBodyUploadFiles, getCurrentProjectID, getUUID, strMapToObj} from "@/common/js/utils";
|
||||
import TestPlan from "@/business/components/api/definition/components/jmeter/components/test-plan";
|
||||
import ThreadGroup from "@/business/components/api/definition/components/jmeter/components/thread-group";
|
||||
import {TYPE_TO_C} from "@/business/components/api/automation/scenario/Setting";
|
||||
|
||||
export default {
|
||||
name: "MsApiExtendBtns",
|
||||
|
@ -46,6 +47,18 @@
|
|||
this.$warning(this.$t('api_test.automation.save_case_info'))
|
||||
}
|
||||
},
|
||||
sortHashTree(stepArray) {
|
||||
if (stepArray) {
|
||||
for (let i in stepArray) {
|
||||
if (!stepArray[i].clazzName) {
|
||||
stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type);
|
||||
}
|
||||
if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
|
||||
this.sortHashTree(stepArray[i].hashTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
createPerformance(row) {
|
||||
/**
|
||||
* 思路:调用后台创建性能测试的方法,把当前案例的hashTree在后台转化为jmx并文件创建性能测试。
|
||||
|
@ -58,6 +71,7 @@
|
|||
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||
return;
|
||||
}
|
||||
let projectId = getCurrentProjectID();
|
||||
this.runData = [];
|
||||
this.singleLoading = true;
|
||||
this.row.request.name = this.row.id;
|
||||
|
@ -65,26 +79,33 @@
|
|||
this.runData.push(this.row.request);
|
||||
/*触发执行操作*/
|
||||
let testPlan = new TestPlan();
|
||||
testPlan.clazzName = TYPE_TO_C.get(testPlan.type);
|
||||
let threadGroup = new ThreadGroup();
|
||||
threadGroup.clazzName = TYPE_TO_C.get(threadGroup.type);
|
||||
threadGroup.hashTree = [];
|
||||
testPlan.hashTree = [threadGroup];
|
||||
this.runData.forEach(item => {
|
||||
item.projectId = projectId;
|
||||
if (!item.clazzName) {
|
||||
item.clazzName = TYPE_TO_C.get(item.type);
|
||||
}
|
||||
threadGroup.hashTree.push(item);
|
||||
})
|
||||
});
|
||||
this.sortHashTree(testPlan.hashTree);
|
||||
let reqObj = {
|
||||
id: this.row.id,
|
||||
id: row.id,
|
||||
testElement: testPlan,
|
||||
type: this.type,
|
||||
name: this.row.name,
|
||||
name: row.name,
|
||||
clazzName: this.clazzName ? this.clazzName : TYPE_TO_C.get(this.type),
|
||||
projectId: getCurrentProjectID(),
|
||||
environmentMap: new Map([
|
||||
[getCurrentProjectID(), this.environment.id]
|
||||
[projectId, this.environment.id]
|
||||
]),
|
||||
};
|
||||
|
||||
let bodyFiles = getBodyUploadFiles(reqObj, this.runData);
|
||||
reqObj.reportId = "run";
|
||||
// let url = "/api/genPerformanceTest";
|
||||
let url = "/api/genPerformanceTestXml";
|
||||
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
|
||||
let jmxObj = {};
|
||||
|
@ -105,7 +126,6 @@
|
|||
}, erro => {
|
||||
this.$emit('runRefresh', {});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,9 +85,11 @@
|
|||
}
|
||||
},
|
||||
jsonData(data) {
|
||||
let obj = {"root": data}
|
||||
this.schema = obj;
|
||||
this.body.jsonSchema = this.schema.root
|
||||
this.schema.root = {};
|
||||
this.$nextTick(() => {
|
||||
this.schema.root = data;
|
||||
this.body.jsonSchema = this.schema.root;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue