parent
d032b09a08
commit
3bed3c426e
|
@ -8,6 +8,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
||||
import io.metersphere.api.dto.mockconfig.MockConfigStaticData;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.service.ApiAutomationService;
|
||||
|
@ -73,6 +74,7 @@ public class MsScenario extends MsTestElement {
|
|||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
boolean isMockEvn = false;
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
return;
|
||||
|
@ -131,6 +133,9 @@ public class MsScenario extends MsTestElement {
|
|||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
envConfig.put(projectId, env);
|
||||
if (StringUtils.equals(environment.getName(), MockConfigStaticData.MOCK_EVN_NAME)) {
|
||||
this.setMockEnvironment(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
config.setConfig(envConfig);
|
||||
|
@ -154,6 +159,7 @@ public class MsScenario extends MsTestElement {
|
|||
for (MsTestElement el : hashTree) {
|
||||
// 给所有孩子加一个父亲标志
|
||||
el.setParent(this);
|
||||
el.setMockEnvironment(this.isMockEnvironment());
|
||||
el.toHashTree(tree, el.getHashTree(), config);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -699,9 +699,13 @@ public class ApiAutomationService {
|
|||
if (StringUtils.isNotBlank(request.getRunMode()) && StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO.name())) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (ApiScenarioWithBLOBs apiScenarioWithBLOBs : apiScenarios) {
|
||||
boolean haveEnv = checkScenarioEnv(apiScenarioWithBLOBs);
|
||||
if (!haveEnv) {
|
||||
builder.append(apiScenarioWithBLOBs.getName()).append("; ");
|
||||
try {
|
||||
boolean haveEnv = checkScenarioEnv(apiScenarioWithBLOBs);
|
||||
if (!haveEnv) {
|
||||
builder.append(apiScenarioWithBLOBs.getName()).append("; ");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MSException.throwException("场景:" + builder.toString() + "运行环境未配置,请检查!");
|
||||
}
|
||||
}
|
||||
if (builder.length() > 0) {
|
||||
|
|
|
@ -169,7 +169,37 @@ public class MockConfigService {
|
|||
MockExpectConfigResponse returnModel = null;
|
||||
|
||||
if (reqJsonObj == null || reqJsonObj.isEmpty()) {
|
||||
return returnModel;
|
||||
for (MockExpectConfigResponse model : mockExpectConfigList) {
|
||||
if (!model.isStatus()) {
|
||||
continue;
|
||||
}
|
||||
JSONObject requestObj = model.getRequest();
|
||||
boolean isJsonParam = requestObj.getBoolean("jsonParam");
|
||||
JSONObject mockExpectJson = new JSONObject();
|
||||
if (isJsonParam) {
|
||||
mockExpectJson = JSONObject.parseObject(requestObj.getString("jsonData"));
|
||||
} else {
|
||||
JSONArray jsonArray = requestObj.getJSONArray("variables");
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object = jsonArray.getJSONObject(i);
|
||||
String name = "";
|
||||
String value = "";
|
||||
if (object.containsKey("name")) {
|
||||
name = String.valueOf(object.get("name")).trim();
|
||||
}
|
||||
if (object.containsKey("value")) {
|
||||
value = String.valueOf(object.get("value")).trim();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
mockExpectJson.put(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mockExpectJson.isEmpty()) {
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for (MockExpectConfigResponse model : mockExpectConfigList) {
|
||||
try {
|
||||
|
|
|
@ -252,20 +252,21 @@
|
|||
GROUP BY groupField;
|
||||
</select>
|
||||
<select id="selectLastReportByIds" resultType="io.metersphere.base.domain.ApiScenarioReport">
|
||||
SELECT report.* FROM api_scenario_report report
|
||||
SELECT report.* FROM api_scenario_report report
|
||||
INNER JOIN (
|
||||
SELECT a.id,a.createTime,a.scenario_id FROM
|
||||
(
|
||||
SELECT id AS id,create_time AS createTime, scenario_id AS scenario_id FROM api_scenario_report
|
||||
WHERE scenario_id in
|
||||
<foreach collection="scenarioIdList" item="value" separator="," open="(" close=")">
|
||||
(
|
||||
SELECT id AS id,create_time AS createTime, scenario_id AS scenario_id FROM api_scenario_report
|
||||
WHERE execute_type = 'Saved' AND scenario_id in
|
||||
<foreach collection="scenarioIdList" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
UNION
|
||||
SELECT report.id AS id,report.create_time AS createTime,planScenario.api_scenario_id AS scenario_id FROM api_scenario_report report
|
||||
INNER JOIN test_plan_api_scenario planScenario ON report.scenario_id = planScenario.id
|
||||
WHERE planScenario.api_scenario_id in
|
||||
<foreach collection="scenarioIdList" item="value" separator="," open="(" close=")">
|
||||
UNION
|
||||
SELECT report.id AS id,report.create_time AS createTime,planScenario.api_scenario_id AS scenario_id FROM
|
||||
api_scenario_report report
|
||||
INNER JOIN test_plan_api_scenario planScenario ON report.scenario_id = planScenario.id
|
||||
WHERE report.execute_type = 'Saved' AND planScenario.api_scenario_id in
|
||||
<foreach collection="scenarioIdList" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
ORDER BY createTime DESC
|
||||
|
|
Loading…
Reference in New Issue