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());
}
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());
}
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);
}
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();
}
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);
}
}
Aggregations