Search in sources :

Example 1 with RESOLVE

use of io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVE in project zeebe by camunda.

the class MappingIncidentTest method shouldCreateNewIncidentAfterResolvedFirstOne.

@Test
public void shouldCreateNewIncidentAfterResolvedFirstOne() {
    // given
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("process").startEvent().serviceTask("failingTask", t -> t.zeebeJobType("external").zeebeInputExpression("foo", "foo").zeebeInputExpression("bar", "bar")).done();
    ENGINE.deployment().withXmlResource(modelInstance).deploy();
    final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId("process").create();
    final Record failureEvent = RecordingExporter.processInstanceRecords().withProcessInstanceKey(processInstanceKey).withElementId("failingTask").withIntent(ProcessInstanceIntent.ELEMENT_ACTIVATING).getFirst();
    final Record<IncidentRecordValue> incidentEvent = RecordingExporter.incidentRecords().withProcessInstanceKey(processInstanceKey).withIntent(IncidentIntent.CREATED).getFirst();
    assertThat(incidentEvent.getValue().getErrorMessage()).contains("no variable found for name 'foo'");
    // when
    ENGINE.variables().ofScope(failureEvent.getKey()).withDocument(VARIABLES).update();
    final Record<IncidentRecordValue> resolvedEvent = ENGINE.incident().ofInstance(processInstanceKey).withKey(incidentEvent.getKey()).resolve();
    // then
    assertThat(resolvedEvent.getKey()).isEqualTo(incidentEvent.getKey());
    final Record<IncidentRecordValue> secondIncidentEvent = RecordingExporter.incidentRecords().onlyEvents().withProcessInstanceKey(processInstanceKey).skipUntil(e -> e.getIntent() == RESOLVED).withIntent(IncidentIntent.CREATED).getFirst();
    Assertions.assertThat(secondIncidentEvent.getValue()).hasErrorType(ErrorType.IO_MAPPING_ERROR).hasBpmnProcessId("process").hasProcessInstanceKey(processInstanceKey).hasElementId("failingTask").hasElementInstanceKey(failureEvent.getKey()).hasVariableScopeKey(failureEvent.getKey());
    assertThat(secondIncidentEvent.getValue().getErrorMessage()).contains("no variable found for name 'bar'");
}
Also used : ErrorType(io.camunda.zeebe.protocol.record.value.ErrorType) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) HashMap(java.util.HashMap) Record(io.camunda.zeebe.protocol.record.Record) Map(java.util.Map) EngineRule(io.camunda.zeebe.engine.util.EngineRule) RESOLVED(io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVED) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) CREATED(io.camunda.zeebe.protocol.record.intent.IncidentIntent.CREATED) ClassRule(org.junit.ClassRule) ELEMENT_COMPLETED(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent.ELEMENT_COMPLETED) IncidentRecordValue(io.camunda.zeebe.protocol.record.value.IncidentRecordValue) Test(org.junit.Test) Assertions.entry(org.assertj.core.api.Assertions.entry) RecordingExporterTestWatcher(io.camunda.zeebe.test.util.record.RecordingExporterTestWatcher) Assertions(io.camunda.zeebe.protocol.record.Assertions) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) RESOLVE(io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVE) Rule(org.junit.Rule) ProcessInstanceRecordValue(io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue) BpmnElementType(io.camunda.zeebe.protocol.record.value.BpmnElementType) IncidentIntent(io.camunda.zeebe.protocol.record.intent.IncidentIntent) Maps(io.camunda.zeebe.test.util.collection.Maps) Record(io.camunda.zeebe.protocol.record.Record) IncidentRecordValue(io.camunda.zeebe.protocol.record.value.IncidentRecordValue) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 2 with RESOLVE

use of io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVE in project zeebe by camunda-cloud.

the class MappingIncidentTest method shouldCreateNewIncidentAfterResolvedFirstOne.

