use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateBpmnProcessById.
@Test
public void shouldCreateBpmnProcessById() {
final WorkflowsClient workflowService = clientRule.workflows();
// when
final WorkflowInstanceEvent workflowInstance = workflowService.create(clientRule.getDefaultTopic()).bpmnProcessId("anId").execute();
// then instance of latest of workflow version is created
assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("anId");
assertThat(workflowInstance.getVersion()).isEqualTo(2);
assertThat(workflowInstance.getWorkflowInstanceKey()).isGreaterThan(0);
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_CREATED")));
}
use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldRejectCreateBpmnProcessByIllegalId.
@Test
public void shouldRejectCreateBpmnProcessByIllegalId() {
final WorkflowsClient workflowService = clientRule.workflows();
// expected
exception.expect(ClientCommandRejectedException.class);
exception.expectMessage("Failed to create instance of workflow with BPMN process id 'illegal' and version '-1'.");
// when
workflowService.create(clientRule.getDefaultTopic()).bpmnProcessId("illegal").execute();
}
use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldNotDeployInvalidModel.
@Test
public void shouldNotDeployInvalidModel() {
// given
final WorkflowsClient workflowService = clientRule.workflows();
// then
exception.expect(ClientCommandRejectedException.class);
exception.expectMessage(containsString("The process must contain at least one none start event."));
// when
workflowService.deploy(clientRule.getDefaultTopic()).addWorkflowModel(Bpmn.createExecutableWorkflow("no-start-event").done(), // does not have a start event
"invalid.bpmn").execute();
}
use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldDeployMultipleResources.
@Test
public void shouldDeployMultipleResources() {
// given
final WorkflowsClient workflowService = clientRule.workflows();
// when
final DeploymentEvent result = workflowService.deploy(clientRule.getDefaultTopic()).addWorkflowModel(Bpmn.createExecutableWorkflow("model1").startEvent().done(), "model1.bpmn").addWorkflowModel(Bpmn.createExecutableWorkflow("model2").startEvent().done(), "model2.bpmn").execute();
// then
assertThat(result.getResources()).hasSize(2).extracting(DeploymentResource::getResourceName).contains("model1.bpmn", "model2.bpmn");
assertThat(result.getDeployedWorkflows()).hasSize(2).extracting(WorkflowDefinition::getBpmnProcessId).contains("model1", "model2");
assertThat(eventRecorder.hasWorkflowEvent(w -> w.getBpmnProcessId().equals("model1"))).isTrue();
assertThat(eventRecorder.hasWorkflowEvent(w -> w.getBpmnProcessId().equals("model2"))).isTrue();
}
use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldDeployWorkflowModel.
@Test
public void shouldDeployWorkflowModel() {
// given
final WorkflowsClient workflowService = clientRule.workflows();
final io.zeebe.model.bpmn.instance.WorkflowDefinition workflow = Bpmn.createExecutableWorkflow("process").startEvent().endEvent().done();
// when
final DeploymentEvent result = workflowService.deploy(clientRule.getDefaultTopic()).addWorkflowModel(workflow, "workflow.bpmn").execute();
// then
assertThat(result.getMetadata().getKey()).isGreaterThan(0);
assertThat(result.getResources()).hasSize(1);
final DeploymentResource deployedResource = result.getResources().get(0);
assertThat(deployedResource.getResource()).isEqualTo(Bpmn.convertToString(workflow).getBytes(UTF_8));
assertThat(deployedResource.getResourceType()).isEqualTo(ResourceType.BPMN_XML);
assertThat(deployedResource.getResourceName()).isEqualTo("workflow.bpmn");
assertThat(result.getDeployedWorkflows()).hasSize(1);
final WorkflowDefinition deployedWorkflow = result.getDeployedWorkflows().get(0);
assertThat(deployedWorkflow.getBpmnProcessId()).isEqualTo("process");
assertThat(deployedWorkflow.getVersion()).isEqualTo(1);
waitUntil(() -> eventRecorder.hasWorkflowEvent(wfEvent("CREATED")));
final WorkflowEvent workflowEvent = eventRecorder.getSingleWorkflowEvent(wfEvent("CREATED"));
assertThat(workflowEvent.getBpmnProcessId()).isEqualTo("process");
assertThat(workflowEvent.getVersion()).isEqualTo(1);
assertThat(workflowEvent.getDeploymentKey()).isEqualTo(result.getMetadata().getKey());
assertThat(workflowEvent.getBpmnXml()).isEqualTo(Bpmn.convertToString(workflow));
}
Aggregations