fix(测试跟踪): 修复测试计划报告环境显示不全的问题
--bug=1015084 --user=宋天阳 【测试跟踪】测试计划-报告列表,报告里的运行环境少了一个 https://www.tapd.cn/55049933/s/1205607
This commit is contained in:
parent
c012ff0738
commit
a4e4bb60b9
|
@ -3,7 +3,9 @@ package io.metersphere.track.dto.testplan;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -14,24 +16,38 @@ public class TestPlanReportRunInfoDTO {
|
||||||
|
|
||||||
private String runMode;
|
private String runMode;
|
||||||
// <测试计划场景关联表ID, <项目ID,环境ID>>
|
// <测试计划场景关联表ID, <项目ID,环境ID>>
|
||||||
private Map<String, Map<String,String>> scenarioRunInfo;
|
private Map<String, Map<String, List<String>>> scenarioRunInfo;
|
||||||
// <测试计划用例关联表ID, <项目ID,环境ID>>
|
// <测试计划用例关联表ID, <项目ID,环境ID>>
|
||||||
private Map<String, Map<String,String>> apiCaseRunInfo;
|
private Map<String, Map<String, String>> apiCaseRunInfo;
|
||||||
|
|
||||||
public TestPlanReportRunInfoDTO(){
|
public TestPlanReportRunInfoDTO() {
|
||||||
scenarioRunInfo = new HashMap<>();
|
scenarioRunInfo = new HashMap<>();
|
||||||
apiCaseRunInfo = new HashMap<>();
|
apiCaseRunInfo = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putScenarioRunInfo(String scenarioResourceId,String projectId,String environmentId){
|
public void putScenarioRunInfo(String scenarioResourceId, String projectId, String environmentId) {
|
||||||
scenarioRunInfo.put(scenarioResourceId,new HashMap<>(){{
|
if (scenarioRunInfo.containsKey(scenarioResourceId)) {
|
||||||
this.put(projectId,environmentId);
|
if (scenarioRunInfo.get(scenarioResourceId).containsKey(projectId)) {
|
||||||
|
if (!scenarioRunInfo.get(scenarioResourceId).get(projectId).contains(environmentId)) {
|
||||||
|
scenarioRunInfo.get(scenarioResourceId).get(projectId).add(environmentId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scenarioRunInfo.get(scenarioResourceId).put(projectId, new ArrayList<>() {{
|
||||||
|
this.add(environmentId);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
scenarioRunInfo.put(scenarioResourceId, new HashMap<>() {{
|
||||||
|
this.put(projectId, new ArrayList<>() {{
|
||||||
|
this.add(environmentId);
|
||||||
|
}});
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void putApiCaseRunInfo(String apiCaseResourceId,String projectId,String environmentId){
|
public void putApiCaseRunInfo(String apiCaseResourceId, String projectId, String environmentId) {
|
||||||
apiCaseRunInfo.put(apiCaseResourceId,new HashMap<>(){{
|
apiCaseRunInfo.put(apiCaseResourceId, new HashMap<>() {{
|
||||||
this.put(projectId,environmentId);
|
this.put(projectId, environmentId);
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -305,11 +305,11 @@ public class TestPlanReportService {
|
||||||
try {
|
try {
|
||||||
Map<String, String> envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
Map<String, String> envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
|
||||||
if (MapUtils.isNotEmpty(envMap)) {
|
if (MapUtils.isNotEmpty(envMap)) {
|
||||||
String envId = null;
|
for (Map.Entry<String, String> entry : envMap.entrySet()) {
|
||||||
for (String envIdStr : envMap.values()) {
|
String projectId = entry.getKey();
|
||||||
envId = envIdStr;
|
String envIdStr = entry.getValue();
|
||||||
|
runInfoDTO.putScenarioRunInfo(model.getId(), projectId, envIdStr);
|
||||||
}
|
}
|
||||||
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), envId);
|
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
}
|
}
|
||||||
|
@ -991,10 +991,10 @@ public class TestPlanReportService {
|
||||||
testPlanReportDTO.setRunMode(StringUtils.equalsIgnoreCase(runInfoDTO.getRunMode(), "serial") ? Translator.get("serial") : Translator.get("parallel"));
|
testPlanReportDTO.setRunMode(StringUtils.equalsIgnoreCase(runInfoDTO.getRunMode(), "serial") ? Translator.get("serial") : Translator.get("parallel"));
|
||||||
Map<String, Set<String>> projectEnvMap = new LinkedHashMap<>();
|
Map<String, Set<String>> projectEnvMap = new LinkedHashMap<>();
|
||||||
if (MapUtils.isNotEmpty(runInfoDTO.getApiCaseRunInfo())) {
|
if (MapUtils.isNotEmpty(runInfoDTO.getApiCaseRunInfo())) {
|
||||||
this.setProjectEnvMap(projectEnvMap, runInfoDTO.getApiCaseRunInfo());
|
this.setApiCaseProjectEnvMap(projectEnvMap, runInfoDTO.getApiCaseRunInfo());
|
||||||
}
|
}
|
||||||
if (MapUtils.isNotEmpty(runInfoDTO.getScenarioRunInfo())) {
|
if (MapUtils.isNotEmpty(runInfoDTO.getScenarioRunInfo())) {
|
||||||
this.setProjectEnvMap(projectEnvMap, runInfoDTO.getScenarioRunInfo());
|
this.setScenarioProjectEnvMap(projectEnvMap, runInfoDTO.getScenarioRunInfo());
|
||||||
}
|
}
|
||||||
Map<String, List<String>> showProjectEnvMap = new LinkedHashMap<>();
|
Map<String, List<String>> showProjectEnvMap = new LinkedHashMap<>();
|
||||||
for (Map.Entry<String, Set<String>> entry : projectEnvMap.entrySet()) {
|
for (Map.Entry<String, Set<String>> entry : projectEnvMap.entrySet()) {
|
||||||
|
@ -1012,7 +1012,33 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setProjectEnvMap(Map<String, Set<String>> projectEnvMap, Map<String, Map<String, String>> caseEnvironmentMap) {
|
private void setScenarioProjectEnvMap(Map<String, Set<String>> projectEnvMap, Map<String, Map<String, List<String>>> caseEnvironmentMap) {
|
||||||
|
if (projectEnvMap == null || caseEnvironmentMap == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Map<String, List<String>> map : caseEnvironmentMap.values()) {
|
||||||
|
if (MapUtils.isEmpty(map)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
||||||
|
String projectId = entry.getKey();
|
||||||
|
List<String> envIdList = entry.getValue();
|
||||||
|
if (CollectionUtils.isNotEmpty(envIdList)) {
|
||||||
|
envIdList.forEach(envId -> {
|
||||||
|
if (projectEnvMap.containsKey(projectId)) {
|
||||||
|
projectEnvMap.get(projectId).add(envId);
|
||||||
|
} else {
|
||||||
|
projectEnvMap.put(projectId, new LinkedHashSet<>() {{
|
||||||
|
this.add(envId);
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setApiCaseProjectEnvMap(Map<String, Set<String>> projectEnvMap, Map<String, Map<String, String>> caseEnvironmentMap) {
|
||||||
if (projectEnvMap == null || caseEnvironmentMap == null) {
|
if (projectEnvMap == null || caseEnvironmentMap == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
v-if="report.envGroupName || report.projectEnvMap" style="display:inline-block">
|
v-if="report.envGroupName || report.projectEnvMap" style="display:inline-block">
|
||||||
<div>
|
<div>
|
||||||
<div style="float: left">
|
<div style="float: left">
|
||||||
{{$t('commons.environment') + ':'}}
|
{{ $t('commons.environment') + ':' }}
|
||||||
</div>
|
</div>
|
||||||
<div style="float: right">
|
<div style="float: right">
|
||||||
<div v-if="report.envGroupName" style="margin-left: 42px">
|
<div v-if="report.envGroupName" style="margin-left: 42px">
|
||||||
<ms-tag type="danger" :content="$t('commons.group')"></ms-tag>
|
<ms-tag type="danger" :content="$t('workspace.env_group.name')"></ms-tag>
|
||||||
{{ report.envGroupName }}
|
{{ report.envGroupName }}
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="report.projectEnvMap" style="margin-left: 42px">
|
<div v-else-if="report.projectEnvMap" style="margin-left: 42px">
|
||||||
|
|
Loading…
Reference in New Issue