Search in sources :

Example 1 with DEPLOYMENT_EVENT

use of io.zeebe.protocol.clientapi.EventType.DEPLOYMENT_EVENT in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldCreateDeployment.

@Test
public void shouldCreateDeployment() {
    // given
    final List<Map<String, Object>> deployedWorkflows = new ArrayList<>();
    Map<String, Object> deployedWorkflow = new HashMap<>();
    deployedWorkflow.put("bpmnProcessId", "foo");
    deployedWorkflow.put("version", 1);
    deployedWorkflows.add(deployedWorkflow);
    deployedWorkflow = new HashMap<>();
    deployedWorkflow.put("bpmnProcessId", "bar");
    deployedWorkflow.put("version", 2);
    deployedWorkflows.add(deployedWorkflow);
    brokerRule.onExecuteCommandRequest(r -> r.eventType() == DEPLOYMENT_EVENT).respondWith().key(2L).event().put("state", "CREATED").put("deployedWorkflows", deployedWorkflows).done().register();
    // when
    final DeploymentEvent deployment = clientRule.workflows().deploy(clientRule.getDefaultTopicName()).addWorkflowModel(WORKFLOW_MODEL, "model.bpmn").execute();
    // then
    assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
    final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
    assertThat(commandRequest.key()).isEqualTo(-1);
    assertThat(commandRequest.getCommand()).containsEntry("state", "CREATE");
    assertThat(deployment.getMetadata().getKey()).isEqualTo(2L);
    assertThat(deployment.getDeployedWorkflows()).hasSize(2);
    assertThat(deployment.getDeployedWorkflows()).extracting("bpmnProcessId").contains("foo", "bar");
    assertThat(deployment.getDeployedWorkflows()).extracting("version").contains(1, 2);
}
Also used : DEPLOYMENT_EVENT(io.zeebe.protocol.clientapi.EventType.DEPLOYMENT_EVENT) java.util(java.util) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.zeebe.model.bpmn.Bpmn) Protocol(io.zeebe.protocol.Protocol) File(java.io.File) ZeebeClient(io.zeebe.client.ZeebeClient) StubBrokerRule(io.zeebe.test.broker.protocol.brokerapi.StubBrokerRule) RuleChain(org.junit.rules.RuleChain) ClientRule(io.zeebe.client.util.ClientRule) ByteArrayInputStream(java.io.ByteArrayInputStream) ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) org.junit(org.junit) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) DeploymentEvent(io.zeebe.client.event.DeploymentEvent) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) ExpectedException(org.junit.rules.ExpectedException) ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) DeploymentEvent(io.zeebe.client.event.DeploymentEvent)

Aggregations

ZeebeClient (io.zeebe.client.ZeebeClient)1 ClientCommandRejectedException (io.zeebe.client.cmd.ClientCommandRejectedException)1 DeploymentEvent (io.zeebe.client.event.DeploymentEvent)1 ClientRule (io.zeebe.client.util.ClientRule)1 Bpmn (io.zeebe.model.bpmn.Bpmn)1 WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)1 Protocol (io.zeebe.protocol.Protocol)1 DEPLOYMENT_EVENT (io.zeebe.protocol.clientapi.EventType.DEPLOYMENT_EVENT)1 ExecuteCommandRequest (io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest)1 StubBrokerRule (io.zeebe.test.broker.protocol.brokerapi.StubBrokerRule)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 java.util (java.util)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 org.junit (org.junit)1 ExpectedException (org.junit.rules.ExpectedException)1 RuleChain (org.junit.rules.RuleChain)1