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);
}
Aggregations