diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 4e37a95699..3686898bde 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -49,6 +49,9 @@ public class MsScenario extends MsTestElement { @JSONField(ordinal = 24) private boolean enableCookieShare; + @JSONField(ordinal = 26) + private List headers; + private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; @Override @@ -87,7 +90,7 @@ public class MsScenario extends MsTestElement { } // 场景变量和环境变量 tree.add(arguments(config)); - //this.addCsvDataSet(tree, variables); + this.addCsvDataSet(tree, variables); this.addCounter(tree, variables); this.addRandom(tree, variables); if (CollectionUtils.isNotEmpty(hashTree)) { @@ -131,6 +134,12 @@ public class MsScenario extends MsTestElement { arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") ); } + if (CollectionUtils.isNotEmpty(this.headers)) { + this.headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> + arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") + ); + } + return arguments; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index acbfa04709..2c273cfc4c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -79,13 +79,13 @@ public class MsIfController extends MsTestElement { } if (StringUtils.equals(operator, "is empty")) { - variable = "!empty(" + variable + ")"; + variable = variable + "==" + "\"\\" + this.variable + "\"" + "|| empty(" + variable + ")"; operator = ""; value = ""; } if (StringUtils.equals(operator, "is not empty")) { - variable = "empty(" + variable + ")"; + variable = variable + "!=" + "\"\\" + this.variable + "\"" + "&& !empty(" + variable + ")"; operator = ""; value = ""; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index 3d05319d2b..b22949ed2a 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -123,13 +123,13 @@ public class MsLoopController extends MsTestElement { } if (StringUtils.equals(operator, "is empty")) { - variable = "!empty(" + variable + ")"; + variable = variable + "==" + "\"\\" + this.whileController.getVariable() + "\"" + "|| empty(" + variable + ")"; operator = ""; value = ""; } if (StringUtils.equals(operator, "is not empty")) { - variable = "empty(" + variable + ")"; + variable = variable + "!=" + "\"\\" + this.whileController.getVariable() + "\"" + "&& !empty(" + variable + ")"; operator = ""; value = ""; } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 4964958aef..3de0a658c2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -62,8 +62,6 @@ public class ApiAutomationService { @Resource private ApiScenarioMapper apiScenarioMapper; @Resource - private ApiDefinitionService apiDefinitionService; - @Resource private ExtApiScenarioMapper extApiScenarioMapper; @Resource private TestPlanApiScenarioMapper testPlanApiScenarioMapper; @@ -103,13 +101,13 @@ public class ApiAutomationService { if (setDefultOrders) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); } - if(StringUtils.isNotEmpty(request.getExecuteStatus())){ - Map> statusFilter = new HashMap<>(); + if (StringUtils.isNotEmpty(request.getExecuteStatus())) { + Map> statusFilter = new HashMap<>(); List list = new ArrayList<>(); list.add("Prepare"); list.add("Underway"); list.add("Completed"); - statusFilter.put("status",list); + statusFilter.put("status", list); request.setFilters(statusFilter); } if (checkThisWeekData) { @@ -174,7 +172,7 @@ public class ApiAutomationService { apiScenarioMapper.insert(scenario); List bodyUploadIds = request.getBodyUploadIds(); - apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles); + FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); return scenario; } @@ -190,7 +188,7 @@ public class ApiAutomationService { public void update(SaveApiScenarioRequest request, List bodyFiles) { checkNameExist(request); List bodyUploadIds = request.getBodyUploadIds(); - apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles); + FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); final ApiScenarioWithBLOBs scenario = new ApiScenarioWithBLOBs(); scenario.setId(request.getId()); @@ -480,8 +478,8 @@ public class ApiAutomationService { public void checkScenarioIsRunnng(List ids) { List lastReportStatusByIds = apiReportService.selectLastReportByIds(ids); for (ApiScenarioReport report : lastReportStatusByIds) { - if(StringUtils.equals(report.getStatus(),APITestStatus.Running.name())){ - MSException.throwException(report.getName()+" Is Running!"); + if (StringUtils.equals(report.getStatus(), APITestStatus.Running.name())) { + MSException.throwException(report.getName() + " Is Running!"); } } } @@ -518,7 +516,7 @@ public class ApiAutomationService { */ public String debugRun(RunDefinitionRequest request, List bodyFiles) { List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); - apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles); + FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); EnvironmentConfig envConfig = null; if (request.getEnvironmentId() != null) { ApiTestEnvironmentWithBLOBs environment = environmentService.get(request.getEnvironmentId()); 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 66143cb04d..1b2d40aaff 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -44,7 +44,7 @@ import org.springframework.web.multipart.MultipartFile; import sun.security.util.Cache; import javax.annotation.Resource; -import java.io.*; +import java.io.File; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -131,7 +131,7 @@ public class ApiDefinitionService { public void create(SaveApiDefinitionRequest request, List bodyFiles) { List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); createTest(request); - createBodyFiles(bodyUploadIds, bodyFiles); + FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); } public void update(SaveApiDefinitionRequest request, List bodyFiles) { @@ -141,27 +141,7 @@ public class ApiDefinitionService { List bodyUploadIds = request.getBodyUploadIds(); request.setBodyUploadIds(null); updateTest(request); - createBodyFiles(bodyUploadIds, bodyFiles); - } - - public void createBodyFiles(List bodyUploadIds, List bodyFiles) { - if (CollectionUtils.isNotEmpty(bodyUploadIds) && CollectionUtils.isNotEmpty(bodyFiles)) { - File testDir = new File(BODY_FILE_DIR); - if (!testDir.exists()) { - testDir.mkdirs(); - } - for (int i = 0; i < bodyUploadIds.size(); i++) { - MultipartFile item = bodyFiles.get(i); - File file = new File(BODY_FILE_DIR + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename()); - try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) { - file.createNewFile(); - FileUtil.copyStream(in, out); - } catch (IOException e) { - LogUtil.error(e); - MSException.throwException(Translator.get("upload_fail")); - } - } - } + FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); } public void delete(String apiId) { @@ -356,10 +336,10 @@ public class ApiDefinitionService { return request; } - /** - * 导入是插件或者postman时创建用例 - * postman考虑是否有前置脚本 - */ + /** + * 导入是插件或者postman时创建用例 + * postman考虑是否有前置脚本 + */ private void importApiCase(ApiDefinitionWithBLOBs apiDefinition, ApiTestCaseMapper apiTestCaseMapper, ApiTestImportRequest apiTestImportRequest, Boolean isInsert) { try { @@ -404,7 +384,7 @@ public class ApiDefinitionService { */ public String run(RunDefinitionRequest request, List bodyFiles) { List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); - createBodyFiles(bodyUploadIds, bodyFiles); + FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); HashTree hashTree = request.getTestElement().generateHashTree(); String runMode = ApiRunMode.DEFINITION.name(); @@ -541,7 +521,7 @@ public class ApiDefinitionService { public void editApiByParam(ApiBatchRequest request) { List ids = request.getIds(); if (request.isSelectAllDate()) { - ids = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(),request.getProtocol()); + ids = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(), request.getProtocol()); } //name在这里只是查询参数 request.setName(null); @@ -605,14 +585,14 @@ public class ApiDefinitionService { public void deleteByParams(ApiDefinitionBatchProcessingRequest request) { List apiIds = request.getDataIds(); if (request.isSelectAllDate()) { - apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(),request.getProtocol()); + apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(), request.getProtocol()); } ApiDefinitionExample example = new ApiDefinitionExample(); example.createCriteria().andIdIn(apiIds); apiDefinitionMapper.deleteByExample(example); } - private List getAllApiIdsByFontedSelect(Map> filters, String name, List moduleIds, String projectId, List unSelectIds,String protocol) { + private List getAllApiIdsByFontedSelect(Map> filters, String name, List moduleIds, String projectId, List unSelectIds, String protocol) { ApiDefinitionRequest request = new ApiDefinitionRequest(); request.setFilters(filters); request.setName(name); @@ -632,7 +612,7 @@ public class ApiDefinitionService { public void removeToGcByParams(ApiDefinitionBatchProcessingRequest request) { List apiIds = request.getDataIds(); if (request.isSelectAllDate()) { - apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(),request.getProtocol()); + apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(), request.getProtocol()); } extApiDefinitionMapper.removeToGc(apiIds); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 6ccaf75c36..8360c15b4f 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -29,6 +29,7 @@ import io.metersphere.service.FileService; import io.metersphere.service.QuotaService; import io.metersphere.service.UserService; import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -38,11 +39,10 @@ import org.apache.jorphan.collections.ListedHashTree; import org.aspectj.util.FileUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; -import java.io.*; +import java.io.File; import java.util.*; import java.util.stream.Collectors; @@ -72,7 +72,7 @@ public class ApiTestCaseService { @Resource private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper; @Resource - TestPlanApiCaseMapper testPlanApiCaseMapper; + private TestPlanApiCaseMapper testPlanApiCaseMapper; private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; @@ -136,7 +136,7 @@ public class ApiTestCaseService { public ApiTestCase create(SaveApiTestCaseRequest request, List bodyFiles) { List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); ApiTestCase test = createTest(request); - createBodyFiles(test, bodyUploadIds, bodyFiles); + FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); return test; } @@ -152,31 +152,10 @@ public class ApiTestCaseService { List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); request.setBodyUploadIds(null); ApiTestCase test = updateTest(request); - createBodyFiles(test, bodyUploadIds, bodyFiles); + FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); return test; } - private void createBodyFiles(ApiTestCase test, List bodyUploadIds, List bodyFiles) { - if (bodyUploadIds.size() > 0) { - String dir = BODY_FILE_DIR + "/" + test.getId(); - File testDir = new File(dir); - if (!testDir.exists()) { - testDir.mkdirs(); - } - for (int i = 0; i < bodyUploadIds.size(); i++) { - MultipartFile item = bodyFiles.get(i); - File file = new File(testDir + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename()); - try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) { - file.createNewFile(); - FileUtil.copyStream(in, out); - } catch (IOException e) { - LogUtil.error(e); - MSException.throwException(Translator.get("upload_fail")); - } - } - } - } - public void delete(String testId) { extTestPlanTestCaseMapper.deleteByTestCaseID(testId); deleteFileByTestId(testId); @@ -279,19 +258,14 @@ public class ApiTestCaseService { } } - private void saveFile(String testId, MultipartFile file) { - final FileMetadata fileMetadata = fileService.saveFile(file); - ApiTestFile apiTestFile = new ApiTestFile(); - apiTestFile.setTestId(testId); - apiTestFile.setFileId(fileMetadata.getId()); - apiTestFileMapper.insert(apiTestFile); - } private void deleteFileByTestId(String testId) { ApiTestFileExample ApiTestFileExample = new ApiTestFileExample(); ApiTestFileExample.createCriteria().andTestIdEqualTo(testId); final List ApiTestFiles = apiTestFileMapper.selectByExample(ApiTestFileExample); - apiTestFileMapper.deleteByExample(ApiTestFileExample); + if (CollectionUtils.isNotEmpty(ApiTestFiles)) { + apiTestFileMapper.deleteByExample(ApiTestFileExample); + } if (!CollectionUtils.isEmpty(ApiTestFiles)) { final List fileIds = ApiTestFiles.stream().map(ApiTestFile::getFileId).collect(Collectors.toList()); 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 0033018d34..56b3fc682b 100644 --- a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java +++ b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java @@ -7,6 +7,7 @@ import io.metersphere.api.dto.SaveHistoricalDataUpgrade; import io.metersphere.api.dto.automation.ScenarioStatus; import io.metersphere.api.dto.definition.request.MsScenario; import io.metersphere.api.dto.definition.request.MsTestElement; +import io.metersphere.api.dto.definition.request.assertions.MsAssertionDuration; import io.metersphere.api.dto.definition.request.assertions.MsAssertions; import io.metersphere.api.dto.definition.request.controller.MsIfController; import io.metersphere.api.dto.definition.request.extract.MsExtract; @@ -84,6 +85,7 @@ public class HistoricalDataUpgradeService { scenario.setReferenced("Upgrade"); scenario.setId(oldScenario.getId()); scenario.setResourceId(UUID.randomUUID().toString()); + scenario.setHeaders(oldScenario.getHeaders()); LinkedList testElements = new LinkedList<>(); int index = 1; for (Request request : oldScenario.getRequests()) { @@ -202,6 +204,23 @@ public class HistoricalDataUpgradeService { if (StringUtils.isEmpty(msAssertions.getName())) { msAssertions.setName("Assertions"); } + // 给初始值 + if (msAssertions.getDuration() == null) { + msAssertions.setDuration(new MsAssertionDuration()); + } + if (CollectionUtils.isEmpty(msAssertions.getJsr223())) { + msAssertions.setJsr223(new LinkedList<>()); + } + if (CollectionUtils.isEmpty(msAssertions.getXpath2())) { + msAssertions.setXpath2(new LinkedList<>()); + } + if (CollectionUtils.isEmpty(msAssertions.getJsonPath())) { + msAssertions.setJsonPath(new LinkedList<>()); + } + if (CollectionUtils.isEmpty(msAssertions.getRegex())) { + msAssertions.setRegex(new LinkedList<>()); + } + msAssertions.setType("Assertions"); msAssertions.setIndex(index + ""); msAssertions.setResourceId(UUID.randomUUID().toString()); @@ -216,6 +235,16 @@ public class HistoricalDataUpgradeService { if (StringUtils.isEmpty(extract.getName())) { extract.setName("Extract"); } + // 默认给初始值 + if (CollectionUtils.isEmpty(extract.getJson())) { + extract.setJson(new LinkedList<>()); + } + if (CollectionUtils.isEmpty(extract.getXpath())) { + extract.setXpath(new LinkedList<>()); + } + if (CollectionUtils.isEmpty(extract.getRegex())) { + extract.setRegex(new LinkedList<>()); + } extract.setType("Extract"); extract.setIndex(index + ""); extract.setHashTree(new LinkedList<>()); diff --git a/backend/src/main/java/io/metersphere/commons/utils/FileUtils.java b/backend/src/main/java/io/metersphere/commons/utils/FileUtils.java new file mode 100644 index 0000000000..01830daeab --- /dev/null +++ b/backend/src/main/java/io/metersphere/commons/utils/FileUtils.java @@ -0,0 +1,34 @@ +package io.metersphere.commons.utils; + +import io.metersphere.commons.exception.MSException; +import io.metersphere.i18n.Translator; +import org.apache.commons.collections.CollectionUtils; +import org.aspectj.util.FileUtil; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.util.List; + +public class FileUtils { + private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; + + public static void createBodyFiles(List bodyUploadIds, List bodyFiles) { + if (CollectionUtils.isNotEmpty(bodyUploadIds) && CollectionUtils.isNotEmpty(bodyFiles)) { + File testDir = new File(BODY_FILE_DIR); + if (!testDir.exists()) { + testDir.mkdirs(); + } + for (int i = 0; i < bodyUploadIds.size(); i++) { + MultipartFile item = bodyFiles.get(i); + File file = new File(BODY_FILE_DIR + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename()); + try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) { + file.createNewFile(); + FileUtil.copyStream(in, out); + } catch (IOException e) { + LogUtil.error(e); + MSException.throwException(Translator.get("upload_fail")); + } + } + } + } +} diff --git a/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java b/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java index 411ccc6c42..6534abf2fe 100644 --- a/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java +++ b/backend/src/main/java/io/metersphere/controller/handler/RestControllerExceptionHandler.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.sql.SQLException; @RestControllerAdvice @@ -30,6 +31,12 @@ public class RestControllerExceptionHandler { } + @ExceptionHandler(SQLException.class) + public ResultHolder sqlExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) { + response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); + return ResultHolder.error("SQL error happened, please check logs."); + } + @ExceptionHandler(MSException.class) public ResultHolder msExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) { response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java index 5f41d6c6b1..fedd336094 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java @@ -180,14 +180,16 @@ public class TestCaseNodeService extends NodeTreeService { List projectIds = testPlanProjectService.getProjectIdsByPlanId(planId); projectIds.forEach(id -> { Project project = projectMapper.selectByPrimaryKey(id); - String name = project.getName(); - List nodeList = getNodeDTO(id, planId); - TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO(); - testCaseNodeDTO.setId(project.getId()); - testCaseNodeDTO.setName(name); - testCaseNodeDTO.setLabel(name); - testCaseNodeDTO.setChildren(nodeList); - list.add(testCaseNodeDTO); + if (project != null) { + String name = project.getName(); + List nodeList = getNodeDTO(id, planId); + TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO(); + testCaseNodeDTO.setId(project.getId()); + testCaseNodeDTO.setName(name); + testCaseNodeDTO.setLabel(name); + testCaseNodeDTO.setChildren(nodeList); + list.add(testCaseNodeDTO); + } }); return list; diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java index ee74dd65b5..bb8b69ee18 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java @@ -62,15 +62,16 @@ public class TestPlanProjectService { } public List getPlanIdByProjectId(String projectId) { - TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample(); - testPlanProjectExample.createCriteria().andProjectIdEqualTo(projectId); - List testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample); - if (CollectionUtils.isEmpty(testPlanProjects)) { + TestPlanExample testPlanExample = new TestPlanExample(); + testPlanExample.createCriteria().andProjectIdEqualTo(projectId); + List testPlans = testPlanMapper.selectByExample(testPlanExample); + + if (CollectionUtils.isEmpty(testPlans)) { return null; } - return testPlanProjects + return testPlans .stream() - .map(TestPlanProject::getTestPlanId) + .map(TestPlan::getId) .collect(Collectors.toList()); } } diff --git a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java index 1dab92a9f8..a2e5645e8c 100644 --- a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java +++ b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java @@ -277,12 +277,16 @@ public class XmindCaseParser { String tc = title.replace(":", ":"); String[] tcArr = tc.split(":"); - if (tcArr.length != 2) { + if (tcArr.length < 1) { process.add(Translator.get("test_case_name") + Translator.get("incorrect_format"), title); return; } // 用例名称 - testCase.setName(this.replace(tcArr[1], TC_REGEX)); + StringBuffer name = new StringBuffer(); + for (int i = 1; i < tcArr.length; i++) { + name.append(tcArr[i]); + } + testCase.setName(name.toString()); testCase.setNodePath(nodePath); // 用例等级和用例性质处理 diff --git a/backend/src/main/resources/db/migration/V74__modify_schedule_message_task.sql b/backend/src/main/resources/db/migration/V74__modify_schedule_message_task.sql new file mode 100644 index 0000000000..695c6b2f11 --- /dev/null +++ b/backend/src/main/resources/db/migration/V74__modify_schedule_message_task.sql @@ -0,0 +1,4 @@ +ALTER TABLE schedule + MODIFY COLUMN id VARCHAR (255); +ALTER TABLE message_task + MODIFY COLUMN id VARCHAR (255); diff --git a/backend/src/main/resources/db/migration/V75__modify_schedule_message_task_test_id.sql b/backend/src/main/resources/db/migration/V75__modify_schedule_message_task_test_id.sql new file mode 100644 index 0000000000..b1092b7e3f --- /dev/null +++ b/backend/src/main/resources/db/migration/V75__modify_schedule_message_task_test_id.sql @@ -0,0 +1,4 @@ +ALTER TABLE schedule + MODIFY COLUMN resource_id VARCHAR (255); +ALTER TABLE message_task + MODIFY COLUMN test_id VARCHAR (255); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 21ffb284f9..d769d6c275 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -106,7 +106,7 @@ {{$t('api_test.automation.scenario_total')}} - :{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length: 0}} + :{{ getVariableSize() }} 共享cookie @@ -196,7 +196,7 @@ - + @@ -204,37 +204,44 @@ diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index bab86e7b27..695a5a4300 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -3,6 +3,7 @@ v-loading="loading" @copy="copyRow" @remove="remove" + @active="active" :is-show-name-input="!isDeletedOrRef" :data="request" :draggable="true" @@ -27,47 +28,60 @@ -

{{$t('api_test.definition.request.req_param')}}

- +

{{ $t('api_test.definition.request.req_param') }}

+ - - + + -

{{$t('api_test.definition.request.res_param')}}

- +

{{ $t('api_test.definition.request.res_param') }}

+
+ + +
+ +
+
+
+
+ - - {{$t('commons.save')}} + + {{ $t('commons.save') }} diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index 85a6931c48..5a33484e08 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -79,17 +79,17 @@ ms -

{{$t('api_test.definition.request.res_param')}}

-
- - -
- -
-
-
+ + + + + + + + + -
+ @@ -97,27 +97,27 @@ diff --git a/frontend/src/business/components/api/definition/components/assertion/ApiAssertions.vue b/frontend/src/business/components/api/definition/components/assertion/ApiAssertions.vue index 82626640a9..3bf78dbd8c 100644 --- a/frontend/src/business/components/api/definition/components/assertion/ApiAssertions.vue +++ b/frontend/src/business/components/api/definition/components/assertion/ApiAssertions.vue @@ -52,31 +52,31 @@