Search in sources :

Example 6 with WorkflowsClient

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

the class CreateWorkflowInstanceTest method shouldCreateBpmnProcessByIdAndVersion.

@Test
public void shouldCreateBpmnProcessByIdAndVersion() {
    final WorkflowsClient workflowService = clientRule.workflows();
    // when
    final WorkflowInstanceEvent workflowInstance = workflowService.create(clientRule.getDefaultTopic()).bpmnProcessId("anId").version(1).execute();
    // then instance is created of first workflow version
    assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("anId");
    assertThat(workflowInstance.getVersion()).isEqualTo(1);
    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 7 with WorkflowsClient

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

the class CreateWorkflowInstanceTest method shouldThrowExceptionForCreateBpmnProcessIfBpmnProcessIdAndWorkflowKeyNotSet.

@Test
public void shouldThrowExceptionForCreateBpmnProcessIfBpmnProcessIdAndWorkflowKeyNotSet() {
    final WorkflowsClient workflowService = clientRule.workflows();
    // expected
    exception.expect(ClientCommandRejectedException.class);
    exception.expectMessage("Command was rejected by broker (WORKFLOW_INSTANCE_REJECTED)");
    // when
    workflowService.create(clientRule.getDefaultTopic()).execute();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient)

Example 8 with WorkflowsClient

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

the class CreateWorkflowInstanceTest method shouldRejectCreateBpmnProcessByIllegalKey.

@Test
public void shouldRejectCreateBpmnProcessByIllegalKey() {
    final WorkflowsClient workflowService = clientRule.workflows();
    // expected
    exception.expect(ClientCommandRejectedException.class);
    exception.expectMessage("Failed to create instance of workflow with key '99'");
    // when
    workflowService.create(clientRule.getDefaultTopic()).workflowKey(99L).execute();
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient)

Example 9 with WorkflowsClient

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

the class CreateWorkflowInstanceTest method shouldCreateBpmnProcessByKey.

@Test
public void shouldCreateBpmnProcessByKey() {
    final WorkflowsClient workflowService = clientRule.workflows();
    waitUntil(() -> eventRecorder.hasWorkflowEvent(wfEvent("CREATED")));
    final long workflowKey = eventRecorder.getSingleWorkflowEvent(wfEvent("CREATED")).getMetadata().getKey();
    // when
    final WorkflowInstanceEvent workflowInstance = workflowService.create(clientRule.getDefaultTopic()).workflowKey(workflowKey).execute();
    // then
    assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("anId");
    assertThat(workflowInstance.getVersion()).isEqualTo(1);
    assertThat(workflowInstance.getWorkflowKey()).isEqualTo(workflowKey);
    waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_CREATED")));
}
Also used : WorkflowsClient(io.zeebe.client.WorkflowsClient) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent)

Example 10 with WorkflowsClient

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

the class CreateWorkflowInstanceTest method shouldThrowExceptionForIllegalVersion.

@Test
@Ignore("https://github.com/zeebe-io/zeebe/issues/369")
public void shouldThrowExceptionForIllegalVersion() {
    final WorkflowsClient workflowService = clientRule.workflows();
    // expected
    exception.expect(RuntimeException.class);
    exception.expectMessage("version must be greater than or equal to -1");
    // when
    workflowService.create(clientRule.getDefaultTopic()).bpmnProcessId("anId").version(-10).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