refacotr: 合并v1.1

This commit is contained in:
chenjianxing 2020-08-25 15:44:07 +08:00
commit 52049d61d4
8 changed files with 78 additions and 49 deletions

View File

@ -219,7 +219,7 @@
<dependency> <dependency>
<groupId>io.metersphere</groupId> <groupId>io.metersphere</groupId>
<artifactId>jmeter-plugins-dubbo</artifactId> <artifactId>jmeter-plugins-dubbo</artifactId>
<version>2.7.9</version> <version>2.7.10</version>
</dependency> </dependency>
<!-- LDAP Module --> <!-- LDAP Module -->

View File

@ -135,16 +135,21 @@ public class Swagger2Parser extends ApiImportAbstractParser {
simpleRef = refModel.getSimpleRef(); simpleRef = refModel.getSimpleRef();
} }
Model model = definitions.get(simpleRef); Model model = definitions.get(simpleRef);
JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions); HashSet<String> refSet = new HashSet<>();
refSet.add(simpleRef);
JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions, refSet);
body.setRaw(bodyParameters.toJSONString()); body.setRaw(bodyParameters.toJSONString());
} else if (schema instanceof ArrayModel) { } else if (schema instanceof ArrayModel) {
ArrayModel arrayModel = (ArrayModel) bodyParameter.getSchema(); ArrayModel arrayModel = (ArrayModel) bodyParameter.getSchema();
Property items = arrayModel.getItems(); Property items = arrayModel.getItems();
if (items instanceof RefProperty) { if (items instanceof RefProperty) {
RefProperty refProperty = (RefProperty) items; RefProperty refProperty = (RefProperty) items;
Model model = definitions.get(refProperty.getSimpleRef()); String simpleRef = refProperty.getSimpleRef();
HashSet<String> refSet = new HashSet<>();
refSet.add(simpleRef);
Model model = definitions.get(simpleRef);
JSONArray propertyList = new JSONArray(); JSONArray propertyList = new JSONArray();
propertyList.add(getBodyJSONObjectParameters(model.getProperties(), definitions)); propertyList.add(getBodyJSONObjectParameters(model.getProperties(), definitions, refSet));
body.setRaw(propertyList.toString()); body.setRaw(propertyList.toString());
} }
} }
@ -152,20 +157,26 @@ public class Swagger2Parser extends ApiImportAbstractParser {
body.setFormat("json"); body.setFormat("json");
} }
private JSONObject getBodyJSONObjectParameters(Map<String, Property> properties, Map<String, Model> definitions) { private JSONObject getBodyJSONObjectParameters(Map<String, Property> properties, Map<String, Model> definitions, HashSet<String> refSet) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
properties.forEach((key, value) -> { properties.forEach((key, value) -> {
if (value instanceof ObjectProperty) { if (value instanceof ObjectProperty) {
ObjectProperty objectProperty = (ObjectProperty) value; ObjectProperty objectProperty = (ObjectProperty) value;
jsonObject.put(key, getBodyJSONObjectParameters(objectProperty.getProperties(), definitions)); jsonObject.put(key, getBodyJSONObjectParameters(objectProperty.getProperties(), definitions, refSet));
} else if (value instanceof ArrayProperty) { } else if (value instanceof ArrayProperty) {
ArrayProperty arrayProperty = (ArrayProperty) value; ArrayProperty arrayProperty = (ArrayProperty) value;
Property items = arrayProperty.getItems(); Property items = arrayProperty.getItems();
if (items instanceof RefProperty) { if (items instanceof RefProperty) {
RefProperty refProperty = (RefProperty) items; RefProperty refProperty = (RefProperty) items;
Model model = definitions.get(refProperty.getSimpleRef()); String simpleRef = refProperty.getSimpleRef();
if (refSet.contains(simpleRef)) {
jsonObject.put(key, new JSONArray());
return;
}
refSet.add(simpleRef);
Model model = definitions.get(simpleRef);
JSONArray propertyList = new JSONArray(); JSONArray propertyList = new JSONArray();
propertyList.add(getBodyJSONObjectParameters(model.getProperties(), definitions)); propertyList.add(getBodyJSONObjectParameters(model.getProperties(), definitions, refSet));
jsonObject.put(key, propertyList); jsonObject.put(key, propertyList);
} else { } else {
jsonObject.put(key, new ArrayList<>()); jsonObject.put(key, new ArrayList<>());

View File

@ -749,13 +749,15 @@ class JMXHttpRequest {
getPostQueryParameters(request, path) { getPostQueryParameters(request, path) {
if (this.method.toUpperCase() !== "GET") { if (this.method.toUpperCase() !== "GET") {
path += '?';
let parameters = []; let parameters = [];
request.parameters.forEach(parameter => { request.parameters.forEach(parameter => {
if (parameter.name && parameter.value) { if (parameter.name && parameter.value) {
parameters.push(parameter); parameters.push(parameter);
} }
}); });
if (parameters.length > 0) {
path += '?';
}
for (let i = 0; i < parameters.length; i++) { for (let i = 0; i < parameters.length; i++) {
let parameter = parameters[i]; let parameter = parameters[i];
path += (parameter.name + '=' + parameter.value); path += (parameter.name + '=' + parameter.value);
@ -942,7 +944,7 @@ class JMXGenerator {
addBodyFormat(request) { addBodyFormat(request) {
let bodyFormat = request.body.format; let bodyFormat = request.body.format;
if (bodyFormat) { if (!request.body.isKV() && bodyFormat) {
switch (bodyFormat) { switch (bodyFormat) {
case BODY_FORMAT.JSON: case BODY_FORMAT.JSON:
this.addContentType(request, 'application/json'); this.addContentType(request, 'application/json');

View File

@ -286,4 +286,8 @@ export default {
cursor: pointer; cursor: pointer;
} }
pre {
margin: 0 0;
}
</style> </style>

View File

@ -75,13 +75,13 @@
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item prop="port" label="Port" style="padding-left: 20px"> <el-form-item prop="port" label="Port" style="padding-left: 20px">
<el-input-number v-model="item.port" :min="1" :max="9999"></el-input-number> <el-input-number v-model="item.port" :min="1" :max="65535"></el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item prop="maxConcurrency" :label="$t('test_resource_pool.max_threads')" <el-form-item prop="maxConcurrency" :label="$t('test_resource_pool.max_threads')"
style="padding-left: 20px"> style="padding-left: 20px">
<el-input-number v-model="item.maxConcurrency" :min="1" :max="9999"></el-input-number> <el-input-number v-model="item.maxConcurrency" :min="1" :max="1000000000"></el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="2"> <el-col :offset="2" :span="2">
@ -137,13 +137,13 @@
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item prop="port" label="Port" style="padding-left: 20px"> <el-form-item prop="port" label="Port" style="padding-left: 20px">
<el-input-number v-model="item.port" :min="1" :max="9999"></el-input-number> <el-input-number v-model="item.port" :min="1" :max="65535"></el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item prop="maxConcurrency" :label="$t('test_resource_pool.max_threads')" <el-form-item prop="maxConcurrency" :label="$t('test_resource_pool.max_threads')"
style="padding-left: 20px"> style="padding-left: 20px">
<el-input-number v-model="item.maxConcurrency" :min="1" :max="9999"></el-input-number> <el-input-number v-model="item.maxConcurrency" :min="1" :max="1000000000"></el-input-number>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="2"> <el-col :offset="2" :span="2">

View File

@ -141,29 +141,29 @@
<el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="35%"> <el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="35%">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-input <el-input
class="table-edit-input"
size="mini" size="mini"
v-if="!readOnly" :disabled="readOnly"
type="textarea" type="textarea"
:autosize="{ minRows: 2, maxRows: 4}" :autosize="{ minRows: 2, maxRows: 4}"
:rows="2" :rows="2"
v-model="scope.row.desc" v-model="scope.row.desc"
:placeholder="$t('commons.input_content')" :placeholder="$t('commons.input_content')"
clearable></el-input> clearable/>
<pre>{{scope.row.desc}}</pre>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="35%"> <el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="35%">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-input <el-input
class="table-edit-input"
size="mini" size="mini"
v-if="!readOnly" :disabled="readOnly"
type="textarea" type="textarea"
:autosize="{ minRows: 2, maxRows: 4}" :autosize="{ minRows: 2, maxRows: 4}"
:rows="2" :rows="2"
v-model="scope.row.result" v-model="scope.row.result"
:placeholder="$t('commons.input_content')" :placeholder="$t('commons.input_content')"
clearable></el-input> clearable/>
<pre>{{scope.row.result}}</pre>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.input_content')" min-width="15%"> <el-table-column :label="$t('commons.input_content')" min-width="15%">
@ -512,18 +512,6 @@
<style scoped> <style scoped>
.tb-edit .el-textarea {
display: none;
}
.tb-edit .current-row .el-textarea {
display: block;
}
.tb-edit .current-row .el-textarea + pre {
display: none;
}
.el-switch { .el-switch {
margin-bottom: 10px; margin-bottom: 10px;
} }

View File

@ -128,17 +128,30 @@
<el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="21%"> <el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="21%">
<template v-slot:default="scope"> <template v-slot:default="scope">
<pre>{{scope.row.desc}}</pre> <el-input
size="mini"
class="border-hidden"
type="textarea"
:autosize="{ minRows: 1, maxRows: 4}"
:disabled="true"
v-model="scope.row.desc"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="21%"> <el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="21%">
<template v-slot:default="scope"> <template v-slot:default="scope">
<pre>{{scope.row.result}}</pre> <el-input
size="mini"
class="border-hidden"
type="textarea"
:autosize="{ minRows: 1, maxRows: 4}"
:disabled="true"
v-model="scope.row.result"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('test_track.plan_view.actual_result')" min-width="21%"> <el-table-column :label="$t('test_track.plan_view.actual_result')" min-width="21%">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-input <el-input
class="table-edit-input"
size="mini" size="mini"
type="textarea" type="textarea"
:autosize="{ minRows: 2, maxRows: 4}" :autosize="{ minRows: 2, maxRows: 4}"
@ -146,8 +159,7 @@
:disabled="isReadOnly" :disabled="isReadOnly"
v-model="scope.row.actualResult" v-model="scope.row.actualResult"
:placeholder="$t('commons.input_content')" :placeholder="$t('commons.input_content')"
clearable></el-input> clearable/>
<pre>{{scope.row.actualResult}}</pre>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('test_track.plan_view.step_result')" min-width="12%"> <el-table-column :label="$t('test_track.plan_view.step_result')" min-width="12%">
@ -302,7 +314,7 @@
}, },
test: {}, test: {},
activeTab: 'detail', activeTab: 'detail',
isFailure: false, isFailure: true,
}; };
}, },
props: { props: {
@ -480,7 +492,7 @@
stepResultChange() { stepResultChange() {
if (this.testCase.method == 'manual') { if (this.testCase.method == 'manual') {
this.isFailure = this.testCase.steptResults.filter(s => { this.isFailure = this.testCase.steptResults.filter(s => {
return !s.executeResult || s.executeResult === 'Failure' || s.executeResult === 'Blocking'; return s.executeResult === 'Failure' || s.executeResult === 'Blocking';
}).length > 0; }).length > 0;
} }
@ -520,17 +532,10 @@
<style scoped> <style scoped>
.border-hidden >>> .el-textarea__inner {
.tb-edit .el-textarea { border-style: hidden;
display: none; background-color: white;
} color: #606266;
.tb-edit .current-row .el-textarea {
display: block;
}
.tb-edit .current-row .el-textarea + pre {
display: none;
} }
.cast_label { .cast_label {

View File

@ -75,3 +75,22 @@ body {
background-color: #EBEEF5; background-color: #EBEEF5;
} }
/* 表格拖拽表头调整宽度 --> */ /* 表格拖拽表头调整宽度 --> */
/* <-- 表格 input 编辑效果*/
.table-edit-input .el-textarea__inner {
border-style: hidden;
}
.table-edit-input.is-disabled .el-textarea__inner {
background-color: white;
color: #606266;
}
.el-table .current-row .table-edit-input {
border: 1px solid #DCDFE6;
border-radius: 5px;
}
.table-edit-input .el-textarea__inner:focus {
border: 1px solid #409EFF;
}
/* 表格 input 编辑效果 --> */