-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3740be
commit 2918731
Showing
5 changed files
with
93 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 51 additions & 44 deletions
95
...ution-migrated/src/test/java/org/camunda/community/migration/example/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,79 @@ | ||
package org.camunda.community.migration.example; | ||
|
||
import io.camunda.process.test.api.CamundaAssert; | ||
import io.camunda.process.test.api.CamundaSpringProcessTest; | ||
import io.camunda.zeebe.client.ZeebeClient; | ||
import io.camunda.zeebe.client.api.response.ActivatedJob; | ||
import io.camunda.zeebe.client.api.response.ProcessInstanceEvent; | ||
import io.camunda.zeebe.process.test.api.ZeebeTestEngine; | ||
import io.camunda.zeebe.spring.test.ZeebeSpringTest; | ||
import org.camunda.bpm.engine.variable.Variables; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.testcontainers.Testcontainers; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import static io.camunda.zeebe.process.test.assertions.BpmnAssert.assertThat; | ||
import static io.camunda.zeebe.protocol.Protocol.*; | ||
import static io.camunda.zeebe.spring.test.ZeebeTestThreadSupport.*; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.*; | ||
|
||
@SpringBootTest | ||
@ZeebeSpringTest | ||
@CamundaSpringProcessTest | ||
public class ApplicationTest { | ||
|
||
@Autowired ZeebeClient zeebeClient; | ||
|
||
@Autowired ZeebeTestEngine zeebeTestEngine; | ||
@Autowired | ||
ZeebeClient zeebeClient; | ||
|
||
@Test | ||
void shouldRunProcess_withUserTask() throws InterruptedException, TimeoutException { | ||
ProcessInstanceEvent processInstance = | ||
zeebeClient | ||
.newCreateInstanceCommand() | ||
.bpmnProcessId("sample-process-solution-process") | ||
.latestVersion() | ||
.variables(Variables.createVariables().putValue("x", 7)) | ||
.send() | ||
.join(); | ||
waitForProcessInstanceHasPassedElement(processInstance, "main-process"); | ||
zeebeTestEngine.waitForIdleState(Duration.ofMinutes(1)); | ||
assertThat(processInstance).isWaitingAtElements("say-hello"); | ||
List<ActivatedJob> userTasks = | ||
zeebeClient | ||
.newActivateJobsCommand() | ||
.jobType(USER_TASK_JOB_TYPE) | ||
.maxJobsToActivate(1) | ||
.send() | ||
.join() | ||
.getJobs(); | ||
ProcessInstanceEvent processInstance = zeebeClient | ||
.newCreateInstanceCommand() | ||
.bpmnProcessId("sample-process-solution-process") | ||
.latestVersion() | ||
.variables(Variables | ||
.createVariables() | ||
.putValue("x", 7)) | ||
.send() | ||
.join(); | ||
CamundaAssert | ||
.assertThat(processInstance) | ||
.hasCompletedElements("Sub Process"); | ||
CamundaAssert | ||
.assertThat(processInstance) | ||
.hasActiveElements("Say hello to\n" + "demo"); | ||
List<ActivatedJob> userTasks = zeebeClient | ||
.newActivateJobsCommand() | ||
.jobType(USER_TASK_JOB_TYPE) | ||
.maxJobsToActivate(100) | ||
.send() | ||
.join() | ||
.getJobs() | ||
.stream() | ||
.filter(j -> j.getProcessInstanceKey() == processInstance.getProcessInstanceKey()) | ||
.toList(); | ||
assertThat(userTasks).hasSize(1); | ||
zeebeClient.newCompleteCommand(userTasks.get(0)).send().join(); | ||
waitForProcessInstanceCompleted(processInstance); | ||
assertThat(processInstance).isCompleted(); | ||
zeebeClient | ||
.newCompleteCommand(userTasks.get(0)) | ||
.send() | ||
.join(); | ||
CamundaAssert | ||
.assertThat(processInstance) | ||
.hasCompletedElements("Say hello to\n" + "demo") | ||
.isCompleted(); | ||
} | ||
|
||
@Test | ||
void shouldRunProcess_withoutUserTask() throws InterruptedException, TimeoutException { | ||
ProcessInstanceEvent processInstance = | ||
zeebeClient | ||
.newCreateInstanceCommand() | ||
.bpmnProcessId("sample-process-solution-process") | ||
.latestVersion() | ||
.variables(Variables.createVariables().putValue("x", 5)) | ||
.send() | ||
.join(); | ||
waitForProcessInstanceCompleted(processInstance); | ||
assertThat(processInstance).isCompleted().hasPassedElement("Event_15mbd4d"); | ||
ProcessInstanceEvent processInstance = zeebeClient | ||
.newCreateInstanceCommand() | ||
.bpmnProcessId("sample-process-solution-process") | ||
.latestVersion() | ||
.variables(Variables | ||
.createVariables() | ||
.putValue("x", 5)) | ||
.send() | ||
.join(); | ||
CamundaAssert | ||
.assertThat(processInstance) | ||
.isCompleted(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters