diff --git a/README.md b/README.md index 207963ad02..85c7bd0b8a 100755 --- a/README.md +++ b/README.md @@ -18,10 +18,6 @@ MeterSphere 是一站式的开源企业级持续测试平台,涵盖测试跟 > 如需进一步了解 MeterSphere 开源项目,推荐阅读 [MeterSphere 的初心和使命](https://mp.weixin.qq.com/s/DpCt3BNgBTlV3sJ5qtPmZw) -## UI 展示 - -![UI](https://metersphere.io/images/screenshot/ss01.png) - ## 在线体验 - 环境地址:https://demo.metersphere.com/ - 用户名:demo diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/request/SqlRequest.java b/backend/src/main/java/io/metersphere/api/dto/scenario/request/SqlRequest.java index bcebba7ccd..d05a479328 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/request/SqlRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/request/SqlRequest.java @@ -37,4 +37,8 @@ public class SqlRequest implements Request { private JSR223PreProcessor jsr223PreProcessor; @JSONField(ordinal = 12) private JSR223PostProcessor jsr223PostProcessor; + @JSONField(ordinal = 13) + private String resultVariable; + @JSONField(ordinal = 14) + private String variableNames; } diff --git a/backend/src/main/java/io/metersphere/api/parse/MsParser.java b/backend/src/main/java/io/metersphere/api/parse/MsParser.java index 4e9c90f5b5..065a4e8da1 100644 --- a/backend/src/main/java/io/metersphere/api/parse/MsParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/MsParser.java @@ -3,6 +3,7 @@ package io.metersphere.api.parse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.parser.Feature; import io.metersphere.api.dto.ApiTestImportRequest; import io.metersphere.api.dto.parse.ApiImport; import io.metersphere.api.dto.scenario.request.RequestType; @@ -23,7 +24,7 @@ public class MsParser extends ApiImportAbstractParser { } private String parsePluginFormat(String testStr) { - JSONObject testObject = JSONObject.parseObject(testStr); + JSONObject testObject = JSONObject.parseObject(testStr, Feature.OrderedField); if (testObject.get("scenarios") != null) { return testStr; } else { diff --git a/backend/src/main/java/io/metersphere/config/KafkaProperties.java b/backend/src/main/java/io/metersphere/config/KafkaProperties.java index 912352b24b..59c24022af 100644 --- a/backend/src/main/java/io/metersphere/config/KafkaProperties.java +++ b/backend/src/main/java/io/metersphere/config/KafkaProperties.java @@ -10,7 +10,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; public class KafkaProperties { public static final String KAFKA_PREFIX = "kafka"; - private String acks; + private String acks = "all"; private String topic; private String fields; private String timestamp; diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 6fbea3d40d..7f9135fcb9 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -81,8 +81,8 @@ public class TestPlanController { @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) - public void editTestPlan(@RequestBody TestPlan testPlan) { - testPlanService.editTestPlan(testPlan); + public void editTestPlan(@RequestBody TestPlanDTO testPlanDTO) { + testPlanService.editTestPlan(testPlanDTO); } @PostMapping("/edit/status/{planId}") diff --git a/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java b/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java index 232c77ada0..a9b9fb545f 100644 --- a/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java +++ b/backend/src/main/java/io/metersphere/track/dto/TestPlanDTO.java @@ -4,8 +4,11 @@ import io.metersphere.base.domain.TestPlan; import lombok.Getter; import lombok.Setter; +import java.util.List; + @Getter @Setter public class TestPlanDTO extends TestPlan { private String projectName; + private List projectIds; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index bdd198c510..7f95cd805d 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -34,6 +34,7 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.*; @@ -110,12 +111,51 @@ public class TestPlanService { return Optional.ofNullable(testPlanMapper.selectByPrimaryKey(testPlanId)).orElse(new TestPlan()); } - public int editTestPlan(TestPlan testPlan) { + public int editTestPlan(TestPlanDTO testPlan) { + editTestPlanProject(testPlan); testPlan.setUpdateTime(System.currentTimeMillis()); checkTestPlanExist(testPlan); return testPlanMapper.updateByPrimaryKeySelective(testPlan); } + private void editTestPlanProject(TestPlanDTO testPlan) { + List projectIds = testPlan.getProjectIds(); + if (!CollectionUtils.isEmpty(projectIds)) { + TestPlanProjectExample testPlanProjectExample1 = new TestPlanProjectExample(); + testPlanProjectExample1.createCriteria().andTestPlanIdEqualTo(testPlan.getId()); + List testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample1); + // 已经关联的项目idList + List dbProjectIds = testPlanProjects.stream().map(TestPlanProject::getProjectId).collect(Collectors.toList()); + // 修改后传过来的项目idList,如果还未关联,进行关联 + projectIds.forEach(projectId -> { + if (!dbProjectIds.contains(projectId)) { + TestPlanProject testPlanProject = new TestPlanProject(); + testPlanProject.setTestPlanId(testPlan.getId()); + testPlanProject.setProjectId(projectId); + testPlanProjectMapper.insert(testPlanProject); + } + }); + + TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample(); + testPlanProjectExample.createCriteria().andTestPlanIdEqualTo(testPlan.getId()).andProjectIdNotIn(projectIds); + testPlanProjectMapper.deleteByExample(testPlanProjectExample); + + // 关联的项目下的用例idList + TestCaseExample example = new TestCaseExample(); + example.createCriteria().andProjectIdIn(projectIds); + List caseList = testCaseMapper.selectByExample(example); + List caseIds = caseList.stream().map(TestCase::getId).collect(Collectors.toList()); + + // 取消关联所属项目下的用例和计划的关系 + TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample(); + TestPlanTestCaseExample.Criteria criteria = testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(testPlan.getId()); + if (!CollectionUtils.isEmpty(caseIds)) { + criteria.andCaseIdNotIn(caseIds); + } + testPlanTestCaseMapper.deleteByExample(testPlanTestCaseExample); + } + } + private void checkTestPlanExist(TestPlan testPlan) { if (testPlan.getName() != null) { TestPlanExample example = new TestPlanExample(); diff --git a/backend/src/main/java/io/metersphere/xmind/XmindToTestCaseParser.java b/backend/src/main/java/io/metersphere/xmind/XmindToTestCaseParser.java index 135fe835f0..699948c904 100644 --- a/backend/src/main/java/io/metersphere/xmind/XmindToTestCaseParser.java +++ b/backend/src/main/java/io/metersphere/xmind/XmindToTestCaseParser.java @@ -55,7 +55,7 @@ public class XmindToTestCaseParser { // 递归处理案例数据 private void makeXmind(StringBuffer processBuffer, Attached parent, int level, String nodePath, List attacheds) { for (Attached item : attacheds) { - if (isBlack(item.getTitle(), "(?:tc|tc)")) { // 用例 + if (isBlack(item.getTitle(), "(?:tc:|tc:|tc)")) { // 用例 item.setParent(parent); this.newTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null); } else { diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 321c869938..d5b4969642 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 321c869938357e8c2253e5bd86c963828664ae23 +Subproject commit d5b4969642fd8d10cc2f949d7377e0a0e5217a3a diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index a3a405615e..5a57cf4026 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -40,7 +40,6 @@ spring.flyway.validate-on-migrate=false spring.messages.basename=i18n/messages # kafka -kafka.acks=1 kafka.fields= kafka.timestamp=yyyy-MM-dd'T'HH:mm:ss.SSSZZ kafka.sample-filter= diff --git a/frontend/src/business/App.vue b/frontend/src/business/App.vue index 6f75a42fa0..1fb604f01a 100644 --- a/frontend/src/business/App.vue +++ b/frontend/src/business/App.vue @@ -1,5 +1,13 @@