Skip to content

Commit

Permalink
Test with last version of API
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-yves-monnet committed Dec 10, 2024
1 parent f35800d commit a74a59f
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 103 deletions.
9 changes: 8 additions & 1 deletion doc/scenarioreference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,21 @@ the variable `loopcrawl` will be a list of 500 random string.

**generateuniqueid(<Prefix>)**
Generate a unique sequential number.
The prefix is used to allo wmultiple counter
The prefix is used to allow multiple counter
Example:
````
"tidblue": "generateuniqueid(blue)"
"tidred": "generateuniqueid(red)"
````
Variables `tidblue` and `tidred` got a unique id, each following a different counter.

**now(LOCALDATETIME|DATE|ZONEDATETIME|LOCALDATE)**
Generate a String object, containing the current date and time.


**stringToDate(LOCALDATETIME|DATE|ZONEDATETIME|LOCALDATE, dateSt)**
Transform a String to a Date (LocalDateTime, Date, ZoneDateTime or LocalDate)


## Verification

Expand Down
18 changes: 10 additions & 8 deletions doc/unittestscenario/resources/ScoreAcceptance.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
<bpmn:incoming>Flow_09z898p</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_09z898p" sourceRef="ActSendAcceptation" targetRef="EndAccepted" />
<bpmn:task id="ActSendRejection" name="Send rejection">
<bpmn:incoming>Flow_0wya675</bpmn:incoming>
<bpmn:outgoing>Flow_1pxztl2</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="Flow_0a4sjzy" name="Rejected" sourceRef="Gateway_01ox9rs" targetRef="CallApplicant" />
<bpmn:endEvent id="EndRejected" name="rejected">
<bpmn:incoming>Flow_1pxztl2</bpmn:incoming>
Expand All @@ -44,6 +40,13 @@
<bpmn:incoming>Flow_0a4sjzy</bpmn:incoming>
<bpmn:outgoing>Flow_0wya675</bpmn:outgoing>
</bpmn:userTask>
<bpmn:serviceTask id="ActSendRejection" name="Send rejection">
<bpmn:extensionElements>
<zeebe:taskDefinition type="send-rejection" />
</bpmn:extensionElements>
<bpmn:incoming>Flow_0wya675</bpmn:incoming>
<bpmn:outgoing>Flow_1pxztl2</bpmn:outgoing>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ScoreAcceptance">
Expand Down Expand Up @@ -79,14 +82,13 @@
<dc:Bounds x="870" y="315" width="40" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1dmaofg_di" bpmnElement="ActSendRejection">
<dc:Bounds x="710" y="250" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1kkk9hs_di" bpmnElement="CallApplicant">
<dc:Bounds x="530" y="250" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0bhloo7_di" bpmnElement="ActSendRejection">
<dc:Bounds x="710" y="250" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1wuzgpt_di" bpmnElement="Flow_1wuzgpt">
<di:waypoint x="228" y="180" />
<di:waypoint x="280" y="180" />
Expand Down
14 changes: 13 additions & 1 deletion doc/unittestscenario/resources/ScoreAcceptanceScn.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,24 @@
"variables": {
"phoneNumber": "(+1) 542 778 2352"
}
},
{
"type": "SERVICETASK",
"taskId": "ActSendRejection",
"topic": "send-rejection",
"waitingTime": "PT0S",
"modeExecution": "ASYNCHRONOUS",
"variablesOperation": {
"sendMessage": "now(LocalDateTime)"
}
}


],
"verifications": {
"activities": [
{
"type": "TASK",
"type": "SERVICETASK",
"taskId": "ActSendRejection"
},
{
Expand Down
25 changes: 1 addition & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,6 @@

<dependencies>

<!-- Camunda operate client is included -->
<!--
8.5 : OK
<version.spring-boot-starter-camunda>8.5.7</version.zeebe>
<version.zeebe-client>8.5.5</version.zeebe-client>
8.5.11 : ?
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda</artifactId>
<version>8.5.7</version>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-client-java</artifactId>
<version>8.5.7</version>
</dependency>
-->


<dependency>
<groupId>io.camunda</groupId>
<artifactId>spring-boot-starter-camunda-sdk</artifactId>
Expand All @@ -96,7 +74,7 @@
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>java-client-operate</artifactId>
<version>8.6.2</version>
<version>8.6.3</version>
</dependency>


Expand All @@ -106,7 +84,6 @@
8.6.6 : incompatible types: io.camunda.common.auth.Authentication cannot be converted to io.camunda.tasklist.auth.Authentication
8.5.10 Bug fix on ZeebeUserTask (actually, no)
8.6.6 last version available-->

<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-tasklist-client-java</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ public void executeServiceTask(String serviceTaskId, String workerId, Map<String
try {
zeebeClient.newCompleteCommand(Long.valueOf(serviceTaskId)).variables(variables).send().join();
} catch (Exception e) {
logger.error("executeServiceTask:Can't execute service task[{}] WorkerId[{}] : {}", serviceTaskId, workerId, e.getMessage());
throw new AutomatorException("Can't execute service task " + e.getMessage());
}
}
Expand Down Expand Up @@ -373,6 +374,7 @@ public void throwBpmnServiceTask(String serviceTaskId,
.send()
.join();
} catch (Exception e) {
logger.error("throwBpmnServiceTask: Can't execute service task[{}] WorkerId[{}] errorCode[{}] errorMessage[{}]: {}", serviceTaskId, workerId, errorCode, errorMessage, e.getMessage());
throw new AutomatorException("Can't execute service task " + e.getMessage());
}
}
Expand Down Expand Up @@ -443,6 +445,7 @@ public String deployBpmn(File processFile, ScenarioDeployment.Policy policy) thr

return String.valueOf(event.getKey());
} catch (Exception e) {
logger.error("deployBpmn: Can't deploy File[{}] Policy[{}] : {}", processFile.getAbsolutePath(), policy, e.getMessage());
throw new AutomatorException("Can't deploy " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected void connectOperate(StringBuilder analysis) throws AutomatorException


} catch (Exception e) {
logger.error("Can't connect to SaaS environemnt[{}] Analysis:{} : {}", serverDefinition.name, analysis, e);
logger.error("Can't connect to SaaS environemnt[{}] Analysis:{} : {}", serverDefinition.name, analysis, e.getMessage());
throw new AutomatorException(
"Can't connect to SaaS environment[" + serverDefinition.name + "] Analysis:" + analysis + " fail : "
+ e.getMessage());
Expand Down Expand Up @@ -125,7 +125,7 @@ protected void connectOperate(StringBuilder analysis) throws AutomatorException
configuration = new CamundaOperateClientConfiguration(authentication, operateUrl, objectMapper, HttpClients.createDefault());
}
} catch (Exception e) {
logger.error("Can't connect to SaaS environment[{}] Analysis:{} : {}", serverDefinition.name, analysis, e);
logger.error("Can't connect to SaaS environment[{}] Analysis:{} : {}", serverDefinition.name, analysis, e.getMessage());
throw new AutomatorException(
"Can't connect to SaaS environment[" + serverDefinition.name + "] Analysis:" + analysis + " fail : "
+ e.getMessage());
Expand All @@ -145,7 +145,7 @@ protected void connectOperate(StringBuilder analysis) throws AutomatorException
analysis.append("successfully, ");

} catch (Exception e) {
logger.error("Can't connect to Server[{}] Analysis:{} : {}", serverDefinition.name, analysis, e);
logger.error("Can't connect to Server[{}] Analysis:{} : {}", serverDefinition.name, analysis, e.getMessage());
throw new AutomatorException(
"Can't connect to Server[" + serverDefinition.name + "] Analysis:" + analysis + " Fail : " + e.getMessage());
}
Expand Down Expand Up @@ -220,8 +220,8 @@ public List<BpmnEngine.TaskDescription> searchTasksByProcessInstanceId(String pr
BpmnEngine.TaskDescription taskDescription = new BpmnEngine.TaskDescription();
taskDescription.taskId = t.getFlowNodeId();
taskDescription.processInstanceId = String.valueOf(t.getProcessInstanceKey());
taskDescription.startDate = t.getStartDate().getDate();
taskDescription.endDate = t.getEndDate().getDate();
taskDescription.startDate = t.getStartDate()==null? null: t.getStartDate().getDate();
taskDescription.endDate = t.getEndDate()==null? null : t.getEndDate().getDate();
taskDescription.type = getTaskType(t.getType()); // to implement
taskDescription.isCompleted = FlowNodeInstanceState.COMPLETED.equals(t.getState()); // to implement
return taskDescription;
Expand Down Expand Up @@ -337,7 +337,7 @@ public long countNumberOfProcessInstancesCreated(String processId, Date startDat
searchQuery.setSize(SEARCH_MAX_SIZE);
searchResult = operateClient.searchProcessInstanceResults(searchQuery);

cumul += searchResult.getItems().stream().filter(t -> t.getStartDate().getDate().after(startDate)).count();
cumul += searchResult.getItems().stream().filter(t -> t.getStartDate()!=null && t.getStartDate().getDate().after(startDate)).count();

} while (searchResult.getItems().size() >= SEARCH_MAX_SIZE && maxLoop < 1000);
return cumul;
Expand Down Expand Up @@ -372,7 +372,7 @@ public long countNumberOfProcessInstancesEnded(String processId, Date startDate,
SearchQuery searchQuery = queryBuilder.build();
searchQuery.setSize(SEARCH_MAX_SIZE);
searchResult = operateClient.searchProcessInstanceResults(searchQuery);
cumul += searchResult.getItems().stream().filter(t -> t.getStartDate().getDate().after(startDate)).count();
cumul += searchResult.getItems().stream().filter(t -> t.getStartDate() !=null && t.getStartDate().getDate().after(startDate)).count();

} while (searchResult.getItems().size() >= SEARCH_MAX_SIZE && maxLoop < 1000);
return cumul;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void connectTaskList(StringBuilder analysis) throws AutomatorException {
taskListBuilder.taskListUrl(taskListUrl)
.saaSAuthentication(serverDefinition.taskListClientId, serverDefinition.taskListClientSecret);
} catch (Exception e) {
logger.error("Can't connect to SaaS environemnt[{}] Analysis:{} : {}", serverDefinition.name, analysis, e);
logger.error("Can't connect to SaaS environemnt[{}] Analysis:{} : {}", serverDefinition.name, analysis, e.getMessage());
throw new AutomatorException(
"Can't connect to SaaS environment[" + serverDefinition.name + "] Analysis:" + analysis + " fail : "
+ e.getMessage());
Expand Down Expand Up @@ -107,56 +107,10 @@ public void connectTaskList(StringBuilder analysis) throws AutomatorException {
analysis.append("successfully, ");

} catch (Exception e) {
logger.error("Can't connect to Server[{}] Analysis:{} : {}", serverDefinition.name, analysis, e);
logger.error("Can't connect to Server[{}] Analysis:{} : {}", serverDefinition.name, analysis, e.getMessage());
throw new AutomatorException(
"Can't connect to Server[" + serverDefinition.name + "] Analysis:" + analysis + " Fail : " + e.getMessage());
}

/* 1.6.1
boolean isOk = true;
io.camunda.tasklist.auth.AuthInterface saTaskList;
// ---------------------------- Camunda Saas
if (BpmnEngineList.CamundaEngine.CAMUNDA_8_SAAS.equals(this.typeCamundaEngine)) {
try {
saTaskList = new io.camunda.tasklist.auth.SaasAuthentication(serverDefinition.zeebeSaasClientId,
serverDefinition.zeebeSaasClientSecret);
} catch (Exception e) {
logger.error("Can't connect to SaaS environment[{}] Analysis:{} : {}", serverDefinition.name, analysis, e);
throw new AutomatorException(
"Can't connect to SaaS environment[" + serverDefinition.name + "] Analysis:" + analysis + " fail : "
+ e.getMessage());
}
//---------------------------- Camunda 8 Self Manage
} else if (BpmnEngineList.CamundaEngine.CAMUNDA_8.equals(this.typeCamundaEngine)) {
saTaskList = new io.camunda.tasklist.auth.SimpleAuthentication(serverDefinition.operateUserName,
serverDefinition.operateUserPassword);
} else
throw new AutomatorException("Invalid configuration");
if (!isOk)
throw new AutomatorException("Invalid configuration " + analysis);
// ---------------- connection
try {
isOk = engineCamunda8.stillOk(serverDefinition.taskListUrl, "taskListUrl", analysis, false, isOk);
analysis.append("Tasklist ...");
taskClient = new CamundaTaskListClient.Builder().taskListUrl(serverDefinition.taskListUrl)
.authentication(saTaskList)
.build();
analysis.append("successfully, ");
//get tasks assigned to demo
logger.info("Zeebe: OK, Operate: OK, TaskList:OK " + analysis);
} catch (Exception e) {
logger.error("Can't connect to Server[{}] Analysis:{} : {}", serverDefinition.name, analysis, e);
throw new AutomatorException(
"Can't connect to Server[" + serverDefinition.name + "] Analysis:" + analysis + " Fail : " + e.getMessage());
}
*/

}

public List<String> searchUserTasksByProcessInstance(String processInstanceId, String userTaskId, int maxResult)
Expand Down Expand Up @@ -199,7 +153,7 @@ public List<String> searchUserTasksByProcessInstance(String processInstanceId, S
return listTasksResult;

} catch (TaskListException e) {
logger.error("TaskListClient: error during search task [{}]", e.getMessage());
logger.error("TaskListClient: error during search task: {}", e.getMessage());
throw new AutomatorException("Can't search users task " + e.getMessage());
}
}
Expand Down Expand Up @@ -227,6 +181,7 @@ public List<String> searchUserTasks(String userTaskId, int maxResult) throws Aut
return listTasksResult;

} catch (TaskListException e) {
logger.error("SearchUserTask: userId[{}] : {}", userTaskId, e.getMessage());
throw new AutomatorException("Can't search users task " + e.getMessage());
}
}
Expand All @@ -237,8 +192,10 @@ public void executeUserTask(String userTaskId, String userId, Map<String, Object
taskClient.claim(userTaskId, engineCamunda8.getServerDefinition().operateUserName);
taskClient.completeTask(userTaskId, variables);
} catch (TaskListException e) {
logger.error("ExecuteUserTask: taskId[{}] userId[{}] : {}", userTaskId, userId, e.getMessage());
throw new AutomatorException("Can't execute task [" + userTaskId + "]");
} catch (Exception e) {
logger.error("ExecuteUserTask: Exception on taskId[{}] userId[{}] : {}", userTaskId, userId, e.getMessage());
throw new AutomatorException("Can't execute task [" + userTaskId + "]");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,35 @@ public void initializeRepository(String repositoryProposition) throws AutomatorE
}

