refactor(接口测试): 重写引用场景启用或禁用后的逻辑处理
--bug=1026993 --user=赵勇 [接口测试]github24932接口自动化,场景内引用多层级场景时,设置场景步骤为“禁用”状态会失效 https://www.tapd.cn/55049933/s/1387800 Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
4e6ffc02e7
commit
77171bd45e
|
@ -1173,6 +1173,9 @@ public class ElementUtil {
|
|||
}
|
||||
|
||||
public static boolean isEnable(MsTestElement element, ParameterConfig config) {
|
||||
if (MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return true;
|
||||
}
|
||||
String path = ElementUtil.getFullIndexPath(element, "");
|
||||
if (StringUtils.isNotBlank(path) && path.endsWith("_")) {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.metersphere.utils.LoggerUtil;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.Arguments;
|
||||
|
@ -66,7 +67,7 @@ public class MsScenario extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
}
|
||||
if (this.getReferenced() != null && this.getReferenced().equals(MsTestElementConstants.Deleted.name())) {
|
||||
|
@ -215,6 +216,7 @@ public class MsScenario extends MsTestElement {
|
|||
ApiScenarioWithBLOBs scenario = apiAutomationService.selectByPrimaryKey(this.getId());
|
||||
if (scenario != null && StringUtils.isNotEmpty(scenario.getScenarioDefinition())) {
|
||||
JSONObject element = JSONUtil.parseObject(scenario.getScenarioDefinition());
|
||||
if (MapUtils.isNotEmpty(config.getKeyMap())) {
|
||||
String path = ElementUtil.getFullIndexPath(this, "");
|
||||
if (path.endsWith("_")) {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
|
@ -224,6 +226,7 @@ public class MsScenario extends MsTestElement {
|
|||
if (!enable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 历史数据处理
|
||||
ElementUtil.dataFormatting(element.optJSONArray(ElementConstants.HASH_TREE));
|
||||
this.setName(scenario.getName());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.dto.definition.request.controller;
|
||||
|
||||
import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
|
@ -7,6 +8,7 @@ import io.metersphere.plugin.core.MsTestElement;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.control.IfController;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
|
@ -33,7 +35,10 @@ public class MsIfController extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
}
|
||||
if (!ElementUtil.isEnable(this, config)) {
|
||||
return;
|
||||
}
|
||||
final HashTree groupTree = tree.add(ifController());
|
||||
|
|
|
@ -14,6 +14,7 @@ import io.metersphere.plugin.core.MsTestElement;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.control.*;
|
||||
import org.apache.jmeter.modifiers.CounterConfig;
|
||||
|
@ -46,7 +47,10 @@ public class MsLoopController extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
}
|
||||
if (!ElementUtil.isEnable(this, config)) {
|
||||
return;
|
||||
}
|
||||
final HashTree groupTree = controller(tree);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.dto.definition.request.controller;
|
||||
|
||||
import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
|
@ -8,6 +9,7 @@ import io.metersphere.plugin.core.MsTestElement;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.control.TransactionController;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
|
@ -32,10 +34,12 @@ public class MsTransactionController extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
}
|
||||
if (!ElementUtil.isEnable(this, config)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TransactionController transactionController = transactionController();
|
||||
final HashTree groupTree = tree.add(transactionController);
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import io.metersphere.utils.JMeterVars;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.protocol.java.sampler.BeanShellSampler;
|
||||
|
@ -40,8 +41,11 @@ public class MsJSR223Processor extends MsTestElement {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (!ElementUtil.isEnable(this, config)) {
|
||||
return;
|
||||
}
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
}
|
||||
this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config, this.getProjectId()));
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.plugin.core.MsTestElement;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.sampler.DebugSampler;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
|
@ -35,7 +36,7 @@ public class MsDebugSampler extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
}
|
||||
if (!ElementUtil.isEnable(this, config)) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import io.metersphere.service.definition.ApiTestCaseService;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.ConfigTestElement;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
|
@ -63,7 +64,7 @@ public class MsDubboSampler extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
} else if (config.isOperating() && StringUtils.isNotEmpty(config.getOperatingSampleTestName())) {
|
||||
this.setName(config.getOperatingSampleTestName());
|
||||
|
|
|
@ -34,6 +34,7 @@ import io.metersphere.service.definition.ApiTestCaseService;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.Arguments;
|
||||
|
@ -98,7 +99,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
|
||||
// 非导出操作,且不是启用状态则跳过执行Ms
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
} else if (config.isOperating() && StringUtils.isNotEmpty(config.getOperatingSampleTestName())) {
|
||||
this.setName(config.getOperatingSampleTestName());
|
||||
|
|
|
@ -27,6 +27,7 @@ import io.metersphere.utils.LoggerUtil;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.Arguments;
|
||||
import org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler;
|
||||
|
@ -61,7 +62,7 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
// 清理掉历史遗留数据
|
||||
this.dataSource = null;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (config != null && !config.isOperating() && !this.isEnable()) {
|
||||
if (config != null && !config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
} else if (config.isOperating() && StringUtils.isNotEmpty(config.getOperatingSampleTestName())) {
|
||||
this.setName(config.getOperatingSampleTestName());
|
||||
|
|
|
@ -29,6 +29,7 @@ import io.metersphere.utils.LoggerUtil;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.Arguments;
|
||||
import org.apache.jmeter.config.ConfigTestElement;
|
||||
|
@ -85,7 +86,7 @@ public class MsTCPSampler extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
} else if (config.isOperating() && StringUtils.isNotEmpty(config.getOperatingSampleTestName())) {
|
||||
this.setName(config.getOperatingSampleTestName());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.dto.definition.request.timer;
|
||||
|
||||
import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
|
@ -7,6 +8,7 @@ import io.metersphere.plugin.core.MsTestElement;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jmeter.timers.ConstantTimer;
|
||||
|
@ -26,7 +28,10 @@ public class MsConstantTimer extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
}
|
||||
if (!ElementUtil.isEnable(this, config)) {
|
||||
return;
|
||||
}
|
||||
final HashTree groupTree = tree.add(constantTimer());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.dto.definition.request.unknown;
|
||||
|
||||
import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
|
@ -12,6 +13,7 @@ import io.metersphere.request.BodyFile;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.config.CSVDataSet;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
|
@ -42,7 +44,10 @@ public class MsJmeterElement extends MsTestElement {
|
|||
try {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
if (!config.isOperating() && !this.isEnable() && MapUtils.isEmpty(config.getKeyMap())) {
|
||||
return;
|
||||
}
|
||||
if (!ElementUtil.isEnable(this, config)) {
|
||||
return;
|
||||
}
|
||||
InputStream inputSource = getStrToStream(jmeterElement);
|
||||
|
|
|
@ -428,7 +428,7 @@ public class ApiScenarioExecuteService {
|
|||
report.setVersionId(scenario.getVersionId());
|
||||
String scenarioDefinition = JSON.toJSONString(request.getTestElement().getHashTree().get(0).getHashTree().get(0));
|
||||
scenario.setScenarioDefinition(scenarioDefinition);
|
||||
apiScenarioReportStructureService.save(scenario, report.getId(), request.getConfig().getReportType());
|
||||
apiScenarioReportStructureService.save(scenario, report.getId(), request.getConfig().getReportType(), true);
|
||||
} else {
|
||||
if (request.getTestElement() != null && CollectionUtils.isNotEmpty(request.getTestElement().getHashTree())) {
|
||||
ApiScenarioWithBLOBs apiScenario = new ApiScenarioWithBLOBs();
|
||||
|
@ -437,7 +437,7 @@ public class ApiScenarioExecuteService {
|
|||
if (testElement != null) {
|
||||
apiScenario.setName(testElement.getName());
|
||||
apiScenario.setScenarioDefinition(JSON.toJSONString(testElement));
|
||||
apiScenarioReportStructureService.save(apiScenario, report.getId(), request.getConfig().getReportType());
|
||||
apiScenarioReportStructureService.save(apiScenario, report.getId(), request.getConfig().getReportType(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import io.metersphere.dto.ProjectJarConfig;
|
|||
import io.metersphere.dto.RunModeConfigDTO;
|
||||
import io.metersphere.environment.service.BaseEnvGroupProjectService;
|
||||
import io.metersphere.plugin.core.MsTestElement;
|
||||
import io.metersphere.service.MsHashTreeService;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.vo.BooleanPool;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
|
@ -160,9 +159,6 @@ public class GenerateHashTreeUtil {
|
|||
if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) {
|
||||
config.setRetryNum(runRequest.getRetryNum());
|
||||
}
|
||||
|
||||
Map<String, Boolean> keyMap = MsHashTreeService.getIndexKeyMap(element, "");
|
||||
config.setKeyMap(keyMap);
|
||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), config);
|
||||
|
||||
LoggerUtil.info("场景资源:" + item.getName() + ", 生成执行脚本JMX成功", runRequest.getReportId());
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.metersphere.service.definition.ApiDefinitionService;
|
|||
import io.metersphere.service.definition.ApiTestCaseService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONArray;
|
||||
|
@ -341,7 +342,7 @@ public class MsHashTreeService {
|
|||
} else {
|
||||
String indexStr = object.has(PARENT_INDEX) && StringUtils.isNotBlank(object.optString(PARENT_INDEX)) ?
|
||||
StringUtils.join(object.optString(PARENT_INDEX), "_", object.optString(INDEX)) : object.optString(INDEX);
|
||||
if (keyMap.containsKey(element.optString(ID) + indexStr)) {
|
||||
if (MapUtils.isNotEmpty(keyMap) && keyMap.containsKey(element.optString(ID) + indexStr)) {
|
||||
enable = keyMap.get(element.optString(ID) + indexStr);
|
||||
object.put(ENABLE, enable);
|
||||
}
|
||||
|
@ -373,7 +374,7 @@ public class MsHashTreeService {
|
|||
} else {
|
||||
String indexStr = element.has(PARENT_INDEX) && StringUtils.isNotBlank(element.optString(PARENT_INDEX)) ?
|
||||
StringUtils.join(element.optString(PARENT_INDEX), "_", element.optString(INDEX)) : element.optString(INDEX);
|
||||
if (keyMap.containsKey(element.optString(ID) + indexStr)) {
|
||||
if (MapUtils.isNotEmpty(keyMap) && keyMap.containsKey(element.optString(ID) + indexStr)) {
|
||||
enable = keyMap.get(element.optString(ID) + indexStr);
|
||||
element.put(ENABLE, enable);
|
||||
}
|
||||
|
@ -413,6 +414,8 @@ public class MsHashTreeService {
|
|||
setCaseEnable(element, keyMap, parentIndex);
|
||||
this.getCaseIds(element, caseIds);
|
||||
hashTree.put(i, element);
|
||||
} else {
|
||||
setCaseEnable(element, keyMap, parentIndex);
|
||||
}
|
||||
if (element.has(HASH_TREE)) {
|
||||
JSONArray elementJSONArray = element.optJSONArray(HASH_TREE);
|
||||
|
@ -437,6 +440,8 @@ public class MsHashTreeService {
|
|||
} else if (ElementConstants.REQUESTS.contains(element.optString(TYPE))) {
|
||||
setCaseEnable(element, keyMap, parentIndex);
|
||||
this.getCaseIds(element, caseIds);
|
||||
} else {
|
||||
setCaseEnable(element, keyMap, parentIndex);
|
||||
}
|
||||
if (element.has(HASH_TREE)) {
|
||||
JSONArray elementJSONArray = element.optJSONArray(HASH_TREE);
|
||||
|
@ -445,15 +450,11 @@ public class MsHashTreeService {
|
|||
}
|
||||
|
||||
private void setCaseEnable(JSONObject element, Map<String, Boolean> keyMap, String parentIndex) {
|
||||
if (element.has(ENABLE) && BooleanUtils.isFalse(element.optBoolean(ENABLE))) {
|
||||
element.put(ENABLE, false);
|
||||
} else {
|
||||
String indexStr = StringUtils.join(element.optString(ID), parentIndex, "_", element.optString(INDEX));
|
||||
if (keyMap.containsKey(indexStr)) {
|
||||
if (MapUtils.isNotEmpty(keyMap) && keyMap.containsKey(indexStr)) {
|
||||
element.put(ENABLE, keyMap.get(indexStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void caseFormatting(JSONArray hashTree, Map<String, ApiTestCaseInfo> caseMap, ParameterConfig msParameter) {
|
||||
for (int i = 0; i < hashTree.length(); i++) {
|
||||
|
|
|
@ -82,7 +82,7 @@ public class ApiScenarioReportStructureService {
|
|||
public void save(List<ApiScenarioWithBLOBs> apiScenarios, String reportId, String reportType) {
|
||||
List<StepTreeDTO> dtoList = new LinkedList<>();
|
||||
for (ApiScenarioWithBLOBs bos : apiScenarios) {
|
||||
StepTreeDTO dto = dataFormatting(bos, reportType);
|
||||
StepTreeDTO dto = dataFormatting(bos, reportType, false);
|
||||
dtoList.add(dto);
|
||||
}
|
||||
this.save(reportId, dtoList);
|
||||
|
@ -91,15 +91,22 @@ public class ApiScenarioReportStructureService {
|
|||
public List<StepTreeDTO> get(List<ApiScenarioWithBLOBs> apiScenarios, String reportType) {
|
||||
List<StepTreeDTO> dtoList = new LinkedList<>();
|
||||
for (ApiScenarioWithBLOBs bos : apiScenarios) {
|
||||
StepTreeDTO dto = dataFormatting(bos, reportType);
|
||||
StepTreeDTO dto = dataFormatting(bos, reportType, false);
|
||||
dtoList.add(dto);
|
||||
}
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
public void save(ApiScenarioWithBLOBs apiScenario, String reportId, String reportType, boolean isDebug) {
|
||||
List<StepTreeDTO> dtoList = new LinkedList<>();
|
||||
StepTreeDTO dto = dataFormatting(apiScenario, reportType, isDebug);
|
||||
dtoList.add(dto);
|
||||
this.save(reportId, dtoList);
|
||||
}
|
||||
|
||||
public void save(ApiScenarioWithBLOBs apiScenario, String reportId, String reportType) {
|
||||
List<StepTreeDTO> dtoList = new LinkedList<>();
|
||||
StepTreeDTO dto = dataFormatting(apiScenario, reportType);
|
||||
StepTreeDTO dto = dataFormatting(apiScenario, reportType, false);
|
||||
dtoList.add(dto);
|
||||
this.save(reportId, dtoList);
|
||||
}
|
||||
|
@ -142,12 +149,12 @@ public class ApiScenarioReportStructureService {
|
|||
}
|
||||
}
|
||||
|
||||
public static StepTreeDTO dataFormatting(ApiScenarioWithBLOBs apiScenario, String reportType) {
|
||||
return dataFormatting(apiScenario.getId(), apiScenario.getName(), apiScenario.getScenarioDefinition(), reportType);
|
||||
public static StepTreeDTO dataFormatting(ApiScenarioWithBLOBs apiScenario, String reportType, boolean isDebug) {
|
||||
return dataFormatting(apiScenario.getId(), apiScenario.getName(), apiScenario.getScenarioDefinition(), reportType, isDebug);
|
||||
}
|
||||
|
||||
public static StepTreeDTO dataFormatting(UiScenarioWithBLOBs uiScenario, String reportType) {
|
||||
return dataFormatting(null, uiScenario.getName(), uiScenario.getScenarioDefinition(), reportType);
|
||||
public static StepTreeDTO dataFormatting(UiScenarioWithBLOBs uiScenario, String reportType, boolean isDebug) {
|
||||
return dataFormatting(null, uiScenario.getName(), uiScenario.getScenarioDefinition(), reportType, isDebug);
|
||||
}
|
||||
|
||||
private static String combinationResourceId(JSONObject element, String reportType, String id) {
|
||||
|
@ -163,15 +170,17 @@ public class ApiScenarioReportStructureService {
|
|||
return resourceId;
|
||||
}
|
||||
|
||||
public static StepTreeDTO dataFormatting(String id, String name, String scenarioDefinition, String reportType) {
|
||||
public static StepTreeDTO dataFormatting(String id, String name, String scenarioDefinition, String reportType, boolean isDebug) {
|
||||
JSONObject element = JSONUtil.parseObject(scenarioDefinition);
|
||||
if (element != null && element.getBoolean(ENABLE)) {
|
||||
//保证场景的步骤是最新的(比如场景中包含引用场景)
|
||||
MsHashTreeService hashTreeService = CommonBeanFactory.getBean(MsHashTreeService.class);
|
||||
assert hashTreeService != null;
|
||||
List<String> caseIds = new ArrayList<>();
|
||||
Map<String, Boolean> keyMap = MsHashTreeService.getIndexKeyMap(element,element.optString(ElementConstants.INDEX));
|
||||
|
||||
Map<String, Boolean> keyMap = new HashMap<>();
|
||||
if (isDebug) {
|
||||
keyMap = MsHashTreeService.getIndexKeyMap(element, element.optString(ElementConstants.INDEX));
|
||||
}
|
||||
hashTreeService.dataFormatting(element, caseIds, keyMap);
|
||||
// 处理用例
|
||||
hashTreeService.caseFormatting(element, caseIds, null);
|
||||
|
|
|
@ -757,8 +757,7 @@ public class ApiScenarioService {
|
|||
if (StringUtils.isNotEmpty(scenarioWithBLOBs.getScenarioDefinition())) {
|
||||
JSONObject element = JSONUtil.parseObject(scenarioWithBLOBs.getScenarioDefinition());
|
||||
List<String> caseIds = new ArrayList<>();
|
||||
Map<String, Boolean> keyMap = MsHashTreeService.getIndexKeyMap(element, element.optString(ElementConstants.INDEX));
|
||||
hashTreeService.dataFormatting(element, caseIds, keyMap);
|
||||
hashTreeService.dataFormatting(element, caseIds, null);
|
||||
// 处理用例
|
||||
hashTreeService.caseFormatting(element, caseIds, getConfig(scenarioWithBLOBs));
|
||||
ElementUtil.dataFormatting(element);
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
v-model="data.enable"
|
||||
class="enable-switch"
|
||||
size="mini"
|
||||
:disabled="data.refEnable || !showVersion || isDeleted || isEnabled()" />
|
||||
:disabled="!showVersion || isDeleted || isEnabled()" />
|
||||
</el-tooltip>
|
||||
|
||||
<el-button
|
||||
|
|
|
@ -72,8 +72,7 @@
|
|||
v-if="!type"
|
||||
:disabled="true"
|
||||
type="primary"
|
||||
size="mini"
|
||||
style="background-color: var(--primary_color); border-color: var(--primary_color)">
|
||||
size="mini">
|
||||
{{ $t('api_test.request.assertions.add') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
:open-tip="$t('api_test.request.extract.json_path_suggest')"
|
||||
:clear-tip="$t('api_test.request.extract.json_path_clear')"
|
||||
@open="suggestJsonOpen"
|
||||
@clear="clearJson" />
|
||||
@clear="clearJson" :is-read-only="isReadOnly"/>
|
||||
</span>
|
||||
</el-row>
|
||||
<div class="extract-add">
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
:disabled="request.caseEnable"
|
||||
@click="add"
|
||||
type="primary"
|
||||
v-if="tabType !== 'assertionsRule'"
|
||||
style="background-color: var(--primary_color); border-color: var(--primary_color)">
|
||||
v-if="tabType !== 'assertionsRule'">
|
||||
{{ $t('api_test.request.assertions.add') }}
|
||||
</el-button>
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue