Search in sources :

Example 1 with WorkflowInstanceEvent

use of io.zeebe.broker.workflow.data.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class IncidentStreamProcessorTest method shouldNotResolveIncidentIfActivityTerminated.

@Test
public void shouldNotResolveIncidentIfActivityTerminated() {
    // given
    final long workflowInstanceKey = 1L;
    final long activityInstanceKey = 2L;
    final StreamProcessorControl control = rule.runStreamProcessor(this::buildStreamProcessor);
    control.blockAfterIncidentEvent(e -> e.getValue().getState() == IncidentState.CREATED);
    final WorkflowInstanceEvent activityInstance = new WorkflowInstanceEvent();
    activityInstance.setState(WorkflowInstanceState.ACTIVITY_READY);
    activityInstance.setWorkflowInstanceKey(workflowInstanceKey);
    final long position = rule.writeEvent(activityInstanceKey, activityInstance);
    final IncidentEvent incident = new IncidentEvent();
    incident.setState(IncidentState.CREATE);
    incident.setWorkflowInstanceKey(workflowInstanceKey);
    incident.setActivityInstanceKey(activityInstanceKey);
    incident.setFailureEventPosition(position);
    rule.writeEvent(incident);
    // stream processor is now blocked
    waitForEventInState(IncidentState.CREATED);
    activityInstance.setState(WorkflowInstanceState.PAYLOAD_UPDATED);
    rule.writeEvent(activityInstanceKey, activityInstance);
    activityInstance.setState(WorkflowInstanceState.ACTIVITY_TERMINATED);
    rule.writeEvent(activityInstanceKey, activityInstance);
    // when
    control.unblock();
    // then
    waitForEventInState(IncidentState.DELETED);
    final List<TypedEvent<IncidentEvent>> incidentEvents = rule.events().onlyIncidentEvents().collect(Collectors.toList());
    assertThat(incidentEvents).extracting("value.state").containsExactly(IncidentState.CREATE, IncidentState.CREATED, IncidentState.RESOLVE, IncidentState.DELETE, IncidentState.RESOLVE_REJECTED, IncidentState.DELETED);
}
Also used : TypedEvent(io.zeebe.broker.logstreams.processor.TypedEvent) WorkflowInstanceEvent(io.zeebe.broker.workflow.data.WorkflowInstanceEvent) StreamProcessorControl(io.zeebe.broker.topic.StreamProcessorControl) IncidentEvent(io.zeebe.broker.incident.data.IncidentEvent) Test(org.junit.Test)

Example 2 with WorkflowInstanceEvent

use of io.zeebe.broker.workflow.data.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class ClientApiMessageHandler method initEventTypeMap.

private void initEventTypeMap() {
    eventsByType.put(EventType.DEPLOYMENT_EVENT, new DeploymentEvent());
    eventsByType.put(EventType.TASK_EVENT, new TaskEvent());
    eventsByType.put(EventType.WORKFLOW_INSTANCE_EVENT, new WorkflowInstanceEvent());
    eventsByType.put(EventType.SUBSCRIBER_EVENT, new TopicSubscriberEvent());
    eventsByType.put(EventType.SUBSCRIPTION_EVENT, new TopicSubscriptionEvent());
    eventsByType.put(EventType.TOPIC_EVENT, new TopicEvent());
}
Also used : TopicEvent(io.zeebe.broker.system.log.TopicEvent) TopicSubscriptionEvent(io.zeebe.broker.event.processor.TopicSubscriptionEvent) TopicSubscriberEvent(io.zeebe.broker.event.processor.TopicSubscriberEvent) TaskEvent(io.zeebe.broker.task.data.TaskEvent) WorkflowInstanceEvent(io.zeebe.broker.workflow.data.WorkflowInstanceEvent) DeploymentEvent(io.zeebe.broker.workflow.data.DeploymentEvent)

Aggregations

WorkflowInstanceEvent (io.zeebe.broker.workflow.data.WorkflowInstanceEvent)2 TopicSubscriberEvent (io.zeebe.broker.event.processor.TopicSubscriberEvent)1 TopicSubscriptionEvent (io.zeebe.broker.event.processor.TopicSubscriptionEvent)1 IncidentEvent (io.zeebe.broker.incident.data.IncidentEvent)1 TypedEvent (io.zeebe.broker.logstreams.processor.TypedEvent)1 TopicEvent (io.zeebe.broker.system.log.TopicEvent)1 TaskEvent (io.zeebe.broker.task.data.TaskEvent)1 StreamProcessorControl (io.zeebe.broker.topic.StreamProcessorControl)1 DeploymentEvent (io.zeebe.broker.workflow.data.DeploymentEvent)1 Test (org.junit.Test)1