use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zdb by Zelldon.
the class ZeebeTest method shouldOpenAndReadState.
@Test
public void shouldOpenAndReadState() {
// given
final ZeebeClient client = ZeebeClient.newClientBuilder().gatewayAddress(zeebeContainer.getExternalGatewayAddress()).usePlaintext().build();
final BpmnModelInstance process = Bpmn.createExecutableProcess("process").startEvent().endEvent().done();
final DeploymentEvent deploymentEvent = client.newDeployCommand().addProcessModel(process, "process.bpmn").send().join();
// when
final var readonlyTransactionDb = ReadonlyTransactionDb.Companion.openReadonlyDb(ZeebePaths.Companion.getRuntimePath(tempDir, "1"));
var zeebeState = new ZeebeDbState(readonlyTransactionDb, readonlyTransactionDb.createContext());
// then
final var processState = zeebeState.getProcessState();
final var processes = processState.getProcesses();
assertThat(processes).hasSize(1);
final var deployedProcesses = new ArrayList<DeployedProcess>(processes);
final var deployedProcess = deployedProcesses.get(0);
assertThat(deployedProcess.getVersion()).isEqualTo(1);
assertThat(deployedProcess.getBpmnProcessId()).isEqualTo(BufferUtil.wrapString("process"));
assertThat(deployedProcess.getResourceName()).isEqualTo(BufferUtil.wrapString("process.bpmn"));
assertThat(deployedProcess.getKey()).isEqualTo(deploymentEvent.getProcesses().get(0).getProcessDefinitionKey());
}
use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zdb by Zelldon.
the class ZeebeTest method shouldRunProcessInstanceUntilEnd.
/**
* Just ot verify whether test container works with Zeebe Client.
*/
@Test
public void shouldRunProcessInstanceUntilEnd() {
// given
final ZeebeClient client = ZeebeClient.newClientBuilder().gatewayAddress(zeebeContainer.getExternalGatewayAddress()).usePlaintext().build();
final BpmnModelInstance process = Bpmn.createExecutableProcess("process").startEvent().endEvent().done();
// when
final DeploymentEvent deploymentEvent = client.newDeployCommand().addProcessModel(process, "process.bpmn").send().join();
// then
final ProcessInstanceResult processInstanceResult = client.newCreateInstanceCommand().bpmnProcessId("process").latestVersion().withResult().send().join();
assertThat(processInstanceResult.getProcessDefinitionKey()).isEqualTo(deploymentEvent.getProcesses().get(0).getProcessDefinitionKey());
}
use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zeebe-dmn-worker by camunda-community-hub.
the class WorkflowTest method init.
@BeforeAll
public static void init() {
final var gatewayAddress = ZEEBE_CONTAINER.getExternalGatewayAddress();
System.setProperty("zeebe.client.broker.gatewayAddress", gatewayAddress);
ZEEBE_CLIENT = ZeebeClient.newClientBuilder().gatewayAddress(gatewayAddress).usePlaintext().build();
// given
final BpmnModelInstance process = Bpmn.createExecutableProcess("process").startEvent().serviceTask("make-decision").zeebeJobType("DMN").zeebeTaskHeader("decisionRef", "decision").endEvent().done();
ZEEBE_CLIENT.newDeployCommand().addProcessModel(process, "process.bpmn").send().join();
}
use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project zeebe-test-container by camunda-community-hub.
the class TriggerTimerCatchEventTest method shouldTriggerTimerStartEvent.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void shouldTriggerTimerStartEvent() {
// given
final ZeebeClock clock = ZeebeClock.newDefaultClock(zeebeContainer);
final BpmnModelInstance process = Bpmn.createExecutableProcess("process").startEvent().intermediateCatchEvent().timerWithDate(TIMER_DATE.toString()).serviceTask("task", b -> b.zeebeJobType(JOB_TYPE)).endEvent().done();
final List<ActivatedJob> activatedJobs = new CopyOnWriteArrayList<>();
final Instant brokerTime;
// when
final JobHandler handler = (client, job) -> activatedJobs.add(job);
try (final ZeebeClient client = newZeebeClient(zeebeContainer);
final JobWorker worker = newJobWorker(handler, client)) {
client.newDeployCommand().addProcessModel(process, "process.bpmn").send().join();
client.newCreateInstanceCommand().bpmnProcessId("process").latestVersion().send().join();
brokerTime = clock.addTime(TIME_OFFSET);
Awaitility.await("until a job has been activated by the worker").untilAsserted(() -> Assertions.assertThat(activatedJobs).hasSize(1));
}
// then
Assertions.assertThat(activatedJobs).as("the timer event was triggered and a job is now available").hasSize(1);
Assertions.assertThat(brokerTime).as("the modified time is at least equal to one day from now").isAfterOrEqualTo(TIMER_DATE);
}
use of io.camunda.zeebe.model.bpmn.BpmnModelInstance in project spring-zeebe by camunda-community-hub.
the class JobHandlerTest method testAutoCompleteOnAlreadyCompletedJob.
@Test
public void testAutoCompleteOnAlreadyCompletedJob() {
BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess("test2").startEvent().serviceTask().zeebeJobType("test2").endEvent().done();
client.newDeployResourceCommand().addProcessModel(bpmnModel, "test2.bpmn").send().join();
ProcessInstanceEvent processInstance = startProcessInstance(client, "test2");
// assertThat(processInstance).isStarted();
waitForProcessInstanceCompleted(processInstance);
assertTrue(calledTest2);
}
Aggregations