From 4ba6ad8a5e1c2a4e64c25d214cef776f42eca1d6 Mon Sep 17 00:00:00 2001 From: "AAVN\\ntnchuong" Date: Thu, 23 May 2024 10:30:51 +0700 Subject: [PATCH] TE-582: improve error message --- pom.xml | 2 +- .../process/analyzer/demo/ProcessAnalyzerBean.java | 4 ---- .../process/analyzer/test/FlowExampleErrorTest.java | 2 +- .../utils/process/analyzer/internal/PathFinder.java | 12 +++++++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index f1006add..79fb279b 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ - scm:git:https://github.com/axonivy-professional-services/market-${project.name}.git + scm:git:https://github.com/axonivy-market/${project.name}.git HEAD diff --git a/process-analyzer-demo/src/com/axonivy/utils/process/analyzer/demo/ProcessAnalyzerBean.java b/process-analyzer-demo/src/com/axonivy/utils/process/analyzer/demo/ProcessAnalyzerBean.java index 736df086..db7ddfb7 100644 --- a/process-analyzer-demo/src/com/axonivy/utils/process/analyzer/demo/ProcessAnalyzerBean.java +++ b/process-analyzer-demo/src/com/axonivy/utils/process/analyzer/demo/ProcessAnalyzerBean.java @@ -202,10 +202,6 @@ private List getAllProcesses() { return processes; } - private boolean isAcceptedProcess(List folders, String fullQualifiedName) { - return folders.stream().anyMatch(folder -> fullQualifiedName.contains(folder)); - } - private static List getElementOfProcess(Process process) { var processElements = process.getProcessElements(); var childElments = getElementOfProcesses(processElements); diff --git a/process-analyzer-test/src_test/com/axonivy/utils/process/analyzer/test/FlowExampleErrorTest.java b/process-analyzer-test/src_test/com/axonivy/utils/process/analyzer/test/FlowExampleErrorTest.java index 47914480..053d8a49 100644 --- a/process-analyzer-test/src_test/com/axonivy/utils/process/analyzer/test/FlowExampleErrorTest.java +++ b/process-analyzer-test/src_test/com/axonivy/utils/process/analyzer/test/FlowExampleErrorTest.java @@ -42,7 +42,7 @@ void shouldThrowExceptionWhenFindTasksOnPathAtStartWithFlowNameNull() { processAnalyzer.findTasksOnPath(start, null, null); }); - String expectedMessage = "Not found path"; + String expectedMessage = "Not found path after element 18DD16F8AA39F5DE-f7"; String actualMessage = exception.getMessage(); assertEquals(expectedMessage, actualMessage); diff --git a/process-analyzer/src/com/axonivy/utils/process/analyzer/internal/PathFinder.java b/process-analyzer/src/com/axonivy/utils/process/analyzer/internal/PathFinder.java index e62c2342..3a89fdd1 100644 --- a/process-analyzer/src/com/axonivy/utils/process/analyzer/internal/PathFinder.java +++ b/process-analyzer/src/com/axonivy/utils/process/analyzer/internal/PathFinder.java @@ -19,17 +19,19 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.SetUtils; +import org.apache.commons.lang3.StringUtils; import com.axonivy.utils.process.analyzer.internal.model.AnalysisPath; import com.axonivy.utils.process.analyzer.internal.model.CommonElement; import com.axonivy.utils.process.analyzer.internal.model.ProcessElement; import com.axonivy.utils.process.analyzer.internal.model.TaskParallelGroup; -import ch.ivyteam.ivy.environment.Ivy; import ch.ivyteam.ivy.process.model.BaseElement; import ch.ivyteam.ivy.process.model.NodeElement; import ch.ivyteam.ivy.process.model.connector.SequenceFlow; @@ -368,8 +370,7 @@ private List findAnalysisPaths(ProcessElement from, String flowNam List outs = getSequenceFlows((NodeElement) from.getElement(), flowName, findType); if (from.getElement() instanceof Alternative && outs.isEmpty()) { - Ivy.log().error("Can not found the out going from a alternative {0}", from.getPid().getRawPid()); - throw new Exception("Not found path"); + throw new Exception("Not found path after element " + getAlternativeNameId(from.getElement())); } Map> pathOptions = new LinkedHashMap<>(); @@ -387,6 +388,11 @@ private List findAnalysisPaths(ProcessElement from, String flowNam return path; } + private String getAlternativeNameId(BaseElement alternative) { + return Stream.of(alternative.getName(), alternative.getPid().getRawPid()).filter(StringUtils::isNotEmpty) + .collect(Collectors.joining("-")); + } + private List removeLastTaskSwitchGateway(List paths) { List result = new ArrayList<>(); for (AnalysisPath path : paths) {