feat: 场景用例导出
This commit is contained in:
parent
a003eb566e
commit
f42e7ac3eb
|
@ -5,6 +5,8 @@ import com.github.pagehelper.PageHelper;
|
|||
import io.metersphere.api.dto.ApiTestImportRequest;
|
||||
import io.metersphere.api.dto.JmxInfoDTO;
|
||||
import io.metersphere.api.dto.automation.*;
|
||||
import io.metersphere.api.dto.definition.ApiBatchRequest;
|
||||
import io.metersphere.api.dto.definition.ApiExportResult;
|
||||
import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.service.ApiAutomationService;
|
||||
|
@ -154,5 +156,12 @@ public class ApiAutomationController {
|
|||
public ApiDefinitionImport testCaseImport(@RequestPart(value = "file", required = false) MultipartFile file, @RequestPart("request") ApiTestImportRequest request) {
|
||||
return apiAutomationService.scenarioImport(file, request);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/export")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||
public ApiScenrioExportResult export(@RequestBody ApiScenarioBatchRequest request) {
|
||||
return apiAutomationService.export(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,6 @@ public class ApiScenarioBatchRequest extends ApiScenarioWithBLOBs {
|
|||
private List<String> ids;
|
||||
private String projectId;
|
||||
private String environmentId;
|
||||
private String executeStatus;
|
||||
private boolean notInTestPlan;
|
||||
private String planId;
|
||||
|
||||
private ApiScenarioRequest condition;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ApiScenrioExportResult {
|
||||
private String projectId;
|
||||
private String version;
|
||||
private List<ApiScenarioWithBLOBs> data;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.dto.automation;
|
||||
|
||||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
@ -8,14 +9,10 @@ import java.util.Map;
|
|||
|
||||
@Setter
|
||||
@Getter
|
||||
public class RunScenarioRequest {
|
||||
|
||||
private String id;
|
||||
public class RunScenarioRequest extends ApiScenarioWithBLOBs {
|
||||
|
||||
private String reportId;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String environmentId;
|
||||
|
||||
private String triggerMode;
|
||||
|
@ -29,28 +26,12 @@ public class RunScenarioRequest {
|
|||
|
||||
private List<String> planCaseIds;
|
||||
|
||||
private String reportUserID;
|
||||
private List<String> ids;
|
||||
|
||||
private List<String> scenarioIds;
|
||||
private String reportUserID;
|
||||
|
||||
private Map<String,String> scenarioTestPlanIdMap;
|
||||
|
||||
/**
|
||||
* isSelectAllDate:选择的数据是否是全部数据(全部数据是不受分页影响的数据)
|
||||
* filters: 数据状态
|
||||
* name:如果是全部数据,那么表格如果历经查询,查询参数是什么
|
||||
* moduleIds: 哪些模块的数据
|
||||
* unSelectIds:是否在页面上有未勾选的数据,有的话他们的ID是哪些。
|
||||
* filters/name/moduleIds/unSeelctIds 只在isSelectAllDate为true时需要。为了让程序能明确批量的范围。
|
||||
*/
|
||||
private boolean isSelectAllDate;
|
||||
|
||||
private Map<String, List<String>> filters;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<String> moduleIds;
|
||||
|
||||
private List<String> unSelectIds;
|
||||
private ApiScenarioRequest condition;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.api.dto.DeleteAPIReportRequest;
|
|||
import io.metersphere.api.dto.JmxInfoDTO;
|
||||
import io.metersphere.api.dto.automation.*;
|
||||
import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
||||
import io.metersphere.api.dto.definition.ApiExportResult;
|
||||
import io.metersphere.api.dto.definition.RunDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
|
||||
import io.metersphere.api.dto.definition.request.*;
|
||||
|
@ -443,11 +444,11 @@ public class ApiAutomationService {
|
|||
* @return
|
||||
*/
|
||||
public String run(RunScenarioRequest request) {
|
||||
List<String> ids = request.getScenarioIds();
|
||||
if (request.isSelectAllDate()) {
|
||||
ids = this.getAllScenarioIdsByFontedSelect(
|
||||
request.getModuleIds(), request.getName(), request.getProjectId(), request.getFilters(), request.getUnSelectIds());
|
||||
}
|
||||
|
||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
|
||||
|
||||
List<String> ids = request.getIds();
|
||||
//检查是否有正在执行中的情景
|
||||
this.checkScenarioIsRunnng(ids);
|
||||
List<ApiScenarioWithBLOBs> apiScenarios = extApiScenarioMapper.selectIds(ids);
|
||||
|
@ -656,11 +657,7 @@ public class ApiAutomationService {
|
|||
|
||||
public JmxInfoDTO genPerformanceTestJmx(RunScenarioRequest request) throws Exception {
|
||||
List<ApiScenarioWithBLOBs> apiScenarios = null;
|
||||
List<String> ids = request.getScenarioIds();
|
||||
if (request.isSelectAllDate()) {
|
||||
ids = this.getAllScenarioIdsByFontedSelect(
|
||||
request.getModuleIds(), request.getName(), request.getProjectId(), request.getFilters(), request.getUnSelectIds());
|
||||
}
|
||||
List<String> ids = request.getIds();
|
||||
apiScenarios = extApiScenarioMapper.selectIds(ids);
|
||||
String testName = "";
|
||||
if (!apiScenarios.isEmpty()) {
|
||||
|
@ -743,4 +740,17 @@ public class ApiAutomationService {
|
|||
create(saveReq, new ArrayList<>());
|
||||
return apiImport;
|
||||
}
|
||||
|
||||
public ApiScenrioExportResult export(ApiScenarioBatchRequest request) {
|
||||
ServiceUtils.getSelectAllIds(request, request.getCondition(),
|
||||
(query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query));
|
||||
ApiScenarioExample example = new ApiScenarioExample();
|
||||
example.createCriteria().andIdIn(request.getIds());
|
||||
List<ApiScenarioWithBLOBs> apiScenarioWithBLOBs = apiScenarioMapper.selectByExampleWithBLOBs(example);
|
||||
ApiScenrioExportResult result = new ApiScenrioExportResult();
|
||||
result.setData(apiScenarioWithBLOBs);
|
||||
result.setProjectId(request.getProjectId());
|
||||
result.setVersion(System.getenv("MS_VERSION"));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ApiScenarioTestJob extends MsScheduleJob {
|
|||
request.setProjectId(projectID);
|
||||
request.setTriggerMode(ReportTriggerMode.SCHEDULE.name());
|
||||
request.setExecuteType(ExecuteType.Saved.name());
|
||||
request.setScenarioIds(this.scenarioIds);
|
||||
request.setIds(this.scenarioIds);
|
||||
request.setReportUserID(this.userId);
|
||||
|
||||
apiAutomationService.run(request);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class TestPlanScenarioCaseService {
|
|||
scenarioIds.add(apiScenario.getApiScenarioId());
|
||||
scenarioIdApiScarionMap.put(apiScenario.getApiScenarioId(),apiScenario.getId());
|
||||
}
|
||||
request.setScenarioIds(scenarioIds);
|
||||
request.setIds(scenarioIds);
|
||||
request.setScenarioTestPlanIdMap(scenarioIdApiScarionMap);
|
||||
request.setRunMode(ApiRunMode.SCENARIO_PLAN.name());
|
||||
return apiAutomationService.run(request);
|
||||
|
|
|
@ -270,7 +270,7 @@
|
|||
this.trashEnable = data;
|
||||
},
|
||||
exportAPI() {
|
||||
this.$refs.apiScenarioList[0].exportApi();
|
||||
this.$refs.apiScenarioList.exportApi();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -614,13 +614,17 @@ export default {
|
|||
this.$emit('openScenario', item)
|
||||
},
|
||||
exportApi() {
|
||||
let param = this.buildBatchParam();
|
||||
param.protocol = this.currentProtocol;
|
||||
this.result = this.$post("/api/definition/export", param, response => {
|
||||
let param = {};
|
||||
this.buildBatchParam(param);
|
||||
this.loading = true;
|
||||
if (param.ids === undefined || param.ids.length < 1) {
|
||||
this.$warning(this.$t("api_test.automation.scenario.check_case"));
|
||||
return;
|
||||
}
|
||||
this.result = this.$post("/api/automation/export", param, response => {
|
||||
this.loading = false;
|
||||
let obj = response.data;
|
||||
obj.protocol = this.currentProtocol;
|
||||
this.buildApiPath(obj.data);
|
||||
downloadFile("Metersphere_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
|
||||
downloadFile("Metersphere_Scenario_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
let scenarioIds = [];
|
||||
scenarioIds.push(row.id);
|
||||
run.projectId = getCurrentProjectID();
|
||||
run.scenarioIds = scenarioIds;
|
||||
run.ids = scenarioIds;
|
||||
run.id = getUUID();
|
||||
run.name = row.name;
|
||||
this.$post(url, run, response => {
|
||||
|
|
|
@ -644,7 +644,8 @@ export default {
|
|||
select_principal: "Select principal",
|
||||
follow_people: "Follow people",
|
||||
select_table: "Select table",
|
||||
select_all: "Select all"
|
||||
select_all: "Select all",
|
||||
check_case: "Please check the Scene Use Case"
|
||||
},
|
||||
report_name_info: 'Please enter the registration name',
|
||||
save_case_info: 'Please save the use case first',
|
||||
|
|
|
@ -645,7 +645,8 @@ export default {
|
|||
select_principal: "请选择责任人",
|
||||
follow_people: "关注人",
|
||||
select_table: "选择可见数据",
|
||||
select_all: "选择全部数据"
|
||||
select_all: "选择全部数据",
|
||||
check_case: "请勾选场景用例"
|
||||
},
|
||||
report_name_info: '请输入报告名称',
|
||||
save_case_info: '请先保存用例',
|
||||
|
|
|
@ -644,7 +644,8 @@ export default {
|
|||
select_principal: "請選擇責任人",
|
||||
follow_people: "關註人",
|
||||
select_table: "選擇可見數據",
|
||||
select_all: "選擇全部數據"
|
||||
select_all: "選擇全部數據",
|
||||
check_case: "請勾選場景用例"
|
||||
},
|
||||
report_name_info: '請輸入報告名稱',
|
||||
save_case_info: '請先保存用例',
|
||||
|
|
Loading…
Reference in New Issue