From f35800d223d411a284d187e038002fab9a018263 Mon Sep 17 00:00:00 2001 From: Pierre-yves-monnet Date: Fri, 6 Dec 2024 11:12:59 -0800 Subject: [PATCH] Migrate to last version of API --- .../java/org/camunda/automator/AutomatorRest.java | 15 ++++++++------- .../bpmnengine/camunda8/BpmnEngineCamunda8.java | 2 +- .../bpmnengine/camunda8/OperateClient.java | 2 +- .../automator/definition/ScenarioExecution.java | 3 +-- .../engine/unit/RunScenarioUnitServiceTask.java | 1 + .../automator/services/AutomatorStartup.java | 7 +++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/camunda/automator/AutomatorRest.java b/src/main/java/org/camunda/automator/AutomatorRest.java index 5a7003d..0c6fb8c 100644 --- a/src/main/java/org/camunda/automator/AutomatorRest.java +++ b/src/main/java/org/camunda/automator/AutomatorRest.java @@ -34,6 +34,7 @@ public class AutomatorRest { public static final String JSON_MESSAGE = "message"; public static final String JSON_INFO = "info"; private static final Logger logger = LoggerFactory.getLogger(AutomatorRest.class.getName()); + public static final String JSON_STATUS_V_NOTEXIST = "NOTEXIST"; private final ConfigurationStartup configurationStartup; private final ContentManager contentManager; private final AutomatorAPI automatorAPI; @@ -76,7 +77,7 @@ public Map getUnitTest(@RequestParam(name = "id") String unitTes if (resultTest != null) { return resultTest; } else { - return Map.of("status", "NOTEXIST"); + return Map.of(AutomatorRest.JSON_STATUS, JSON_STATUS_V_NOTEXIST); } } @@ -85,7 +86,7 @@ public List> getListUnitTest() { List> listUnitTest = new ArrayList<>(); for (Map.Entry entryTest : cacheExecution.entrySet()) { if (entryTest.getValue() instanceof Map resultMap) { - listUnitTest.add(Map.of("id", entryTest.getKey(), + listUnitTest.add(Map.of(AutomatorRest.JSON_ID, entryTest.getKey(), JSON_SCENARIO_NAME, getSecureValue(resultMap.get(JSON_SCENARIO_NAME)))); } else { listUnitTest.add(Map.of(JSON_ID, entryTest.getKey(), @@ -159,8 +160,8 @@ private void startTest(String scenarioName, String serverName, String unitTestId } /** - * @param runResult - * @return + * @param runResult result to transform in JSON + * @return result ready for a JSON format */ private Map resultToJson(RunResult runResult) { Map resultMap = new HashMap<>(); @@ -198,9 +199,9 @@ private Map completeMessage(Map result, StatusTe * Connect to the BPM Engine * * @param scenario scenario to use to connect - * @param runParameters - * @param result - * @return + * @param runParameters running parameters + * @param result result of the connection + * @return BPMN Engine */ private BpmnEngine connectToEngine(Scenario scenario, RunParameters runParameters, Map result) { BpmnEngine bpmnEngine = null; diff --git a/src/main/java/org/camunda/automator/bpmnengine/camunda8/BpmnEngineCamunda8.java b/src/main/java/org/camunda/automator/bpmnengine/camunda8/BpmnEngineCamunda8.java index 9240704..4d9ec1a 100644 --- a/src/main/java/org/camunda/automator/bpmnengine/camunda8/BpmnEngineCamunda8.java +++ b/src/main/java/org/camunda/automator/bpmnengine/camunda8/BpmnEngineCamunda8.java @@ -382,7 +382,7 @@ public void throwBpmnServiceTask(String serviceTaskId, * @param filterTaskId filter on the taskId * @param maxResult maximum Result * @return list of Task - * @throws AutomatorException + * @throws AutomatorException in case of error */ @Override public List searchTasksByProcessInstanceId(String processInstanceId, String filterTaskId, int maxResult) diff --git a/src/main/java/org/camunda/automator/bpmnengine/camunda8/OperateClient.java b/src/main/java/org/camunda/automator/bpmnengine/camunda8/OperateClient.java index a4011df..0f5c220 100644 --- a/src/main/java/org/camunda/automator/bpmnengine/camunda8/OperateClient.java +++ b/src/main/java/org/camunda/automator/bpmnengine/camunda8/OperateClient.java @@ -198,7 +198,7 @@ public List activateServiceTasks(String processInstanceId, String servic * @param filterTaskId filter on the taskId * @param maxResult maximum Result * @return list of Task - * @throws AutomatorException + * @throws AutomatorException in case of error */ public List searchTasksByProcessInstanceId(String processInstanceId, String filterTaskId, int maxResult) throws AutomatorException { diff --git a/src/main/java/org/camunda/automator/definition/ScenarioExecution.java b/src/main/java/org/camunda/automator/definition/ScenarioExecution.java index e49e5a0..4aa0554 100644 --- a/src/main/java/org/camunda/automator/definition/ScenarioExecution.java +++ b/src/main/java/org/camunda/automator/definition/ScenarioExecution.java @@ -1,7 +1,6 @@ package org.camunda.automator.definition; import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** @@ -77,7 +76,7 @@ public ScenarioExecution addStep(ScenarioStep step) { } public List getSteps() { - return steps == null ? Collections.emptyList() : steps; + return steps; } public ScenarioVerification getVerifications() { diff --git a/src/main/java/org/camunda/automator/engine/unit/RunScenarioUnitServiceTask.java b/src/main/java/org/camunda/automator/engine/unit/RunScenarioUnitServiceTask.java index 9e4a310..5e6ddca 100644 --- a/src/main/java/org/camunda/automator/engine/unit/RunScenarioUnitServiceTask.java +++ b/src/main/java/org/camunda/automator/engine/unit/RunScenarioUnitServiceTask.java @@ -62,6 +62,7 @@ public RunResult executeServiceTask(ScenarioStep step, RunResult result) { try { Thread.sleep(500); } catch (InterruptedException e) { + // nothing to do here } } } while (listActivities.isEmpty() && System.currentTimeMillis() - beginTimeWait < waitingTimeInMs); diff --git a/src/main/java/org/camunda/automator/services/AutomatorStartup.java b/src/main/java/org/camunda/automator/services/AutomatorStartup.java index 5f48609..11a776f 100644 --- a/src/main/java/org/camunda/automator/services/AutomatorStartup.java +++ b/src/main/java/org/camunda/automator/services/AutomatorStartup.java @@ -24,7 +24,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; +import java.util.Objects; @Service public class AutomatorStartup { @@ -101,7 +101,6 @@ private List loadStartupScenario() { } else { logger.error("AutomatorStartup/StartupScenario:: Can't find File [{}/{}] or [{}]", configurationStartup.scenarioPath, scenarioFileName, scenarioFileName); - continue; } } @@ -113,8 +112,8 @@ private List loadStartupScenario() { configurationStartup.getScenarioResourceAtStartupName()); } else { List scenarioResource = configurationStartup.getScenarioResourceAtStartup().stream() - .filter(t -> t != null) - .collect(Collectors.toList()); + .filter(Objects::nonNull) + .toList(); logger.info("Detect {} scenario [Resource] from variable [{}]", scenarioResource.size(),