feat (接口自动化): 完成优化需求10
--story=1002982 --user=赵勇 10.调整步骤顺序后 会... https://www.tapd.cn/55049933/s/1045288
This commit is contained in:
parent
a15a66194e
commit
faa608003c
|
@ -353,7 +353,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
if (StringUtils.isNotEmpty(useEvnId) && !StringUtils.equals(useEvnId, this.getEnvironmentId())) {
|
||||
this.setEnvironmentId(useEvnId);
|
||||
}
|
||||
HttpConfig httpConfig = getHttpConfig(config.getConfig().get(this.getProjectId()).getHttpConfig());
|
||||
HttpConfig httpConfig = matchConfig(config);
|
||||
httpConfig.setPreProcessor(environmentConfig.getPreProcessor());
|
||||
httpConfig.setPostProcessor(environmentConfig.getPostProcessor());
|
||||
return httpConfig;
|
||||
|
@ -725,10 +725,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
/**
|
||||
* 按照环境规则匹配环境
|
||||
*
|
||||
* @param httpConfig
|
||||
* @param parameterConfig
|
||||
* @return
|
||||
*/
|
||||
private HttpConfig getHttpConfig(HttpConfig httpConfig) {
|
||||
private HttpConfig matchConfig(ParameterConfig parameterConfig) {
|
||||
HttpConfig httpConfig = parameterConfig.getConfig().get(this.getProjectId()).getHttpConfig();
|
||||
boolean isNext = true;
|
||||
if (CollectionUtils.isNotEmpty(httpConfig.getConditions())) {
|
||||
for (HttpConfigCondition item : httpConfig.getConditions()) {
|
||||
|
|
|
@ -2,11 +2,16 @@ package io.metersphere.api.dto.scenario;
|
|||
|
||||
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
|
||||
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
|
||||
import io.metersphere.base.domain.ApiModule;
|
||||
import io.metersphere.base.domain.ApiModuleExample;
|
||||
import io.metersphere.base.mapper.ApiModuleMapper;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -24,6 +29,8 @@ public class HttpConfig {
|
|||
private MsJSR223PreProcessor preProcessor;
|
||||
private MsJSR223PostProcessor postProcessor;
|
||||
|
||||
private ApiModuleMapper apiModuleMapper;
|
||||
|
||||
public HttpConfig initHttpConfig(HttpConfigCondition configCondition) {
|
||||
HttpConfig config = new HttpConfig();
|
||||
config.isMock = this.isMock;
|
||||
|
@ -42,10 +49,33 @@ public class HttpConfig {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void getAllChild(String moduleId, List<String> allChild) {
|
||||
// 找出所有子模块
|
||||
if (apiModuleMapper == null) {
|
||||
apiModuleMapper = CommonBeanFactory.getBean(ApiModuleMapper.class);
|
||||
}
|
||||
allChild.add(moduleId);
|
||||
ApiModuleExample example = new ApiModuleExample();
|
||||
example.createCriteria().andParentIdEqualTo(moduleId);
|
||||
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
|
||||
for (ApiModule module : modules) {
|
||||
getAllChild(module.getId(), allChild);
|
||||
}
|
||||
}
|
||||
|
||||
public HttpConfig getModuleCondition(String moduleId, HttpConfigCondition configCondition) {
|
||||
List<String> moduleIds = new ArrayList<>();
|
||||
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)) {
|
||||
if (CollectionUtils.isEmpty(configCondition.getModuleIds())) {
|
||||
for (KeyValue keyValue : configCondition.getDetails()) {
|
||||
getAllChild(keyValue.getValue(), moduleIds);
|
||||
}
|
||||
configCondition.setModuleIds(moduleIds);
|
||||
} else {
|
||||
moduleIds = configCondition.getModuleIds();
|
||||
}
|
||||
|
||||
if (moduleIds.contains(moduleId)) {
|
||||
return initHttpConfig(configCondition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,6 @@ public class HttpConfigCondition {
|
|||
private String domain;
|
||||
private int port;
|
||||
private List<KeyValue> headers;
|
||||
|
||||
private List<String> moduleIds;
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@
|
|||
highlight-current
|
||||
@node-expand="nodeExpand"
|
||||
@node-collapse="nodeCollapse"
|
||||
:allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable ref="stepTree">
|
||||
:allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" draggable ref="stepTree">
|
||||
<span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%">
|
||||
<!-- 步骤组件-->
|
||||
<ms-component-config
|
||||
|
@ -1028,7 +1028,6 @@ export default {
|
|||
const index = hashTree.findIndex(d => d.resourceId !== undefined && row.resourceId !== undefined && d.resourceId === row.resourceId)
|
||||
hashTree.splice(index, 1);
|
||||
this.sort();
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1060,7 +1059,6 @@ export default {
|
|||
hashTree.push(obj);
|
||||
}
|
||||
this.sort();
|
||||
this.reload();
|
||||
},
|
||||
reload() {
|
||||
this.loading = true
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
<el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary"
|
||||
@click="handleCommand"> {{ $t('commons.test') }}
|
||||
</el-button>
|
||||
<el-button size="small" type="primary" class="ms-api-buttion" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
|
||||
{{ $t('report.stop_btn') }}
|
||||
</el-button>
|
||||
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
|
||||
{{ $t('commons.test') }}
|
||||
|
@ -15,6 +12,9 @@
|
|||
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<el-button size="small" type="primary" class="ms-api-buttion" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
|
||||
{{ $t('report.stop_btn') }}
|
||||
</el-button>
|
||||
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
|
||||
<div v-loading="loading">
|
||||
<!-- 请求参数 -->
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
<el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary"
|
||||
@click="handleCommand"> {{ $t('commons.test') }}
|
||||
</el-button>
|
||||
<el-button size="small" type="primary" class="ms-api-buttion" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
|
||||
{{ $t('report.stop_btn') }}
|
||||
</el-button>
|
||||
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
|
||||
{{ $t('commons.test') }}
|
||||
|
@ -15,6 +12,9 @@
|
|||
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<el-button size="small" type="primary" class="ms-api-buttion" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
|
||||
{{ $t('report.stop_btn') }}
|
||||
</el-button>
|
||||
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
|
||||
<div v-loading="loading">
|
||||
<!-- JDBC 请求参数 -->
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
<el-form-item>
|
||||
<el-button v-if="scenario" size="small" type="primary" @click="handleCommand"> {{ $t('commons.test') }}
|
||||
</el-button>
|
||||
<el-button size="small" type="primary" @click="stop" v-if="isStop">
|
||||
{{ $t('report.stop_btn') }}
|
||||
</el-button>
|
||||
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
|
||||
{{ $t('commons.test') }}
|
||||
|
@ -24,6 +21,9 @@
|
|||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<el-button size="small" type="primary" @click="stop" v-if="isStop">
|
||||
{{ $t('report.stop_btn') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-loading="loading">
|
||||
|
|
Loading…
Reference in New Issue