fix(场景自动化) 增加数组数据处理

This commit is contained in:
fit2-zhao 2021-09-16 18:11:46 +08:00 committed by fit2-zhao
parent 4931c7816b
commit 8b50869490
4 changed files with 313 additions and 285 deletions

View File

@ -274,6 +274,25 @@ public class MsHTTPSamplerProxy extends MsTestElement {
addCertificate(config, httpSamplerTree); addCertificate(config, httpSamplerTree);
//增加全局前后至脚本 //增加全局前后至脚本
if (httpConfig != null) {
this.setScript(httpConfig, httpSamplerTree, config);
}
if (CollectionUtils.isNotEmpty(hashTree)) {
for (MsTestElement el : hashTree) {
if (el.getEnvironmentId() == null) {
if (this.getEnvironmentId() == null) {
el.setEnvironmentId(useEnvironment);
} else {
el.setEnvironmentId(this.getEnvironmentId());
}
}
el.toHashTree(httpSamplerTree, el.getHashTree(), config);
}
}
}
private void setScript(HttpConfig httpConfig, HashTree httpSamplerTree, ParameterConfig config) {
MsJSR223PreProcessor preProcessor = httpConfig.getPreProcessor(); MsJSR223PreProcessor preProcessor = httpConfig.getPreProcessor();
MsJSR223PostProcessor postProcessor = httpConfig.getPostProcessor(); MsJSR223PostProcessor postProcessor = httpConfig.getPostProcessor();
if (preProcessor != null) { if (preProcessor != null) {
@ -296,19 +315,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
} }
postProcessor.toHashTree(httpSamplerTree, postProcessor.getHashTree(), config); postProcessor.toHashTree(httpSamplerTree, postProcessor.getHashTree(), config);
} }
if (CollectionUtils.isNotEmpty(hashTree)) {
for (MsTestElement el : hashTree) {
if (el.getEnvironmentId() == null) {
if (this.getEnvironmentId() == null) {
el.setEnvironmentId(useEnvironment);
} else {
el.setEnvironmentId(this.getEnvironmentId());
}
}
el.toHashTree(httpSamplerTree, el.getHashTree(), config);
}
}
} }
private void initConnectAndResponseTimeout(ParameterConfig config) { private void initConnectAndResponseTimeout(ParameterConfig config) {
@ -348,7 +354,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
if (jsonArray.size() > 0) { if (jsonArray.size() > 0) {
this.authManager = jsonArray.getJSONObject(0).toJavaObject(MsAuthManager.class); this.authManager = jsonArray.getJSONObject(0).toJavaObject(MsAuthManager.class);
} }
}catch (Exception e){} } catch (Exception e) {
}
} }
if (StringUtils.isNotEmpty(useEvnId) && !StringUtils.equals(useEvnId, this.getEnvironmentId())) { if (StringUtils.isNotEmpty(useEvnId) && !StringUtils.equals(useEvnId, this.getEnvironmentId())) {
this.setEnvironmentId(useEvnId); this.setEnvironmentId(useEvnId);

View File

@ -63,19 +63,29 @@ public class HttpConfig {
} }
} }
public HttpConfig getModuleCondition(String moduleId, HttpConfigCondition configCondition) { // public HttpConfig getModuleCondition(String moduleId, HttpConfigCondition configCondition) {
List<String> moduleIds = new ArrayList<>(); // List<String> moduleIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(configCondition.getDetails())) { // if (CollectionUtils.isNotEmpty(configCondition.getDetails())) {
if (CollectionUtils.isEmpty(configCondition.getModuleIds())) { // if (CollectionUtils.isEmpty(configCondition.getModuleIds())) {
for (KeyValue keyValue : configCondition.getDetails()) { // for (KeyValue keyValue : configCondition.getDetails()) {
getAllChild(keyValue.getValue(), moduleIds); // getAllChild(keyValue.getValue(), moduleIds);
} // }
configCondition.setModuleIds(moduleIds); // configCondition.setModuleIds(moduleIds);
} else { // } else {
moduleIds = configCondition.getModuleIds(); // moduleIds = configCondition.getModuleIds();
} // }
//
// if (moduleIds.contains(moduleId)) {
// return initHttpConfig(configCondition);
// }
// }
// return null;
// }
if (moduleIds.contains(moduleId)) { public HttpConfig getModuleCondition(String moduleId, HttpConfigCondition configCondition) {
if (CollectionUtils.isNotEmpty(configCondition.getDetails())) {
List<KeyValue> details = configCondition.getDetails().stream().filter(detail -> StringUtils.contains(detail.getValue(), moduleId)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(details)) {
return initHttpConfig(configCondition); return initHttpConfig(configCondition);
} }
} }

@ -1 +1 @@
Subproject commit 6e2b1d3d7d79f985e6edf81eb593670b8da87465 Subproject commit a6a66f87a57346cdd7da22086bac5e82a7e47bdb

View File

@ -99,6 +99,7 @@
import ApiDefinitionStepButton from "../components/ApiDefinitionStepButton"; import ApiDefinitionStepButton from "../components/ApiDefinitionStepButton";
import {hasPermission} from '@/common/js/utils'; import {hasPermission} from '@/common/js/utils';
import Convert from "@/business/components/common/json-schema/convert/convert"; import Convert from "@/business/components/common/json-schema/convert/convert";
export default { export default {
name: "MsApiHttpRequestForm", name: "MsApiHttpRequestForm",
components: { components: {
@ -209,19 +210,22 @@
let index = this.request.hashTree.indexOf(row); let index = this.request.hashTree.indexOf(row);
this.request.hashTree.splice(index, 1); this.request.hashTree.splice(index, 1);
this.reload(); this.reload();
}, }
,
copyRow(row) { copyRow(row) {
let obj = JSON.parse(JSON.stringify(row)); let obj = JSON.parse(JSON.stringify(row));
obj.id = getUUID(); obj.id = getUUID();
this.request.hashTree.push(obj); this.request.hashTree.push(obj);
this.reload(); this.reload();
}, }
,
reload() { reload() {
this.isReloadData = true this.isReloadData = true
this.$nextTick(() => { this.$nextTick(() => {
this.isReloadData = false this.isReloadData = false
}) })
}, }
,
init() { init() {
if (!this.request.body) { if (!this.request.body) {
this.request.body = new Body(); this.request.body = new Body();
@ -235,17 +239,20 @@
if (!this.request.arguments) { if (!this.request.arguments) {
this.request.arguments = []; this.request.arguments = [];
} }
}, }
,
// body // body
reloadBody() { reloadBody() {
this.isBodyShow = false; this.isBodyShow = false;
this.$nextTick(() => { this.$nextTick(() => {
this.isBodyShow = true; this.isBodyShow = true;
}); });
}, }
,
batchAdd() { batchAdd() {
this.$refs.batchAddParameter.open(); this.$refs.batchAddParameter.open();
}, }
,
format(array, obj) { format(array, obj) {
if (array) { if (array) {
let isAdd = true; let isAdd = true;
@ -260,7 +267,8 @@
this.request.arguments.unshift(obj); this.request.arguments.unshift(obj);
} }
} }
}, }
,
batchSave(data) { batchSave(data) {
if (data) { if (data) {
let params = data.split("\n"); let params = data.split("\n");
@ -311,16 +319,19 @@
height: 18px; height: 18px;
border-radius: 42%; border-radius: 42%;
} }
.ms-header { .ms-header {
background: #783887; background: #783887;
color: white; color: white;
height: 18px; height: 18px;
border-radius: 42%; border-radius: 42%;
} }
.request-tabs { .request-tabs {
margin: 20px; margin: 20px;
min-height: 200px; min-height: 200px;
} }
.ms-el-link { .ms-el-link {
float: right; float: right;
margin-right: 45px; margin-right: 45px;