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