@Test
public void shouldCreateNewIncidentAfterResolvedFirstOne() {
    // given
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("process").startEvent().serviceTask("failingTask", t -> t.zeebeJobType("external").zeebeInputExpression("foo", "foo").zeebeInputExpression("bar", "bar")).done();
    ENGINE.deployment().withXmlResource(modelInstance).deploy();
    final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId("process").create();
    final Record failureEvent = RecordingExporter.processInstanceRecords().withProcessInstanceKey(processInstanceKey).withElementId("failingTask").withIntent(ProcessInstanceIntent.ELEMENT_ACTIVATING).getFirst();
    final Record<IncidentRecordValue> incidentEvent = RecordingExporter.incidentRecords().withProcessInstanceKey(processInstanceKey).withIntent(IncidentIntent.CREATED).getFirst();
    assertThat(incidentEvent.getValue().getErrorMessage()).contains("no variable found for name 'foo'");
    // when
    ENGINE.variables().ofScope(failureEvent.getKey()).withDocument(VARIABLES).update();
    final Record<IncidentRecordValue> resolvedEvent = ENGINE.incident().ofInstance(processInstanceKey).withKey(incidentEvent.getKey()).resolve();
    // then
    assertThat(resolvedEvent.getKey()).isEqualTo(incidentEvent.getKey());
    final Record<IncidentRecordValue> secondIncidentEvent = RecordingExporter.incidentRecords().onlyEvents().withProcessInstanceKey(processInstanceKey).skipUntil(e -> e.getIntent() == RESOLVED).withIntent(IncidentIntent.CREATED).getFirst();
    Assertions.assertThat(secondIncidentEvent.getValue()).hasErrorType(ErrorType.IO_MAPPING_ERROR).hasBpmnProcessId("process").hasProcessInstanceKey(processInstanceKey).hasElementId("failingTask").hasElementInstanceKey(failureEvent.getKey()).hasVariableScopeKey(failureEvent.getKey());
    assertThat(secondIncidentEvent.getValue().getErrorMessage()).contains("no variable found for name 'bar'");
}
Also used : ErrorType(io.camunda.zeebe.protocol.record.value.ErrorType) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) HashMap(java.util.HashMap) Record(io.camunda.zeebe.protocol.record.Record) Map(java.util.Map) EngineRule(io.camunda.zeebe.engine.util.EngineRule) RESOLVED(io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVED) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) CREATED(io.camunda.zeebe.protocol.record.intent.IncidentIntent.CREATED) ClassRule(org.junit.ClassRule) ELEMENT_COMPLETED(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent.ELEMENT_COMPLETED) IncidentRecordValue(io.camunda.zeebe.protocol.record.value.IncidentRecordValue) Test(org.junit.Test) Assertions.entry(org.assertj.core.api.Assertions.entry) RecordingExporterTestWatcher(io.camunda.zeebe.test.util.record.RecordingExporterTestWatcher) Assertions(io.camunda.zeebe.protocol.record.Assertions) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) RESOLVE(io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVE) Rule(org.junit.Rule) ProcessInstanceRecordValue(io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue) BpmnElementType(io.camunda.zeebe.protocol.record.value.BpmnElementType) IncidentIntent(io.camunda.zeebe.protocol.record.intent.IncidentIntent) Maps(io.camunda.zeebe.test.util.collection.Maps) Record(io.camunda.zeebe.protocol.record.Record) IncidentRecordValue(io.camunda.zeebe.protocol.record.value.IncidentRecordValue) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 3 with RESOLVE

use of io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVE in project zeebe by zeebe-io.

the class MappingIncidentTest method shouldCreateNewIncidentAfterResolvedFirstOne.

