fix(测试用例(xmind导入)、测试计划执行): #1003262 修复测试用例xmind导入时页面脑图排序问题;测试计划执行时获取不到执行人的问题
【【github#2656】xmind用例导入后,MeterSphere中脑图和本地文件顺序相反】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001003262
This commit is contained in:
parent
dc457c754c
commit
540b73cd5d
|
@ -21,6 +21,7 @@ import java.util.Map;
|
|||
@Setter
|
||||
public class TestPlanExecuteInfo {
|
||||
private String reportId;
|
||||
private String creator;
|
||||
private Map<String, String> apiCaseExecInfo = new HashMap<>();
|
||||
private Map<String, String> apiScenarioCaseExecInfo = new HashMap<>();
|
||||
private Map<String, String> loadCaseExecInfo = new HashMap<>();
|
||||
|
@ -38,6 +39,11 @@ public class TestPlanExecuteInfo {
|
|||
private boolean isScenarioAllExecuted;
|
||||
private boolean isLoadCaseAllExecuted;
|
||||
|
||||
public TestPlanExecuteInfo(String reportId,String creator){
|
||||
this.reportId = reportId;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public synchronized void updateExecuteInfo(Map<String, String> apiCaseExecInfo, Map<String, String> apiScenarioCaseExecInfo, Map<String, String> loadCaseExecInfo) {
|
||||
if (MapUtils.isNotEmpty(apiCaseExecInfo)) {
|
||||
this.apiCaseExecInfo.putAll(apiCaseExecInfo);
|
||||
|
|
|
@ -16,7 +16,7 @@ public class TestPlanReportExecuteCatch {
|
|||
private TestPlanReportExecuteCatch() {
|
||||
}
|
||||
|
||||
public synchronized static void addApiTestPlanExecuteInfo(String reportId,
|
||||
public synchronized static void addApiTestPlanExecuteInfo(String reportId,String creator,
|
||||
Map<String, String> apiCaseExecInfo, Map<String, String> apiScenarioCaseExecInfo, Map<String, String> loadCaseExecInfo) {
|
||||
if(testPlanReportMap == null){
|
||||
testPlanReportMap = new HashMap<>();
|
||||
|
@ -31,14 +31,21 @@ public class TestPlanReportExecuteCatch {
|
|||
loadCaseExecInfo = new HashMap<>();
|
||||
}
|
||||
|
||||
TestPlanExecuteInfo executeInfo = new TestPlanExecuteInfo();
|
||||
executeInfo.setReportId(reportId);
|
||||
TestPlanExecuteInfo executeInfo = new TestPlanExecuteInfo(reportId,creator);
|
||||
executeInfo.setApiCaseExecInfo(apiCaseExecInfo);
|
||||
executeInfo.setApiScenarioCaseExecInfo(apiScenarioCaseExecInfo);
|
||||
executeInfo.setLoadCaseExecInfo(loadCaseExecInfo);
|
||||
testPlanReportMap.put(reportId,executeInfo);
|
||||
}
|
||||
|
||||
public synchronized static String getCreator(String reportId){
|
||||
if(testPlanReportMap != null && testPlanReportMap.containsKey(reportId)){
|
||||
return testPlanReportMap.get(reportId).getCreator();
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void updateApiTestPlanExecuteInfo(String reportId,
|
||||
Map<String, String> apiCaseExecInfo, Map<String, String> apiScenarioCaseExecInfo, Map<String, String> loadCaseExecInfo) {
|
||||
if(testPlanReportMap != null && testPlanReportMap.containsKey(reportId)){
|
||||
|
|
|
@ -236,6 +236,9 @@ public class ApiDefinitionExecResultService {
|
|||
result.getScenarios().forEach(scenarioResult -> {
|
||||
if (scenarioResult != null && CollectionUtils.isNotEmpty(scenarioResult.getRequestResults())) {
|
||||
scenarioResult.getRequestResults().forEach(item -> {
|
||||
|
||||
String creator = TestPlanReportExecuteCatch.getCreator(testPlanReportId);
|
||||
|
||||
String status = item.isSuccess() ? "success" : "error";
|
||||
ApiDefinitionExecResult saveResult = new ApiDefinitionExecResult();
|
||||
saveResult.setId(UUID.randomUUID().toString());
|
||||
|
@ -279,34 +282,27 @@ public class ApiDefinitionExecResultService {
|
|||
saveResult.setType(finalSaveResultType);
|
||||
saveResult.setStatus(status);
|
||||
|
||||
String userID = null;
|
||||
if (StringUtils.equals(type, ApiRunMode.SCHEDULE_API_PLAN.name())) {
|
||||
TestPlanApiCase apiCase = testPlanApiCaseService.getById(item.getName());
|
||||
String scheduleCreateUser = testPlanService.findScheduleCreateUserById(apiCase.getTestPlanId());
|
||||
userID = scheduleCreateUser;
|
||||
if(StringUtils.isEmpty(creator)){
|
||||
creator = testPlanService.findScheduleCreateUserById(apiCase.getTestPlanId());
|
||||
}
|
||||
apiCase.setStatus(status);
|
||||
apiCase.setUpdateTime(System.currentTimeMillis());
|
||||
testPlanApiCaseService.updateByPrimaryKeySelective(apiCase);
|
||||
} else if (StringUtils.equals(type, ApiRunMode.JENKINS_API_PLAN.name())) {
|
||||
TestPlanApiCase apiCase = testPlanApiCaseService.getById(item.getName());
|
||||
// userID = Objects.requireNonNull(SessionUtils.getUser()).getId();
|
||||
userID = SessionUtils.getUserId();
|
||||
if(userID == null){
|
||||
userID = "";
|
||||
}
|
||||
apiCase.setStatus(status);
|
||||
apiCase.setUpdateTime(System.currentTimeMillis());
|
||||
testPlanApiCaseService.updateByPrimaryKeySelective(apiCase);
|
||||
} else {
|
||||
userID = SessionUtils.getUserId();
|
||||
if(userID == null){
|
||||
userID = "";
|
||||
}
|
||||
// userID = Objects.requireNonNull(SessionUtils.getUser()).getId();
|
||||
testPlanApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
|
||||
testCaseReviewApiCaseService.setExecResult(item.getName(), status, item.getStartTime());
|
||||
}
|
||||
saveResult.setUserId(userID);
|
||||
if(creator == null){
|
||||
creator = "";
|
||||
}
|
||||
saveResult.setUserId(creator);
|
||||
// 前一条数据内容清空
|
||||
ApiDefinitionExecResult prevResult = extApiDefinitionExecResultMapper.selectMaxResultByResourceIdAndType(item.getName(), finalSaveResultType);
|
||||
if (prevResult != null) {
|
||||
|
|
|
@ -536,7 +536,7 @@ public class TestCaseService {
|
|||
testCaseNodeService.createNodes(xmindParser.getNodePaths(), projectId);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(xmindParser.getTestCase())) {
|
||||
Collections.reverse(xmindParser.getTestCase());
|
||||
// Collections.reverse(xmindParser.getTestCase());
|
||||
this.saveImportData(xmindParser.getTestCase(), projectId);
|
||||
names = xmindParser.getTestCase().stream().map(TestCase::getName).collect(Collectors.toList());
|
||||
ids = xmindParser.getTestCase().stream().map(TestCase::getId).collect(Collectors.toList());
|
||||
|
@ -1572,7 +1572,7 @@ public class TestCaseService {
|
|||
testCaseNodeService.createNodes(nodePathList, projectId);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(continueCaseList)) {
|
||||
Collections.reverse(continueCaseList);
|
||||
// Collections.reverse(continueCaseList);
|
||||
this.saveImportData(continueCaseList, projectId);
|
||||
names.addAll(continueCaseList.stream().map(TestCase::getName).collect(Collectors.toList()));
|
||||
ids.addAll(continueCaseList.stream().map(TestCase::getId).collect(Collectors.toList()));
|
||||
|
|
|
@ -254,7 +254,7 @@ public class TestPlanReportService {
|
|||
performanceInfoMap = saveRequest.getPerformanceIdMap();
|
||||
}
|
||||
|
||||
TestPlanReportExecuteCatch.addApiTestPlanExecuteInfo(testPlanReportID, apiCaseInfoMap, scenarioInfoMap, performanceInfoMap);
|
||||
TestPlanReportExecuteCatch.addApiTestPlanExecuteInfo(testPlanReportID,saveRequest.getUserId(), apiCaseInfoMap, scenarioInfoMap, performanceInfoMap);
|
||||
|
||||
testPlanReport.setPrincipal(testPlan.getPrincipal());
|
||||
if (testPlanReport.getIsScenarioExecuting() || testPlanReport.getIsApiCaseExecuting() || testPlanReport.getIsPerformanceExecuting()) {
|
||||
|
|
Loading…
Reference in New Issue