Skip to content

Commit

Permalink
Migrate to last version of API
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-yves-monnet committed Dec 6, 2024
1 parent 83869cc commit f35800d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
15 changes: 8 additions & 7 deletions src/main/java/org/camunda/automator/AutomatorRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,7 +77,7 @@ public Map<String, Object> 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);
}
}

Expand All @@ -85,7 +86,7 @@ public List<Map<String, Object>> getListUnitTest() {
List<Map<String, Object>> 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(),
Expand Down Expand Up @@ -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<String, Object> resultToJson(RunResult runResult) {
Map<String, Object> resultMap = new HashMap<>();
Expand Down Expand Up @@ -198,9 +199,9 @@ private Map<String, Object> completeMessage(Map<String, Object> 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<String, Object> result) {
BpmnEngine bpmnEngine = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TaskDescription> searchTasksByProcessInstanceId(String processInstanceId, String filterTaskId, int maxResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public List<String> 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<BpmnEngine.TaskDescription> searchTasksByProcessInstanceId(String processInstanceId, String filterTaskId, int maxResult)
throws AutomatorException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.camunda.automator.definition;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -77,7 +76,7 @@ public ScenarioExecution addStep(ScenarioStep step) {
}

public List<ScenarioStep> getSteps() {
return steps == null ? Collections.emptyList() : steps;
return steps;
}

public ScenarioVerification getVerifications() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -101,7 +101,6 @@ private List<Path> loadStartupScenario() {
} else {
logger.error("AutomatorStartup/StartupScenario:: Can't find File [{}/{}] or [{}]", configurationStartup.scenarioPath,
scenarioFileName, scenarioFileName);
continue;
}
}

Expand All @@ -113,8 +112,8 @@ private List<Path> loadStartupScenario() {
configurationStartup.getScenarioResourceAtStartupName());
} else {
List<Resource> scenarioResource = configurationStartup.getScenarioResourceAtStartup().stream()
.filter(t -> t != null)
.collect(Collectors.toList());
.filter(Objects::nonNull)
.toList();

logger.info("Detect {} scenario [Resource] from variable [{}]",
scenarioResource.size(),
Expand Down

0 comments on commit f35800d

Please sign in to comment.