Search in sources :

Example 11 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class IncidentTest method shouldDeleteIncidentWhenWorkflowInstanceIsCanceled.

@Test
public void shouldDeleteIncidentWhenWorkflowInstanceIsCanceled() {
    // given
    clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
    final WorkflowInstanceEvent workflowInstance = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
    waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
    // when
    clientRule.workflows().cancel(workflowInstance).execute();
    // then
    waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("DELETED")));
}
Also used : WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) Test(org.junit.Test)

Example 12 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class IncidentTest method shouldCreateAndResolveInputMappingIncident.

@Test
public void shouldCreateAndResolveInputMappingIncident() {
    // given
    clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
    clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
    waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
    final WorkflowInstanceEvent activityInstanceEvent = eventRecorder.getSingleWorkflowInstanceEvent(w -> "ACTIVITY_READY".equals(w.getState()));
    // when
    clientRule.workflows().updatePayload(activityInstanceEvent).payload(PAYLOAD).execute();
    // then
    waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("CREATED")));
    waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVED")));
}
Also used : WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) Test(org.junit.Test)

Example 13 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class CancelWorkflowInstanceTest method shouldFailToLockTaskAfterCancel.

@Test
public void shouldFailToLockTaskAfterCancel() {
    // given
    final WorkflowInstanceEvent workflowInstance = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
    waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("CREATED")));
    clientRule.workflows().cancel(workflowInstance).execute();
    final PollableTaskSubscription taskSubscription = clientRule.tasks().newPollableTaskSubscription(clientRule.getDefaultTopic()).taskType("test").lockOwner("owner").lockTime(Duration.ofMinutes(1)).open();
    // when
    final int completedTasks = taskSubscription.poll((c, t) -> c.complete(t).withoutPayload().execute());
    // then
    assertThat(completedTasks).isEqualTo(0);
    waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("LOCK_REJECTED")));
    assertThat(eventRecorder.hasTaskEvent(taskEvent("CANCELED")));
    assertThat(eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_CANCELED")));
}
Also used : WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) PollableTaskSubscription(io.zeebe.client.task.PollableTaskSubscription)

Example 14 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class CancelWorkflowInstanceTest method shouldCancelWorkflowInstance.

@Test
public void shouldCancelWorkflowInstance() {
    // given
    final WorkflowInstanceEvent workflowInstance = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
    // when
    clientRule.workflows().cancel(workflowInstance).execute();
    // then
    waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_CANCELED")));
}
Also used : WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent)

Example 15 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class CancelWorkflowInstanceTest method shouldFailToCompleteTaskAfterCancel.

@Test
public void shouldFailToCompleteTaskAfterCancel() {
    // given
    final WorkflowInstanceEvent workflowInstance = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
    final PollableTaskSubscription taskSubscription = clientRule.tasks().newPollableTaskSubscription(clientRule.getDefaultTopic()).taskType("test").lockOwner("owner").lockTime(Duration.ofMinutes(1)).open();
    waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("LOCKED")));
    clientRule.workflows().cancel(workflowInstance).execute();
    // when
    taskSubscription.poll((c, t) -> c.complete(t).withoutPayload().execute());
    // then
    waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("COMPLETE_REJECTED")));
    assertThat(eventRecorder.hasTaskEvent(taskEvent("CANCELED")));
    assertThat(eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_CANCELED")));
}
Also used : WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) PollableTaskSubscription(io.zeebe.client.task.PollableTaskSubscription)

Aggregations

WorkflowInstanceEvent (io.zeebe.client.event.WorkflowInstanceEvent)31 Test (org.junit.Test)14 ClientRule (io.zeebe.broker.it.ClientRule)7 EmbeddedBrokerRule (io.zeebe.broker.it.EmbeddedBrokerRule)7 TopicEventRecorder (io.zeebe.broker.it.util.TopicEventRecorder)7 Bpmn (io.zeebe.model.bpmn.Bpmn)7 WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)7 TestUtil.waitUntil (io.zeebe.test.util.TestUtil.waitUntil)7 Duration (java.time.Duration)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 RuleChain (org.junit.rules.RuleChain)7 RecordingTaskHandler (io.zeebe.broker.it.util.RecordingTaskHandler)6 WorkflowsClient (io.zeebe.client.WorkflowsClient)6 TaskEvent (io.zeebe.client.event.TaskEvent)6 ExpectedException (org.junit.rules.ExpectedException)6 TopicEventRecorder.wfInstanceEvent (io.zeebe.broker.it.util.TopicEventRecorder.wfInstanceEvent)5 org.junit (org.junit)5 ClientCommandRejectedException (io.zeebe.client.cmd.ClientCommandRejectedException)4 DeploymentEvent (io.zeebe.client.event.DeploymentEvent)4 TasksClient (io.zeebe.client.TasksClient)3