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);
if (StringUtils.isNotBlank(historyStepStr)) {
List<FunctionalCaseStepDTO> historySteps = JSON.parseArray(historyStepStr, FunctionalCaseStepDTO.class);
Map<String, FunctionalCaseStepDTO> historyStepMap = historySteps.stream().collect(Collectors.toMap(FunctionalCaseStepDTO::getId, t -> t));
newCaseSteps.forEach(newCaseStep -> {
historySteps.forEach(historyStep -> {
setHistoryInfo(newCaseStep, historyStep);
});
setHistoryInfo(newCaseStep, historyStepMap);
});
}
}
}
private static void setHistoryInfo(FunctionalCaseStepDTO newCaseStep, FunctionalCaseStepDTO historyStep) {
if (StringUtils.equals(historyStep.getDesc(), newCaseStep.getDesc()) && StringUtils.equals(historyStep.getResult(), newCaseStep.getResult())) {
private static void setHistoryInfo(FunctionalCaseStepDTO newCaseStep, Map<String, FunctionalCaseStepDTO> historyStepMap) {
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.setActualResult(historyStep.getActualResult());
}
}
public void editFunctionalCase(TestPlanCaseEditRequest request, String userId) {
TestPlanFunctionalCase planFunctionalCase = testPlanFunctionalCaseMapper.selectByPrimaryKey(request.getId());
TestPlanFunctionalCase functionalCase = new TestPlanFunctionalCase();