Search in sources :

Example 1 with WorkflowsClient

use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldDeployYamlWorkflow.

@Test
public void shouldDeployYamlWorkflow() {
    // given
    final WorkflowsClient workflowService = clientRule.workflows();
    // when
    final DeploymentEvent result = workflowService.deploy(clientRule.getDefaultTopic()).addResourceFromClasspath("workflows/simple-workflow.yaml").execute();
    // then
    assertThat(result.getMetadata().getKey()).isGreaterThan(0);
    assertThat(result.getResources()).hasSize(1);
    final DeploymentResource deployedResource = result.getResources().get(0);
    assertThat(deployedResource.getResourceType()).isEqualTo(ResourceType.YAML_WORKFLOW);
    assertThat(deployedResource.getResourceName()).isEqualTo("workflows/simple-workflow.yaml");
    assertThat(result.getDeployedWorkflows()).hasSize(1);
    final WorkflowDefinition deployedWorkflow = result.getDeployedWorkflows().get(0);
    assertThat(deployedWorkflow.getBpmnProcessId()).isEqualTo("yaml-workflow");
    assertThat(deployedWorkflow.getVersion()).isEqualTo(1);
    waitUntil(() -> eventRecorder.hasWorkflowEvent(wfEvent("CREATED")));
    final InputStream yamlStream = getClass().getResourceAsStream("/workflows/simple-workflow.yaml");
    final io.zeebe.model.bpmn.instance.WorkflowDefinition workflowDefinition = Bpmn.readFromYamlStream(yamlStream);
    final String bpmnXml = Bpmn.convertToString(workflowDefinition);
    final WorkflowEvent workflowEvent = eventRecorder.getSingleWorkflowEvent(wfEvent("CREATED"));
    assertThat(workflowEvent.getBpmnProcessId()).isEqualTo("yaml-workflow");
    assertThat(workflowEvent.getVersion()).isEqualTo(1);
    assertThat(workflowEvent.getDeploymentKey()).isEqualTo(result.getMetadata().getKey());
    assertThat(workflowEvent.getBpmnXml()).isEqualTo(bpmnXml);
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) InputStream(java.io.InputStream) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 2 with WorkflowsClient

use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldNotDeployUnparsableModel.

@Test
public void shouldNotDeployUnparsableModel() {
    // given
    final WorkflowsClient workflowService = clientRule.workflows();
    // then
    exception.expect(ClientCommandRejectedException.class);
    exception.expectMessage(containsString("Failed to deploy resource 'invalid.bpmn'"));
    // when
    workflowService.deploy(clientRule.getDefaultTopic()).addResourceStringUtf8("Foooo", "invalid.bpmn").execute();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) Test(org.junit.Test)

Example 3 with WorkflowsClient

use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldNotDeployIfNoResourceIsAdded.

@Test
public void shouldNotDeployIfNoResourceIsAdded() {
    // given
    final WorkflowsClient workflowService = clientRule.workflows();
    // then
    exception.expect(ClientCommandRejectedException.class);
    exception.expectMessage(containsString("Deployment doesn't contain a resource to deploy."));
    // when
    workflowService.deploy(clientRule.getDefaultTopic()).execute();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) Test(org.junit.Test)

Example 4 with WorkflowsClient

use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.

the class CreateDeploymentTest method shouldNotDeployNonExecutableModel.

@Test
public void shouldNotDeployNonExecutableModel() {
    // given
    final WorkflowsClient workflowService = clientRule.workflows();
    final io.zeebe.model.bpmn.instance.WorkflowDefinition workflowDefinition = Bpmn.createExecutableWorkflow("not-executable").startEvent().endEvent().done();
    final ProcessImpl workflowImpl = (ProcessImpl) workflowDefinition.getWorkflows().iterator().next();
    workflowImpl.setExecutable(false);
    // then
    exception.expect(ClientCommandRejectedException.class);
    exception.expectMessage(containsString("BPMN model must contain at least one executable process"));
    // when
    workflowService.deploy(clientRule.getDefaultTopic()).addWorkflowModel(workflowDefinition, "workflow.bpmn").execute();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) ProcessImpl(io.zeebe.model.bpmn.impl.instance.ProcessImpl) Test(org.junit.Test)

Example 5 with WorkflowsClient

use of io.zeebe.client.WorkflowsClient in project zeebe by zeebe-io.

the class CreateWorkflowInstanceTest method deployProcess.

@Before
public void deployProcess() {
    final WorkflowsClient workflowService = clientRule.workflows();
    workflowService.deploy(clientRule.getDefaultTopic()).addWorkflowModel(Bpmn.createExecutableWorkflow("anId").startEvent().endEvent().done(), "workflow.bpmn").execute();
    workflowService.deploy(clientRule.getDefaultTopic()).addWorkflowModel(Bpmn.createExecutableWorkflow("anId").startEvent().endEvent().done(), "workflow.bpmn").execute();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient)

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