Search in sources :

Example 1 with ZeebeFuture

use of io.camunda.zeebe.client.api.ZeebeFuture in project zeebe by camunda.

the class CreateProcessInstanceWithResultTest method shouldOnlyReturnVariablesInRootScope.

@Test
public void shouldOnlyReturnVariablesInRootScope() {
    // given
    final BpmnModelInstance processWithVariableScopes = Bpmn.createExecutableProcess(processId).startEvent().subProcess("sub", b -> {
        b.embeddedSubProcess().startEvent().serviceTask("task", t -> t.zeebeJobType(jobType)).endEvent();
        b.zeebeInputExpression("x", "y");
    }).endEvent().done();
    processDefinitionKey = CLIENT_RULE.deployProcess(processWithVariableScopes);
    final ZeebeFuture<ProcessInstanceResult> resultFuture = createProcessInstanceWithVariables(Map.of("x", "1"));
    // when
    completeJobWithVariables(Map.of("y", "2"));
    // then
    final ProcessInstanceResult result = resultFuture.join();
    assertThat(result.getBpmnProcessId()).isEqualTo(processId);
    assertThat(result.getProcessDefinitionKey()).isEqualTo(processDefinitionKey);
    assertThat(result.getVariablesAsMap()).containsExactly(entry("x", "1"));
}
Also used : ClientException(io.camunda.zeebe.client.api.command.ClientException) ZeebeFuture(io.camunda.zeebe.client.api.ZeebeFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) Test(org.junit.Test) BrokerClassRuleHelper(io.camunda.zeebe.test.util.BrokerClassRuleHelper) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) RuleChain(org.junit.rules.RuleChain) Rule(org.junit.Rule) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) GrpcClientRule(io.camunda.zeebe.it.util.GrpcClientRule) TestUtil.waitUntil(io.camunda.zeebe.test.util.TestUtil.waitUntil) EmbeddedBrokerRule(io.camunda.zeebe.broker.test.EmbeddedBrokerRule) Maps(io.camunda.zeebe.test.util.collection.Maps) Map(java.util.Map) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Map.entry(java.util.Map.entry) ActivateJobsResponse(io.camunda.zeebe.client.api.response.ActivateJobsResponse) ClassRule(org.junit.ClassRule) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent) Before(org.junit.Before) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 2 with ZeebeFuture

use of io.camunda.zeebe.client.api.ZeebeFuture in project zeebe by zeebe-io.

the class CreateProcessInstanceWithResultTest method shouldOnlyReturnVariablesInRootScope.

@Test
public void shouldOnlyReturnVariablesInRootScope() {
    // given
    final BpmnModelInstance processWithVariableScopes = Bpmn.createExecutableProcess(processId).startEvent().subProcess("sub", b -> {
        b.embeddedSubProcess().startEvent().serviceTask("task", t -> t.zeebeJobType(jobType)).endEvent();
        b.zeebeInputExpression("x", "y");
    }).endEvent().done();
    processDefinitionKey = CLIENT_RULE.deployProcess(processWithVariableScopes);
    final ZeebeFuture<ProcessInstanceResult> resultFuture = createProcessInstanceWithVariables(Map.of("x", "1"));
    // when
    completeJobWithVariables(Map.of("y", "2"));
    // then
    final ProcessInstanceResult result = resultFuture.join();
    assertThat(result.getBpmnProcessId()).isEqualTo(processId);
    assertThat(result.getProcessDefinitionKey()).isEqualTo(processDefinitionKey);
    assertThat(result.getVariablesAsMap()).containsExactly(entry("x", "1"));
}
Also used : ClientException(io.camunda.zeebe.client.api.command.ClientException) ZeebeFuture(io.camunda.zeebe.client.api.ZeebeFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) Test(org.junit.Test) BrokerClassRuleHelper(io.camunda.zeebe.test.util.BrokerClassRuleHelper) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) RuleChain(org.junit.rules.RuleChain) Rule(org.junit.Rule) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) GrpcClientRule(io.camunda.zeebe.it.util.GrpcClientRule) TestUtil.waitUntil(io.camunda.zeebe.test.util.TestUtil.waitUntil) EmbeddedBrokerRule(io.camunda.zeebe.broker.test.EmbeddedBrokerRule) Maps(io.camunda.zeebe.test.util.collection.Maps) Map(java.util.Map) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Map.entry(java.util.Map.entry) ActivateJobsResponse(io.camunda.zeebe.client.api.response.ActivateJobsResponse) ClassRule(org.junit.ClassRule) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent) Before(org.junit.Before) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 3 with ZeebeFuture

