Search in sources :

Example 1 with IncidentEvent

use of io.zeebe.broker.incident.data.IncidentEvent 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)

Aggregations

IncidentEvent (io.zeebe.broker.incident.data.IncidentEvent)1 TypedEvent (io.zeebe.broker.logstreams.processor.TypedEvent)1 StreamProcessorControl (io.zeebe.broker.topic.StreamProcessorControl)1 WorkflowInstanceEvent (io.zeebe.broker.workflow.data.WorkflowInstanceEvent)1 Test (org.junit.Test)1