use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldCreateDeploymentWithMultipleResourcesAndWorkflows.
@Test
public void shouldCreateDeploymentWithMultipleResourcesAndWorkflows() throws IOException {
// given
final WorkflowDefinition singleWorkflow = Bpmn.createExecutableWorkflow("singleProcess").startEvent().done();
final InputStream multipleWorkflowsResource = getClass().getResourceAsStream("/workflows/collaboration.bpmn");
final List<Map<String, Object>> resources = Arrays.asList(deploymentResource(bpmnXml(singleWorkflow), "process1.bpmn"), deploymentResource(StreamUtil.read(multipleWorkflowsResource), "collaboration.bpmn"));
// when
final ExecuteCommandResponse resp = apiRule.createCmdRequest().partitionId(Protocol.SYSTEM_PARTITION).eventType(EventType.DEPLOYMENT_EVENT).command().put(PROP_STATE, "CREATE").put("topicName", ClientApiRule.DEFAULT_TOPIC_NAME).put("resources", resources).done().sendAndAwait();
// then
assertThat(resp.getEvent()).containsEntry(PROP_STATE, "CREATED");
final List<SubscribedEvent> workflowEvents = apiRule.topic().receiveEvents(workflowEvents("CREATED")).limit(3).collect(toList());
assertThat(workflowEvents).extracting(s -> s.event().get(PROP_WORKFLOW_BPMN_PROCESS_ID)).contains("singleProcess", "process1", "process2");
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldCreateDeploymentWithMultipleResources.
@Test
public void shouldCreateDeploymentWithMultipleResources() {
// given
final WorkflowDefinition definition1 = Bpmn.createExecutableWorkflow("process1").startEvent().done();
final WorkflowDefinition definition2 = Bpmn.createExecutableWorkflow("process2").startEvent().done();
final List<Map<String, Object>> resources = Arrays.asList(deploymentResource(bpmnXml(definition1), "process1.bpmn"), deploymentResource(bpmnXml(definition2), "process2.bpmn"));
// when
final ExecuteCommandResponse resp = apiRule.createCmdRequest().partitionId(Protocol.SYSTEM_PARTITION).eventType(EventType.DEPLOYMENT_EVENT).command().put(PROP_STATE, "CREATE").put("topicName", ClientApiRule.DEFAULT_TOPIC_NAME).put("resources", resources).done().sendAndAwait();
// then
assertThat(resp.getEvent()).containsEntry(PROP_STATE, "CREATED");
final List<SubscribedEvent> workflowEvents = apiRule.topic().receiveEvents(workflowEvents("CREATED")).limit(2).collect(toList());
assertThat(workflowEvents).extracting(s -> s.event().get(PROP_WORKFLOW_BPMN_PROCESS_ID)).contains("process1", "process2");
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldRejectDeploymentIfNotValid.
@Test
public void shouldRejectDeploymentIfNotValid() {
// given
final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").done();
// when
final ExecuteCommandResponse resp = apiRule.topic().deployWithResponse(ClientApiRule.DEFAULT_TOPIC_NAME, definition);
// then
assertThat(resp.key()).isGreaterThanOrEqualTo(0L);
assertThat(resp.getEvent()).containsEntry(PROP_STATE, "REJECTED");
assertThat((String) resp.getEvent().get("errorMessage")).contains("The process must contain at least one none start event.");
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateWorkflowInstanceOnAllPartitions.
@Test
public void shouldCreateWorkflowInstanceOnAllPartitions() {
// given
final int partitions = 3;
apiRule.createTopic("test", partitions);
final List<Integer> partitionIds = apiRule.getPartitionIds("test");
final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").startEvent().endEvent().done();
// when
apiRule.topic().deploy("test", definition);
// then
final List<Long> workflowInstanceKeys = new ArrayList<>();
partitionIds.forEach(partitionId -> {
final long workflowInstanceKey = apiRule.topic(partitionId).createWorkflowInstance("process");
workflowInstanceKeys.add(workflowInstanceKey);
});
assertThat(workflowInstanceKeys).hasSize(partitions).allMatch(k -> k > 0);
}
use of io.zeebe.model.bpmn.instance.WorkflowDefinition in project zeebe by zeebe-io.
the class WorkflowInstanceFunctionalTest method shouldCompleteServiceTaskWhenTaskIsCompleted.
@Test
public void shouldCompleteServiceTaskWhenTaskIsCompleted() {
// given
final WorkflowDefinition definition = Bpmn.createExecutableWorkflow("process").startEvent().serviceTask("foo", t -> t.taskType("bar")).endEvent().done();
testClient.deploy(definition);
final long workflowInstanceKey = testClient.createWorkflowInstance("process");
// when
testClient.completeTaskOfType("bar");
// then
final SubscribedEvent activityActivatedEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_ACTIVATED"));
final SubscribedEvent activityCompletedEvent = testClient.receiveSingleEvent(workflowInstanceEvents("ACTIVITY_COMPLETED"));
assertThat(activityCompletedEvent.key()).isEqualTo(activityActivatedEvent.key());
assertThat(activityCompletedEvent.event()).containsEntry(PROP_WORKFLOW_BPMN_PROCESS_ID, "process").containsEntry(PROP_WORKFLOW_VERSION, 1).containsEntry(PROP_WORKFLOW_INSTANCE_KEY, workflowInstanceKey).containsEntry(PROP_WORKFLOW_ACTIVITY_ID, "foo");
}
Aggregations