use of io.camunda.zeebe.client.api.ZeebeFuture in project zeebe by camunda-cloud.

the class CreateProcessInstanceWithResultTest method shouldOnlyReturnVariablesInRootScope.

@Test
public void shouldOnlyReturnVariablesInRootScope() {
    // given
    final BpmnModelInstance processWithVariableScopes = Bpmn.createExecutableProcess(processId).startEvent().subProcess("sub", b -> {
        b.embeddedSubProcess().startEvent().serviceTask("task", t -> t.zeebeJobType(jobType)).endEvent();
        b.zeebeInputExpression("x", "y");
    }).endEvent().done();
    processDefinitionKey = CLIENT_RULE.deployProcess(processWithVariableScopes);
    final ZeebeFuture<ProcessInstanceResult> resultFuture = createProcessInstanceWithVariables(Map.of("x", "1"));
    // when
    completeJobWithVariables(Map.of("y", "2"));
    // then
    final ProcessInstanceResult result = resultFuture.join();
    assertThat(result.getBpmnProcessId()).isEqualTo(processId);
    assertThat(result.getProcessDefinitionKey()).isEqualTo(processDefinitionKey);
    assertThat(result.getVariablesAsMap()).containsExactly(entry("x", "1"));
}
Also used : ClientException(io.camunda.zeebe.client.api.command.ClientException) ZeebeFuture(io.camunda.zeebe.client.api.ZeebeFuture) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) Test(org.junit.Test) BrokerClassRuleHelper(io.camunda.zeebe.test.util.BrokerClassRuleHelper) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) RuleChain(org.junit.rules.RuleChain) Rule(org.junit.Rule) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) GrpcClientRule(io.camunda.zeebe.it.util.GrpcClientRule) TestUtil.waitUntil(io.camunda.zeebe.test.util.TestUtil.waitUntil) EmbeddedBrokerRule(io.camunda.zeebe.broker.test.EmbeddedBrokerRule) Maps(io.camunda.zeebe.test.util.collection.Maps) Map(java.util.Map) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Map.entry(java.util.Map.entry) ActivateJobsResponse(io.camunda.zeebe.client.api.response.ActivateJobsResponse) ClassRule(org.junit.ClassRule) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent) Before(org.junit.Before) ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Aggregations

EmbeddedBrokerRule (io.camunda.zeebe.broker.test.EmbeddedBrokerRule)3 ZeebeFuture (io.camunda.zeebe.client.api.ZeebeFuture)3 ClientException (io.camunda.zeebe.client.api.command.ClientException)3 ActivateJobsResponse (io.camunda.zeebe.client.api.response.ActivateJobsResponse)3 ProcessInstanceResult (io.camunda.zeebe.client.api.response.ProcessInstanceResult)3 GrpcClientRule (io.camunda.zeebe.it.util.GrpcClientRule)3 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)3 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)3 JobIntent (io.camunda.zeebe.protocol.record.intent.JobIntent)3 BrokerClassRuleHelper (io.camunda.zeebe.test.util.BrokerClassRuleHelper)3 TestUtil.waitUntil (io.camunda.zeebe.test.util.TestUtil.waitUntil)3 Maps (io.camunda.zeebe.test.util.collection.Maps)3 RecordingExporter (io.camunda.zeebe.test.util.record.RecordingExporter)3 Map (java.util.Map)3 Map.entry (java.util.Map.entry)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)3 Before (org.junit.Before)3 ClassRule (org.junit.ClassRule)3 Rule (org.junit.Rule)3