refactor(用例脑图): 测试计划与用例评审的脑图不显示用例标签

This commit is contained in:
guoyuqi 2024-09-10 17:47:39 +08:00 committed by Craftsman
parent ffa7c29451
commit 99221b0673
1 changed files with 12 additions and 10 deletions

View File

@ -141,7 +141,7 @@ public class FunctionalCaseMinderService {
Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue)); Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue));
//构造父子级数据 //构造父子级数据
buildList(functionalCaseMindDTOList, list, priorityMap, false); buildList(functionalCaseMindDTOList, list, priorityMap, "FUNCTIONAL");
return list; return list;
} }
@ -152,7 +152,7 @@ public class FunctionalCaseMinderService {
return customFields.stream().map(TemplateCustomFieldDTO::getFieldId).toList(); return customFields.stream().map(TemplateCustomFieldDTO::getFieldId).toList();
} }
private void buildList(List<FunctionalCaseMindDTO> functionalCaseMindDTOList, List<FunctionalMinderTreeDTO> list, Map<String, String> priorityMap, boolean addActualResult) { private void buildList(List<FunctionalCaseMindDTO> functionalCaseMindDTOList, List<FunctionalMinderTreeDTO> list, Map<String, String> priorityMap, String sourceType) {
//构造父子级数据 //构造父子级数据
for (FunctionalCaseMindDTO functionalCaseMindDTO : functionalCaseMindDTOList) { for (FunctionalCaseMindDTO functionalCaseMindDTO : functionalCaseMindDTOList) {
FunctionalMinderTreeDTO root = new FunctionalMinderTreeDTO(); FunctionalMinderTreeDTO root = new FunctionalMinderTreeDTO();
@ -163,15 +163,17 @@ public class FunctionalCaseMinderService {
rootData.setCaseId(functionalCaseMindDTO.getCaseId()); rootData.setCaseId(functionalCaseMindDTO.getCaseId());
rootData.setPriority(StringUtils.isNotBlank(priorityMap.get(functionalCaseMindDTO.getCaseId())) ? Integer.parseInt(priorityMap.get(functionalCaseMindDTO.getCaseId()).substring(1)) + 1 : 1); rootData.setPriority(StringUtils.isNotBlank(priorityMap.get(functionalCaseMindDTO.getCaseId())) ? Integer.parseInt(priorityMap.get(functionalCaseMindDTO.getCaseId()).substring(1)) + 1 : 1);
rootData.setStatus(functionalCaseMindDTO.getReviewStatus()); rootData.setStatus(functionalCaseMindDTO.getReviewStatus());
rootData.setResource(List.of(Translator.get("minder_extra_node.case"))); if (StringUtils.equalsIgnoreCase(sourceType, "FUNCTIONAL")) {
List<FunctionalMinderTreeDTO> children = buildChildren(functionalCaseMindDTO, addActualResult); rootData.setResource(List.of(Translator.get("minder_extra_node.case")));
}
List<FunctionalMinderTreeDTO> children = buildChildren(functionalCaseMindDTO, sourceType);
root.setChildren(children); root.setChildren(children);
root.setData(rootData); root.setData(rootData);
list.add(root); list.add(root);
} }
} }
private List<FunctionalMinderTreeDTO> buildChildren(FunctionalCaseMindDTO functionalCaseMindDTO, boolean addActualResult) { private List<FunctionalMinderTreeDTO> buildChildren(FunctionalCaseMindDTO functionalCaseMindDTO, String sourceType) {
List<FunctionalMinderTreeDTO> children = new ArrayList<>(); List<FunctionalMinderTreeDTO> children = new ArrayList<>();
if (functionalCaseMindDTO.getPrerequisite() != null) { if (functionalCaseMindDTO.getPrerequisite() != null) {
String prerequisiteText = new String(functionalCaseMindDTO.getPrerequisite(), StandardCharsets.UTF_8); String prerequisiteText = new String(functionalCaseMindDTO.getPrerequisite(), StandardCharsets.UTF_8);
@ -203,7 +205,7 @@ public class FunctionalCaseMinderService {
String stepText = new String(functionalCaseMindDTO.getSteps(), StandardCharsets.UTF_8); String stepText = new String(functionalCaseMindDTO.getSteps(), StandardCharsets.UTF_8);
if (StringUtils.isNotBlank(stepText)) { if (StringUtils.isNotBlank(stepText)) {
List<FunctionalCaseStepDTO> functionalCaseStepDTOS = JSON.parseArray(stepText, FunctionalCaseStepDTO.class); List<FunctionalCaseStepDTO> functionalCaseStepDTOS = JSON.parseArray(stepText, FunctionalCaseStepDTO.class);
if (addActualResult) { if (StringUtils.equalsIgnoreCase(sourceType, "TEST_PLAN")) {
compareStep(functionalCaseMindDTO.getExecuteSteps(), functionalCaseStepDTOS); compareStep(functionalCaseMindDTO.getExecuteSteps(), functionalCaseStepDTOS);
} }
for (FunctionalCaseStepDTO functionalCaseStepDTO : functionalCaseStepDTOS) { for (FunctionalCaseStepDTO functionalCaseStepDTO : functionalCaseStepDTOS) {
@ -219,7 +221,7 @@ public class FunctionalCaseMinderService {
} else { } else {
expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(result, Translator.get("minder_extra_node.steps_expected_result"), Long.valueOf(functionalCaseStepDTO.getNum())); expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(result, Translator.get("minder_extra_node.steps_expected_result"), Long.valueOf(functionalCaseStepDTO.getNum()));
} }
if (addActualResult) { if (StringUtils.equalsIgnoreCase(sourceType, "TEST_PLAN")) {
Map<String, String> statusMap = new HashMap<>(); Map<String, String> statusMap = new HashMap<>();
statusMap.put(ResultStatus.SUCCESS.name(), Translator.get("case.minder.status.success")); statusMap.put(ResultStatus.SUCCESS.name(), Translator.get("case.minder.status.success"));
statusMap.put(ResultStatus.ERROR.name(), Translator.get("case.minder.status.error")); statusMap.put(ResultStatus.ERROR.name(), Translator.get("case.minder.status.error"));
@ -256,7 +258,7 @@ public class FunctionalCaseMinderService {
} }
} }
if (addActualResult) { if (StringUtils.equalsIgnoreCase(sourceType, "TEST_PLAN")) {
String contentText = StringUtils.EMPTY; String contentText = StringUtils.EMPTY;
if (functionalCaseMindDTO.getContent() != null) { if (functionalCaseMindDTO.getContent() != null) {
contentText = new String(functionalCaseMindDTO.getContent(), StandardCharsets.UTF_8); contentText = new String(functionalCaseMindDTO.getContent(), StandardCharsets.UTF_8);
@ -1231,7 +1233,7 @@ public class FunctionalCaseMinderService {
List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted, fieldIds); List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted, fieldIds);
Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue)); Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue));
//构造父子级数据 //构造父子级数据
buildList(functionalCaseMindDTOList, list, priorityMap, false); buildList(functionalCaseMindDTOList, list, priorityMap, "REVIEW");
return list; return list;
} }
@ -1248,7 +1250,7 @@ public class FunctionalCaseMinderService {
List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted, fieldIds); List<FunctionalCaseCustomField> caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted, fieldIds);
Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue)); Map<String, String> priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue));
//构造父子级数据 //构造父子级数据
buildList(functionalCaseMindDTOList, list, priorityMap, true); buildList(functionalCaseMindDTOList, list, priorityMap, "TEST_PLAN");
return list; return list;
} }