use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class YamlWorkflowTest method shouldCompleteTaskWithPayload.
@Test
public void shouldCompleteTaskWithPayload() {
// given
workflowClient.deploy(clientRule.getDefaultTopic()).addResourceFromClasspath("workflows/workflow-with-mappings.yaml").execute();
workflowClient.create(clientRule.getDefaultTopic()).bpmnProcessId("workflow-mappings").payload("{\"foo\":1}").execute();
// when
final RecordingTaskHandler recordingTaskHandler = new RecordingTaskHandler((c, task) -> c.complete(task).payload("{\"result\":3}").execute());
taskClient.newTaskSubscription(clientRule.getDefaultTopic()).taskType("foo").lockOwner("owner").lockTime(Duration.ofMinutes(5)).handler(recordingTaskHandler).open();
// then
waitUntil(() -> recordingTaskHandler.getHandledTasks().size() >= 1);
final TaskEvent taskLockedEvent = recordingTaskHandler.getHandledTasks().get(0);
assertThat(taskLockedEvent.getPayload()).isEqualTo("{\"bar\":1}");
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_COMPLETED")));
final WorkflowInstanceEvent workflowEvent = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_COMPLETED"));
assertThat(workflowEvent.getPayload()).isEqualTo("{\"result\":3}");
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateWorkflowInstanceByWorkflowKey.
@Test
public void shouldCreateWorkflowInstanceByWorkflowKey() {
// given
brokerRule.onWorkflowRequestRespondWith(1L).put("state", "WORKFLOW_INSTANCE_CREATED").put("workflowInstanceKey", 1).put("payload", msgPackConverter.convertToMsgPack("null")).done().register();
// when
final WorkflowInstanceEvent workflowInstance = clientRule.workflows().create(clientRule.getDefaultTopicName()).workflowKey(2L).execute();
// then
assertThat(workflowInstance).isNotNull();
assertThat(workflowInstance.getWorkflowKey()).isEqualTo(2L);
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateWorkflowInstanceByBpmnProcessId.
@Test
public void shouldCreateWorkflowInstanceByBpmnProcessId() {
// given
brokerRule.onWorkflowRequestRespondWith(1L).put("state", "WORKFLOW_INSTANCE_CREATED").put("version", 1).put("workflowInstanceKey", 1).put("payload", msgPackConverter.convertToMsgPack("null")).done().register();
// when
final WorkflowInstanceEvent workflowInstance = clientRule.workflows().create(clientRule.getDefaultTopicName()).bpmnProcessId("foo").execute();
// then
assertThat(workflowInstance).isNotNull();
assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("foo");
assertThat(workflowInstance.getVersion()).isEqualTo(1);
assertThat(workflowInstance.getWorkflowInstanceKey()).isEqualTo(1);
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateWorkflowInstanceWithPayload.
@Test
public void shouldCreateWorkflowInstanceWithPayload() throws Exception {
// given
final byte[] payload = getBytes("{ \"bar\" : 4 }");
brokerRule.onWorkflowRequestRespondWith(1L).put("state", "WORKFLOW_INSTANCE_CREATED").put("version", 1).put("workflowInstanceKey", 1).put("payload", msgPackConverter.convertToMsgPack("{ \"bar\" : 4 }")).done().register();
// when
final WorkflowInstanceEvent workflowInstance = clientRule.workflows().create(clientRule.getDefaultTopicName()).bpmnProcessId("foo").payload(new ByteArrayInputStream(payload)).execute();
// then
assertThat(workflowInstance).isNotNull();
assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("foo");
assertThat(workflowInstance.getVersion()).isEqualTo(1);
assertThat(workflowInstance.getWorkflowInstanceKey()).isEqualTo(1);
assertThat(workflowInstance.getPayload()).isEqualTo("{\"bar\":4}");
}
use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.
the class CreateWorkflowInstanceTest method shouldCreateWorkflowInstanceByBpmnProcessIdAndVersion.
@Test
public void shouldCreateWorkflowInstanceByBpmnProcessIdAndVersion() {
// given
brokerRule.onWorkflowRequestRespondWith(1L).put("state", "WORKFLOW_INSTANCE_CREATED").put("workflowInstanceKey", 1).put("payload", msgPackConverter.convertToMsgPack("null")).done().register();
// when
final WorkflowInstanceEvent workflowInstance = clientRule.workflows().create(clientRule.getDefaultTopicName()).bpmnProcessId("foo").version(2).execute();
// then
assertThat(workflowInstance).isNotNull();
assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("foo");
assertThat(workflowInstance.getVersion()).isEqualTo(2);
assertThat(workflowInstance.getWorkflowInstanceKey()).isEqualTo(1);
}
Aggregations