refactor(测试计划): 测试计划功能用例详情的步骤结果对比增加唯一性

This commit is contained in:
guoyuqi 2024-05-17 11:30:58 +08:00 committed by 刘瑞斌
parent aa9101c795
commit 156bed16c9
1 changed files with 5 additions and 6 deletions

View File

@ -615,23 +615,22 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
String historyStepStr = new String(testPlanCaseExecuteHistory.getSteps(), StandardCharsets.UTF_8); String historyStepStr = new String(testPlanCaseExecuteHistory.getSteps(), StandardCharsets.UTF_8);
if (StringUtils.isNotBlank(historyStepStr)) { if (StringUtils.isNotBlank(historyStepStr)) {
List<FunctionalCaseStepDTO> historySteps = JSON.parseArray(historyStepStr, FunctionalCaseStepDTO.class); List<FunctionalCaseStepDTO> historySteps = JSON.parseArray(historyStepStr, FunctionalCaseStepDTO.class);
Map<String, FunctionalCaseStepDTO> historyStepMap = historySteps.stream().collect(Collectors.toMap(FunctionalCaseStepDTO::getId, t -> t));
newCaseSteps.forEach(newCaseStep -> { newCaseSteps.forEach(newCaseStep -> {
historySteps.forEach(historyStep -> { setHistoryInfo(newCaseStep, historyStepMap);
setHistoryInfo(newCaseStep, historyStep);
});
}); });
} }
} }
} }
private static void setHistoryInfo(FunctionalCaseStepDTO newCaseStep, FunctionalCaseStepDTO historyStep) { private static void setHistoryInfo(FunctionalCaseStepDTO newCaseStep, Map<String, FunctionalCaseStepDTO> historyStepMap) {
if (StringUtils.equals(historyStep.getDesc(), newCaseStep.getDesc()) && StringUtils.equals(historyStep.getResult(), newCaseStep.getResult())) { FunctionalCaseStepDTO historyStep = historyStepMap.get(newCaseStep.getId());
if (historyStep != null && StringUtils.equals(historyStep.getDesc(), newCaseStep.getDesc()) && StringUtils.equals(historyStep.getResult(), newCaseStep.getResult())) {
newCaseStep.setExecuteResult(historyStep.getExecuteResult()); newCaseStep.setExecuteResult(historyStep.getExecuteResult());
newCaseStep.setActualResult(historyStep.getActualResult()); newCaseStep.setActualResult(historyStep.getActualResult());
} }
} }
public void editFunctionalCase(TestPlanCaseEditRequest request, String userId) { public void editFunctionalCase(TestPlanCaseEditRequest request, String userId) {
TestPlanFunctionalCase planFunctionalCase = testPlanFunctionalCaseMapper.selectByPrimaryKey(request.getId()); TestPlanFunctionalCase planFunctionalCase = testPlanFunctionalCaseMapper.selectByPrimaryKey(request.getId());
TestPlanFunctionalCase functionalCase = new TestPlanFunctionalCase(); TestPlanFunctionalCase functionalCase = new TestPlanFunctionalCase();