@Test
public void shouldCreateNewIncidentAfterResolvedFirstOne() {
    // given
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("process").startEvent().serviceTask("failingTask", t -> t.zeebeJobType("external").zeebeInputExpression("foo", "foo").zeebeInputExpression("bar", "bar")).done();
    ENGINE.deployment().withXmlResource(modelInstance).deploy();
    final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId("process").create();
    final Record failureEvent = RecordingExporter.processInstanceRecords().withProcessInstanceKey(processInstanceKey).withElementId("failingTask").withIntent(ProcessInstanceIntent.ELEMENT_ACTIVATING).getFirst();
    final Record<IncidentRecordValue> incidentEvent = RecordingExporter.incidentRecords().withProcessInstanceKey(processInstanceKey).withIntent(IncidentIntent.CREATED).getFirst();
    assertThat(incidentEvent.getValue().getErrorMessage()).contains("no variable found for name 'foo'");
    // when
    ENGINE.variables().ofScope(failureEvent.getKey()).withDocument(VARIABLES).update();
    final Record<IncidentRecordValue> resolvedEvent = ENGINE.incident().ofInstance(processInstanceKey).withKey(incidentEvent.getKey()).resolve();
    // then
    assertThat(resolvedEvent.getKey()).isEqualTo(incidentEvent.getKey());
    final Record<IncidentRecordValue> secondIncidentEvent = RecordingExporter.incidentRecords().onlyEvents().withProcessInstanceKey(processInstanceKey).skipUntil(e -> e.getIntent() == RESOLVED).withIntent(IncidentIntent.CREATED).getFirst();
    Assertions.assertThat(secondIncidentEvent.getValue()).hasErrorType(ErrorType.IO_MAPPING_ERROR).hasBpmnProcessId("process").hasProcessInstanceKey(processInstanceKey).hasElementId("failingTask").hasElementInstanceKey(failureEvent.getKey()).hasVariableScopeKey(failureEvent.getKey());
    assertThat(secondIncidentEvent.getValue().getErrorMessage()).contains("no variable found for name 'bar'");
}
Also used : ErrorType(io.camunda.zeebe.protocol.record.value.ErrorType) ProcessInstanceIntent(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.camunda.zeebe.model.bpmn.Bpmn) HashMap(java.util.HashMap) Record(io.camunda.zeebe.protocol.record.Record) Map(java.util.Map) EngineRule(io.camunda.zeebe.engine.util.EngineRule) RESOLVED(io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVED) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) CREATED(io.camunda.zeebe.protocol.record.intent.IncidentIntent.CREATED) ClassRule(org.junit.ClassRule) ELEMENT_COMPLETED(io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent.ELEMENT_COMPLETED) IncidentRecordValue(io.camunda.zeebe.protocol.record.value.IncidentRecordValue) Test(org.junit.Test) Assertions.entry(org.assertj.core.api.Assertions.entry) RecordingExporterTestWatcher(io.camunda.zeebe.test.util.record.RecordingExporterTestWatcher) Assertions(io.camunda.zeebe.protocol.record.Assertions) RecordingExporter(io.camunda.zeebe.test.util.record.RecordingExporter) RESOLVE(io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVE) Rule(org.junit.Rule) ProcessInstanceRecordValue(io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue) BpmnElementType(io.camunda.zeebe.protocol.record.value.BpmnElementType) IncidentIntent(io.camunda.zeebe.protocol.record.intent.IncidentIntent) Maps(io.camunda.zeebe.test.util.collection.Maps) Record(io.camunda.zeebe.protocol.record.Record) IncidentRecordValue(io.camunda.zeebe.protocol.record.value.IncidentRecordValue) BpmnModelInstance(io.camunda.zeebe.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Aggregations

EngineRule (io.camunda.zeebe.engine.util.EngineRule)3 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)3 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)3 Assertions (io.camunda.zeebe.protocol.record.Assertions)3 Record (io.camunda.zeebe.protocol.record.Record)3 IncidentIntent (io.camunda.zeebe.protocol.record.intent.IncidentIntent)3 CREATED (io.camunda.zeebe.protocol.record.intent.IncidentIntent.CREATED)3 RESOLVE (io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVE)3 RESOLVED (io.camunda.zeebe.protocol.record.intent.IncidentIntent.RESOLVED)3 ProcessInstanceIntent (io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent)3 ELEMENT_COMPLETED (io.camunda.zeebe.protocol.record.intent.ProcessInstanceIntent.ELEMENT_COMPLETED)3 BpmnElementType (io.camunda.zeebe.protocol.record.value.BpmnElementType)3 ErrorType (io.camunda.zeebe.protocol.record.value.ErrorType)3 IncidentRecordValue (io.camunda.zeebe.protocol.record.value.IncidentRecordValue)3 ProcessInstanceRecordValue (io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue)3 Maps (io.camunda.zeebe.test.util.collection.Maps)3 RecordingExporter (io.camunda.zeebe.test.util.record.RecordingExporter)3 RecordingExporterTestWatcher (io.camunda.zeebe.test.util.record.RecordingExporterTestWatcher)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3