diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/MsDefinitionParser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/MsDefinitionParser.java index d3799f69a0..db0a5bf459 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/MsDefinitionParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/MsDefinitionParser.java @@ -9,7 +9,9 @@ import io.metersphere.api.dto.scenario.request.RequestType; import io.metersphere.api.parse.MsAbstractParser; import io.metersphere.base.domain.ApiDefinitionWithBLOBs; import io.metersphere.base.domain.ApiModule; +import io.metersphere.base.domain.ApiTestCaseWithBLOBs; import io.metersphere.commons.constants.ApiImportPlatform; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import java.io.InputStream; @@ -55,13 +57,23 @@ public class MsDefinitionParser extends MsAbstractParser { private ApiDefinitionImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) { ApiDefinitionImport apiDefinitionImport = JSON.parseObject(testStr, ApiDefinitionImport.class); + Map> caseMap = new HashMap<>(); + apiDefinitionImport.getCases().forEach(item -> { + List caseList = caseMap.get(item.getApiDefinitionId()); + if (caseList == null) { + caseList = new ArrayList<>(); + caseMap.put(item.getApiDefinitionId(), caseList); + } + caseList.add(item); + }); apiDefinitionImport.getData().forEach(apiDefinition -> { - parseApiDefinition(apiDefinition, importRequest); + parseApiDefinition(apiDefinition, importRequest, caseMap); }); return apiDefinitionImport; } - private void parseApiDefinition(ApiDefinitionWithBLOBs apiDefinition, ApiTestImportRequest importRequest) { + private void parseApiDefinition(ApiDefinitionWithBLOBs apiDefinition, ApiTestImportRequest importRequest, Map> caseMap) { + String originId = apiDefinition.getId(); String id = UUID.randomUUID().toString(); if (StringUtils.isBlank(apiDefinition.getModulePath())) { apiDefinition.setModuleId(null); @@ -73,6 +85,19 @@ public class MsDefinitionParser extends MsAbstractParser { JSONObject requestObj = JSONObject.parseObject(request); requestObj.put("id", id); apiDefinition.setRequest(JSONObject.toJSONString(requestObj)); + parseCase(caseMap, apiDefinition, importRequest, originId); + } + + private void parseCase(Map> caseMap, ApiDefinitionWithBLOBs apiDefinition, + ApiTestImportRequest importRequest, String originId) { + List cases = caseMap.get(originId); + if (CollectionUtils.isEmpty(cases)) { + return; + } + cases.forEach(item -> { + item.setApiDefinitionId(apiDefinition.getId()); + item.setProjectId(importRequest.getProjectId()); + }); } private void parseModule(String modulePath, ApiTestImportRequest importRequest, ApiDefinitionWithBLOBs apiDefinition) { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 4df858c686..52bafba745 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -572,11 +572,18 @@ public class ApiDefinitionService { } item.setNum(num++); importCreate(item, batchMapper, apiTestCaseMapper, request, apiImport.getCases()); - importMsCase(apiImport, sqlSession, apiTestCaseMapper); if (i % 300 == 0) { sqlSession.flushStatements(); } } + if (!CollectionUtils.isEmpty(apiImport.getCases())) { + for (int i = 0; i < apiImport.getCases().size(); i++) { + importMsCase(apiImport, sqlSession, apiTestCaseMapper); + if (i % 300 == 0) { + sqlSession.flushStatements(); + } + } + } sqlSession.flushStatements(); } diff --git a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java index 56b3fc682b..a9e25176e5 100644 --- a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java +++ b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java @@ -91,7 +91,7 @@ public class HistoricalDataUpgradeService { for (Request request : oldScenario.getRequests()) { // 条件控制器 MsIfController ifController = null; - if (request.getController() != null && StringUtils.isNotEmpty(request.getController().getValue()) + if (request.getController() != null && StringUtils.isNotEmpty(request.getController().getOperator()) && StringUtils.isNotEmpty(request.getController().getVariable())) { ifController = new MsIfController(); BeanUtils.copyBean(ifController, request.getController()); diff --git a/frontend/src/business/components/api/automation/scenario/common/ScenarioImport.vue b/frontend/src/business/components/api/automation/scenario/common/ScenarioImport.vue index 54aa5e4516..2aad07e5c6 100644 --- a/frontend/src/business/components/api/automation/scenario/common/ScenarioImport.vue +++ b/frontend/src/business/components/api/automation/scenario/common/ScenarioImport.vue @@ -99,7 +99,7 @@ protocol: "", platforms: [ { - name: 'Metersphere', + name: 'MeterSphere', value: 'Metersphere', tip: this.$t('api_test.api_import.ms_tip'), exportTip: this.$t('api_test.api_import.ms_export_tip'), @@ -113,14 +113,14 @@ suffixes: new Set(['json']) }, { - name: 'Jmeter', + name: 'JMeter', value: 'Jmeter', tip: this.$t('api_test.api_import.jmeter_tip'), exportTip: this.$t('api_test.api_import.jmeter_export_tip'), suffixes: new Set(['jmx']) }, { - name: 'Har', + name: 'HAR', value: 'Har', tip: this.$t('api_test.api_import.har_tip'), exportTip: this.$t('api_test.api_import.har_export_tip'), diff --git a/frontend/src/business/components/api/definition/components/import/ApiImport.vue b/frontend/src/business/components/api/definition/components/import/ApiImport.vue index 4a21594921..e4e77933fc 100644 --- a/frontend/src/business/components/api/definition/components/import/ApiImport.vue +++ b/frontend/src/business/components/api/definition/components/import/ApiImport.vue @@ -128,7 +128,7 @@ export default { protocol: "", platforms: [ { - name: 'Metersphere', + name: 'MeterSphere', value: 'Metersphere', tip: this.$t('api_test.api_import.ms_tip'), exportTip: this.$t('api_test.api_import.ms_export_tip'), @@ -149,7 +149,7 @@ export default { suffixes: new Set(['json']) }, { - name: 'Har', + name: 'HAR', value: 'Har', tip: this.$t('api_test.api_import.har_tip'), exportTip: this.$t('api_test.api_import.har_export_tip'), diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 205d5f906b..42a6bb99ab 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -327,7 +327,7 @@ export default { use_tip_tapd: 'Basic Auth account information is queried in "Company Management-Security and Integration-Open Platform"', use_tip_jira: 'Jira software server authentication information is account password, Jira software cloud authentication information is account + token (account settings-security-create API token)', use_tip_zentao: 'The account password is a Zentao account with corresponding permissions, and the account needs to have super model calling interface permissions', - use_tip_two: 'After saving the Basic Auth account information, you need to manually associate the ID/key in the Metersphere project', + use_tip_two: 'After saving the Basic Auth account information, you need to manually associate the ID/key in the MeterSphere project', link_the_project_now: 'Link the project now', cancel_edit: 'Cancel edit', cancel_integration: 'Cancel integration', @@ -437,7 +437,7 @@ export default { downloadJtl: 'Download JTL', test_execute_again: 'Test Execute Again', export: 'Export', - export_to_ms_format: 'Export to Metersphere format', + export_to_ms_format: 'Export to MeterSphere format', export_to_swagger3_format: 'Export to Swagger3.0 format', compare: 'Compare', generation_error: 'Report generation error, unable to view, please check log details!', @@ -809,7 +809,7 @@ export default { url_description: "etc: https://fit2cloud.com", path_description: "etc:/login", parameters: "Query parameters", - jmeter_func: "Jmeter Functions", + jmeter_func: "JMeter Functions", parameters_filter_example: "Example", parameters_filter_tips: "Only support MockJs function result preview", parameters_advance: "Advanced parameter settings", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index b05065d003..dc8be3bd01 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -325,7 +325,7 @@ export default { use_tip_tapd: 'Tapd Basic Auth 账号信息在"公司管理-安全与集成-开放平台"中查询', use_tip_jira: 'Jira software server 认证信息为 账号密码,Jira software cloud 认证信息为 账号+令牌(账户设置-安全-创建API令牌)', use_tip_zentao: '账号密码为具有相应权限的Zentao账号,账号需要具有 超级model调用接口权限', - use_tip_two: '保存 Basic Auth 账号信息后,需要在 Metersphere 项目中手动关联 ID/key', + use_tip_two: '保存 Basic Auth 账号信息后,需要在 MeterSphere 项目中手动关联 ID/key', link_the_project_now: '马上关联项目', cancel_edit: '取消编辑', cancel_integration: '取消集成', @@ -435,7 +435,7 @@ export default { test_execute_again: '再次执行', downloadJtl: '下载JTL', export: '导出', - export_to_ms_format: '导出 Metersphere 格式', + export_to_ms_format: '导出 MeterSphere 格式', export_to_swagger3_format: '导出 Swagger3.0 格式', compare: '比较', generation_error: '报告生成错误, 无法查看, 请检查日志详情!', @@ -810,7 +810,7 @@ export default { path_description: "例如:/login", url_invalid: "URL无效", parameters: "Query参数", - jmeter_func: "Jmeter 方法", + jmeter_func: "JMeter 方法", parameters_filter_example: "示例", parameters_filter_tips: "只支持 MockJs 函数结果预览", parameters_advance: "return", @@ -946,16 +946,16 @@ export default { file_size_limit: "文件大小不超过 20 M", tip: "说明", export_tip: "导出方法", - ms_tip: "支持 Metersphere json 格式", - ms_export_tip: "通过 Metersphere 接口测试页面或者浏览器插件导出 json 格式文件", + ms_tip: "支持 MeterSphere json 格式", + ms_export_tip: "通过 MeterSphere 接口测试页面或者浏览器插件导出 json 格式文件", har_export_tip: "通过 浏览器的开发者工具 导出 Har 格式文件", postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件", swagger_tip: "支持 Swagger 2.0 与 3.0 版本的 json 文件", har_tip: "只支持 Har 文件", post_export_tip: "通过 Postman 导出测试集合", swagger_export_tip: "通过 Swagger 页面导出", - jmeter_export_tip: "通过 Jmeter 生成JMX文件", - jmeter_tip: "支持 Jmeter 5.2版本的JMX 文件", + jmeter_export_tip: "通过 JMeter 生成JMX文件", + jmeter_tip: "支持 JMeter 5.2版本的JMX 文件", suffixFormatErr: "文件格式不符合要求", swagger_url_import: "使用URL导入", timing_synchronization: "定时同步", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index f44b918165..a0815d36b5 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -325,7 +325,7 @@ export default { use_tip_tapd: 'Tapd Basic Auth 賬號信息在"公司管理-安全與集成-開放平臺"中查詢', use_tip_jira: 'Jira software server 認證信息為 賬號密碼,Jira software cloud 認證信息為 賬號+令牌(賬戶設置-安全-創建API令牌)', use_tip_zentao: '賬號密碼為具有相應權限的Zentao賬號,賬號需要具有 超級model調用接口權限', - use_tip_two: '保存 Basic Auth 賬號信息後,需要在 Metersphere 項目中手動關聯 ID/key', + use_tip_two: '保存 Basic Auth 賬號信息後,需要在 MeterSphere 項目中手動關聯 ID/key', link_the_project_now: '馬上關聯項目', cancel_edit: '取消編輯', cancel_integration: '取消集成', @@ -435,7 +435,7 @@ export default { test_execute_again: '再次執行', downloadJtl: '下載JTL', export: '導出', - export_to_ms_format: '導出 Metersphere 格式', + export_to_ms_format: '導出 MeterSphere 格式', export_to_swagger3_format: '導出 Swagger3.0 格式', compare: '比較', generation_error: '報告生成錯誤, 無法查看, 請檢查日誌詳情!', @@ -809,7 +809,7 @@ export default { path_description: "例如:/login", url_invalid: "URL無效", parameters: "Query參數", - jmeter_func: "Jmeter 方法", + jmeter_func: "JMeter 方法", parameters_filter_example: "示例", parameters_filter_tips: "只支持 MockJs 函數結果預覽", parameters_advance: "高級參數設置", @@ -945,16 +945,16 @@ export default { file_size_limit: "文件大小不超過 20 M", tip: "說明", export_tip: "導出方法", - ms_tip: "支持 Metersphere json 格式", - ms_export_tip: "通過 Metersphere 接口測試頁面或者瀏覽器插件導出 json 格式文件", + ms_tip: "支持 MeterSphere json 格式", + ms_export_tip: "通過 MeterSphere 接口測試頁面或者瀏覽器插件導出 json 格式文件", har_export_tip: "通过 瀏覽器到開發者工具 导出 Har 格式文件", postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件", swagger_tip: "支持 Swagger 2.0 與 3.0 版本的 json 文件", har_tip: "只支持 Har 文件", post_export_tip: "通過 Postman 導出測試集合", swagger_export_tip: "通過 Swagger 頁面導出", - jmeter_export_tip: "通過 Jmeter 生成JMX文件", - jmeter_tip: "支持 Jmeter 5.2版本的JMX 文件", + jmeter_export_tip: "通過 JMeter 生成JMX文件", + jmeter_tip: "支持 JMeter 5.2版本的JMX 文件", suffixFormatErr: "文件格式不符合要求", swagger_url_import: "使用URL導入", timing_synchronization: "定時同步",