Search in sources :

Example 1 with DeploymentEvent

use of io.camunda.zeebe.client.api.response.DeploymentEvent 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());
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ArrayList(java.util.ArrayList) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) ZeebeDbState(io.camunda.zeebe.engine.state.ZeebeDbState) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Example 2 with DeploymentEvent

use of io.camunda.zeebe.client.api.response.DeploymentEvent 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());
}
Also used : ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) ZeebeClient(io.camunda.zeebe.client.ZeebeClient) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Example 3 with DeploymentEvent

use of io.camunda.zeebe.client.api.response.DeploymentEvent in project zeebe-process-test by camunda.

the class EngineClientTest method shouldCreateProcessInstance.

@Test
void shouldCreateProcessInstance() {
    // given
    final DeploymentEvent deployment = zeebeClient.newDeployCommand().addProcessModel(Bpmn.createExecutableProcess("simpleProcess").startEvent().endEvent().done(), "simpleProcess.bpmn").send().join();
    // when
    final ProcessInstanceEvent processInstance = zeebeClient.newCreateInstanceCommand().bpmnProcessId("simpleProcess").latestVersion().variables(Map.of("test", 1)).send().join();
    // then
    assertThat(processInstance.getProcessInstanceKey()).isPositive();
    assertThat(processInstance.getBpmnProcessId()).isEqualTo("simpleProcess");
    assertThat(processInstance.getProcessDefinitionKey()).isEqualTo(deployment.getProcesses().get(0).getProcessDefinitionKey());
    assertThat(processInstance.getVersion()).isEqualTo(1);
}
Also used : ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Example 4 with DeploymentEvent

use of io.camunda.zeebe.client.api.response.DeploymentEvent in project zeebe-process-test by camunda.

the class AbstractProcessEventInspectionsTest method testFindLastProcessInstance.

@Test
void testFindLastProcessInstance() throws InterruptedException {
    // given
    final DeploymentEvent deploymentEvent = Utilities.deployProcess(getClient(), ProcessPackTimerStartEvent.RESOURCE_NAME);
    // when
    Utilities.increaseTime(getEngine(), Duration.ofDays(1));
    final Optional<InspectedProcessInstance> lastProcessInstance = InspectionUtility.findProcessEvents().triggeredByTimer(ProcessPackTimerStartEvent.TIMER_ID).withProcessDefinitionKey(deploymentEvent.getProcesses().get(0).getProcessDefinitionKey()).findLastProcessInstance();
    // then
    Assertions.assertThat(lastProcessInstance).isNotEmpty();
    BpmnAssert.assertThat(lastProcessInstance.get()).isCompleted();
}
Also used : InspectedProcessInstance(io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) Test(org.junit.jupiter.api.Test)

Example 5 with DeploymentEvent

use of io.camunda.zeebe.client.api.response.DeploymentEvent in project zeebe-test-container by camunda-community-hub.

the class ZeebeBrokerNodeTest method shouldReuseHostDataOnRestart.

@Timeout(value = 5, unit = TimeUnit.MINUTES)
@ParameterizedTest(name = "{0}")
@MethodSource("reuseDataTestCases")
@EnabledOnOs(LINUX)
void shouldReuseHostDataOnRestart(@SuppressWarnings("unused") final String testName, final BrokerNodeProvider brokerNodeProvider, @TempDir final Path dataDir) {
    // given
    final ZeebeBrokerNode<?> broker = brokerNodeProvider.apply(dataDir);
    final ZeebeGatewayContainer gateway = new ZeebeGatewayContainer().withEnv("ZEEBE_GATEWAY_CLUSTER_CONTACTPOINT", broker.getInternalClusterAddress());
    // when
    broker.start();
    gateway.start();
    try (final ZeebeClient client = ZeebeClientFactory.newZeebeClient(gateway)) {
        // deploy a new process, which we can use on restart to assert that the data was correctly
        // reused
        final DeploymentEvent deployment = deploySampleProcess(client);
        broker.stop();
        // on restart we need to wait until the gateway is aware of the new leader
        broker.start();
        awaitUntilTopologyIsComplete(client);
        final ProcessInstanceEvent processInstance = createSampleProcessInstance(client);
        // then
        assertThat(processInstance).as("the process instance was successfully created").isNotNull().extracting(ProcessInstanceEvent::getProcessDefinitionKey).isEqualTo(deployment.getProcesses().get(0).getProcessDefinitionKey());
    } finally {
        CloseHelper.quietCloseAll(gateway, broker);
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Timeout(org.junit.jupiter.api.Timeout) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)73 Test (org.junit.Test)26 Test (org.junit.jupiter.api.Test)26 ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)12 ClientTest (io.camunda.zeebe.client.util.ClientTest)12 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)11 Process (io.camunda.zeebe.client.api.response.Process)11 ProcessImpl (io.camunda.zeebe.client.impl.response.ProcessImpl)10 InspectedProcessInstance (io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance)8 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)7 ProcessInstanceResult (io.camunda.zeebe.client.api.response.ProcessInstanceResult)6 RetriableClientFutureImpl (io.camunda.zeebe.client.impl.RetriableClientFutureImpl)5 DeploymentEventImpl (io.camunda.zeebe.client.impl.response.DeploymentEventImpl)5 DeployProcessRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployProcessRequest)5 ZeebeClientBuilder (io.camunda.zeebe.client.ZeebeClientBuilder)3 ActivateJobsResponse (io.camunda.zeebe.client.api.response.ActivateJobsResponse)3 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)3 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)3 ZeebeFuture (io.camunda.zeebe.client.api.ZeebeFuture)2 ClientException (io.camunda.zeebe.client.api.command.ClientException)2