public Path addResource(Resource resource) throws IOException {
if (resource==null)
return null;
Path targetPath = repositoryPath.resolve(resource.getFilename());
Files.copy(resource.getInputStream(), targetPath, StandardCopyOption.REPLACE_EXISTING);
logger.info("CopiedReource: [{}] tp [{}]", resource.getFilename(), targetPath);
logger.info("CopiedResource: [{}] to [{}]", resource.getFilename(), targetPath);
return targetPath;
}

public Path addFile(Path sourcePath) throws IOException {
Path sourceFileName = sourcePath.getFileName();
// Get the directory from targetPath
Path targetDir = repositoryPath.getParent();
// Combine the directory of targetPath with the filename of sourcePath
Path targetPath = targetDir.resolve(sourceFileName);
Path targetPath = repositoryPath.resolve(sourceFileName);
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
logger.info("CopiedFile: [{}] tp [{}]", sourcePath, targetPath);
logger.info("CopiedFile: [{}] to [{}]", sourcePath, targetPath);
return targetPath;
}

public Path addFromInputStream(InputStream inputStream, String fileName) throws IOException {
OutputStream outputStream = null;
File fileContent = null;
try {
fileContent = new File(repositoryPath + File.separator + fileName);
File fileContent = new File(repositoryPath + File.separator + fileName);
// Open an OutputStream to the temporary file
outputStream = new FileOutputStream(fileContent);
// Transfer data from InputStream to OutputStream
byte[] buffer = new byte[1024 * 100]; // 100Ko
int bytesRead;
int count = 0;

while ((bytesRead = inputStream.read(buffer)) != -1) {
count += bytesRead;
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush();
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/camunda/automator/engine/RunResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public List<ErrorDescription> getListErrors() {
public void addError(ScenarioStep step, String explanation) {
this.listErrors.add(new ErrorDescription(step, explanation));
logger.error((step == null ? "" : step.getType().toString()) + " " + explanation);

}

public void addError(ScenarioStep step, AutomatorException e) {
Expand Down Expand Up @@ -205,7 +204,7 @@ public void merge(RunResult result) {

/**
* Two execution on the exact same execution: we go for a merge plus one step more, we collect additionnal information, like processinstanceIdList
* @param result
* @param result the result to merge
*/
public void mergeDuplicateExecution(RunResult result) {
merge(result);
Expand Down Expand Up @@ -245,8 +244,8 @@ public List<String> getListProcessInstancesId() {
return listProcessInstancesId;
}

public void addListProcessInstancesId(List<String> listProcessInstancesId) {
listProcessInstancesId.addAll(listProcessInstancesId);
public void addListProcessInstancesId(List<String> listProcessInstancesIdParam) {
listProcessInstancesId.addAll(listProcessInstancesIdParam);
}
public List<String> getProcessInstanceId() {
return this.listProcessInstancesId;
Expand Down Expand Up @@ -310,7 +309,7 @@ public String getSynthesis(boolean fullDetail) {
synthesis.append(runScenario.getScenario().getProcessId());
synthesis.append("): ");

StringBuilder append = synthesis.append(timeExecution);
synthesis.append(timeExecution);
synthesis.append(" timeExecution(ms), ");
RecordCreationPI recordCreationPI = recordCreationPIMap.get(runScenario.getScenario().getProcessId());
synthesis.append(recordCreationPI == null ? 0 : recordCreationPI.nbCreated);
Expand Down
Loading

0 comments on commit a74a59f

Please sign in to comment.