Search in sources :

Example 11 with WorkflowsClient

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")));
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent)

Example 12 with WorkflowsClient

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();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient)

Example 13 with WorkflowsClient

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();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) Test(org.junit.Test)

Example 14 with WorkflowsClient

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();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) Test(org.junit.Test)

Example 15 with WorkflowsClient

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));
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) Test(org.junit.Test)

Aggregations

WorkflowsClient (io.zeebe.client.WorkflowsClient)15 Test (org.junit.Test)7 WorkflowInstanceEvent (io.zeebe.client.event.WorkflowInstanceEvent)3 ProcessImpl (io.zeebe.model.bpmn.impl.instance.ProcessImpl)1 InputStream (java.io.InputStream)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1