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 7917a3f2b9..1676145df1 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -179,9 +179,8 @@ public class TestPlanService { else if (res.getStatus().equals(TestPlanStatus.Completed.name())) { res.setActualEndTime(null); } // 已完成->进行中,结束时间置空 - } - else if (!res.getStatus().equals(TestPlanStatus.Prepare.name()) && - testPlan.getStatus().equals(TestPlanStatus.Prepare.name())) { + } else if (!StringUtils.equals(res.getStatus(), TestPlanStatus.Prepare.name()) && + StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())) { res.setActualStartTime(null); res.setActualEndTime(null); } // 非未开始->未开始,时间都置空 @@ -190,7 +189,9 @@ public class TestPlanService { //已完成,写入实际完成时间 res.setActualEndTime(System.currentTimeMillis()); } - res.setStatus(testPlan.getStatus()); + if(StringUtils.isNotEmpty(testPlan.getStatus())){ + res.setStatus(testPlan.getStatus()); + } } List userIds = new ArrayList<>(); @@ -339,7 +340,7 @@ public class TestPlanService { testPlanScenarioCaseService.deleteByPlanId(planId); //删除定时任务 - scheduleService.deleteScheduleAndJobByResourceId(planId,ScheduleGroup.TEST_PLAN_TEST.name()); + scheduleService.deleteScheduleAndJobByResourceId(planId, ScheduleGroup.TEST_PLAN_TEST.name()); int num = testPlanMapper.deleteByPrimaryKey(planId); List relatedUsers = new ArrayList<>(); @@ -438,7 +439,7 @@ public class TestPlanService { } public List listTestPlanByProject(QueryTestPlanRequest request) { - List testPlans=extTestPlanMapper.list(request); + List testPlans = extTestPlanMapper.list(request); return testPlans; } @@ -785,12 +786,13 @@ public class TestPlanService { } return issues; } - public List selectTestPlanByRelevancy(QueryTestPlanRequest params){ - return extTestPlanMapper.selectTestPlanByRelevancy(params); + + public List selectTestPlanByRelevancy(QueryTestPlanRequest params) { + return extTestPlanMapper.selectTestPlanByRelevancy(params); } public String findTestProjectNameByTestPlanID(String testPlanId) { - return extTestPlanMapper.findTestProjectNameByTestPlanID(testPlanId); + return extTestPlanMapper.findTestProjectNameByTestPlanID(testPlanId); } public String findScheduleCreateUserById(String testPlanId) { @@ -878,23 +880,23 @@ public class TestPlanService { return request.getId(); } - public void run(String testPlanID,String projectID,String userId,String triggerMode){ - Map planScenarioIdMap; - Map apiTestCaseIdMap; - Map performanceIdMap; + public void run(String testPlanID, String projectID, String userId, String triggerMode) { + Map planScenarioIdMap; + Map apiTestCaseIdMap; + Map performanceIdMap; planScenarioIdMap = new LinkedHashMap<>(); apiTestCaseIdMap = new LinkedHashMap<>(); performanceIdMap = new LinkedHashMap<>(); List testPlanApiScenarioList = testPlanScenarioCaseService.getCasesByPlanId(testPlanID); - for (TestPlanApiScenario model :testPlanApiScenarioList) { - planScenarioIdMap.put(model.getApiScenarioId(),model.getId()); + for (TestPlanApiScenario model : testPlanApiScenarioList) { + planScenarioIdMap.put(model.getApiScenarioId(), model.getId()); } List testPlanApiCaseList = testPlanApiCaseService.getCasesByPlanId(testPlanID); for (TestPlanApiCase model : testPlanApiCaseList) { - apiTestCaseIdMap.put(model.getApiCaseId(),model.getId()); + apiTestCaseIdMap.put(model.getApiCaseId(), model.getId()); } LoadCaseRequest loadCaseRequest = new LoadCaseRequest(); @@ -902,24 +904,24 @@ public class TestPlanService { loadCaseRequest.setProjectId(projectID); List testPlanLoadCaseDTOList = testPlanLoadCaseService.list(loadCaseRequest); for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) { - performanceIdMap.put(dto.getId(),dto.getLoadCaseId()); + performanceIdMap.put(dto.getId(), dto.getLoadCaseId()); } LogUtil.info("-------------- start testplan schedule ----------"); TestPlanReportService testPlanReportService = CommonBeanFactory.getBean(TestPlanReportService.class); //首先创建testPlanReport,然后返回的ID重新赋值为resourceID,作为后续的参数 - TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(testPlanID,userId,triggerMode); + TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(testPlanID, userId, triggerMode); //执行接口案例任务 - for (Map.Entry entry: apiTestCaseIdMap.entrySet()) { + for (Map.Entry entry : apiTestCaseIdMap.entrySet()) { String apiCaseID = entry.getKey(); String planCaseID = entry.getValue(); ApiTestCaseWithBLOBs blobs = apiTestCaseService.get(apiCaseID); //需要更新这里来保证PlanCase的状态能正常更改 - apiTestCaseService.run(blobs,UUID.randomUUID().toString(),testPlanReport.getId(),testPlanID,ApiRunMode.SCHEDULE_API_PLAN.name()); + apiTestCaseService.run(blobs, UUID.randomUUID().toString(), testPlanReport.getId(), testPlanID, ApiRunMode.SCHEDULE_API_PLAN.name()); } //执行场景执行任务 - if(!planScenarioIdMap.isEmpty()){ + if (!planScenarioIdMap.isEmpty()) { LogUtil.info("-------------- testplan schedule ---------- api case over -----------------"); SchedulePlanScenarioExecuteRequest scenarioRequest = new SchedulePlanScenarioExecuteRequest(); String senarionReportID = UUID.randomUUID().toString(); @@ -928,7 +930,7 @@ public class TestPlanService { scenarioRequest.setProjectId(projectID); scenarioRequest.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); scenarioRequest.setExecuteType(ExecuteType.Saved.name()); - Map> testPlanScenarioIdMap = new HashMap<>(); + Map> testPlanScenarioIdMap = new HashMap<>(); testPlanScenarioIdMap.put(testPlanID, planScenarioIdMap); scenarioRequest.setTestPlanScenarioIDMap(testPlanScenarioIdMap); scenarioRequest.setReportUserID(userId); @@ -940,7 +942,7 @@ public class TestPlanService { } //执行性能测试任务 List performaneReportIDList = new ArrayList<>(); - for (Map.Entry entry: performanceIdMap.entrySet()) { + for (Map.Entry entry : performanceIdMap.entrySet()) { String id = entry.getKey(); String caseID = entry.getValue(); RunTestPlanRequest performanceRequest = new RunTestPlanRequest(); @@ -950,7 +952,7 @@ public class TestPlanService { String reportId = null; try { reportId = performanceTestService.run(performanceRequest); - if(reportId!=null){ + if (reportId != null) { performaneReportIDList.add(reportId); TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase(); @@ -958,7 +960,7 @@ public class TestPlanService { testPlanLoadCase.setLoadReportId(reportId); testPlanLoadCaseService.update(testPlanLoadCase); } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } //更新关联处的报告 @@ -968,9 +970,9 @@ public class TestPlanService { testPlanLoadCaseService.update(loadCase); } - if(!performaneReportIDList.isEmpty()){ + if (!performaneReportIDList.isEmpty()) { //性能测试时保存性能测试报告ID,在结果返回时用于捕捉并进行 - testPlanReportService.updatePerformanceInfo(testPlanReport,performaneReportIDList,ReportTriggerMode.SCHEDULE.name()); + testPlanReportService.updatePerformanceInfo(testPlanReport, performaneReportIDList, ReportTriggerMode.SCHEDULE.name()); } } } diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 566225d774..0bf1abea90 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -10,6 +10,7 @@ @sort-change="sort" @filter-change="filter" @select-all="select" @select="select" + @header-dragend="headerDragend" v-loading="loading"> @@ -20,7 +21,7 @@ @selectPageAll="isSelectDataAll(false)" @selectAll="isSelectDataAll(true)"/> - + @@ -28,7 +29,7 @@