use of io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue in project zeebe-process-test by camunda.
the class ProcessInstanceAssert method isWaitingExactlyAtElements.
/**
* Verifies the expectation that the process instance is currently waiting at the specified
* elements, and not at any other element.
*
* @param elementIdsVarArg The ids of the elements
* @return this {@link ProcessInstanceAssert}
*/
public ProcessInstanceAssert isWaitingExactlyAtElements(final String... elementIdsVarArg) {
final List<String> elementIds = Arrays.asList(elementIdsVarArg);
final Set<String> elementsInWaitState = getElementsInWaitState();
final List<String> wrongfullyWaitingElementIds = new ArrayList<>();
final List<String> wrongfullyNotWaitingElementIds = new ArrayList<>();
StreamFilter.processInstance(recordStream).withProcessInstanceKey(actual).withRejectionType(RejectionType.NULL_VAL).withoutBpmnElementType(BpmnElementType.PROCESS).withIntent(ProcessInstanceIntent.ELEMENT_ACTIVATED).stream().map(Record::getValue).map(ProcessInstanceRecordValue::getElementId).distinct().forEach(id -> {
final boolean shouldBeWaitingAtElement = elementIds.contains(id);
final boolean isWaitingAtElement = elementsInWaitState.contains(id);
if (shouldBeWaitingAtElement && !isWaitingAtElement) {
wrongfullyNotWaitingElementIds.add(id);
} else if (!shouldBeWaitingAtElement && isWaitingAtElement) {
wrongfullyWaitingElementIds.add(id);
}
});
final SoftAssertions softly = new SoftAssertions();
softly.assertThat(wrongfullyWaitingElementIds.isEmpty()).withFailMessage("Process with key %s is waiting at element(s) with id(s) %s", actual, String.join(", ", wrongfullyWaitingElementIds)).isTrue();
softly.assertThat(wrongfullyNotWaitingElementIds.isEmpty()).withFailMessage("Process with key %s is not waiting at element(s) with id(s) %s", actual, String.join(", ", wrongfullyNotWaitingElementIds)).isTrue();
softly.assertAll();
return this;
}
use of io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue in project zeebe-exporter-protobuf by camunda-community-hub.
the class RecordTransformTest method shouldTransformWorkflowInstance.
@Test
public void shouldTransformWorkflowInstance() {
// given
final ProcessInstanceRecordValue workflowInstanceRecordValue = mockProcessInstanceRecordValue();
final Record<ProcessInstanceRecordValue> mockedRecord = mockRecord(workflowInstanceRecordValue, ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ELEMENT_ACTIVATED);
// when
final Schema.ProcessInstanceRecord workflowInstance = (Schema.ProcessInstanceRecord) RecordTransformer.toProtobufMessage(mockedRecord);
// then
assertMetadata(workflowInstance.getMetadata(), "PROCESS_INSTANCE", "ELEMENT_ACTIVATED");
assertThat(workflowInstance.getBpmnProcessId()).isEqualTo("process");
assertThat(workflowInstance.getElementId()).isEqualTo("startEvent");
assertThat(workflowInstance.getProcessDefinitionKey()).isEqualTo(4L);
assertThat(workflowInstance.getVersion()).isEqualTo(1);
assertThat(workflowInstance.getProcessInstanceKey()).isEqualTo(1L);
assertThat(workflowInstance.getFlowScopeKey()).isEqualTo(-1L);
assertThat(workflowInstance.getBpmnElementType()).isEqualTo("START_EVENT");
assertThat(workflowInstance.getParentProcessInstanceKey()).isEqualTo(-1L);
assertThat(workflowInstance.getParentElementInstanceKey()).isEqualTo(-1L);
}
use of io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue in project zeebe-exporter-protobuf by camunda-community-hub.
the class RecordTransformTest method mockProcessInstanceRecordValue.
private ProcessInstanceRecordValue mockProcessInstanceRecordValue() {
final ProcessInstanceRecordValue workflowInstanceRecordValue = mock(ProcessInstanceRecordValue.class);
when(workflowInstanceRecordValue.getProcessInstanceKey()).thenReturn(1L);
when(workflowInstanceRecordValue.getBpmnProcessId()).thenReturn("process");
when(workflowInstanceRecordValue.getElementId()).thenReturn("startEvent");
when(workflowInstanceRecordValue.getFlowScopeKey()).thenReturn(-1L);
when(workflowInstanceRecordValue.getVersion()).thenReturn(1);
when(workflowInstanceRecordValue.getProcessDefinitionKey()).thenReturn(4L);
when(workflowInstanceRecordValue.getBpmnElementType()).thenReturn(BpmnElementType.START_EVENT);
when(workflowInstanceRecordValue.getParentProcessInstanceKey()).thenReturn(-1L);
when(workflowInstanceRecordValue.getParentElementInstanceKey()).thenReturn(-1L);
return workflowInstanceRecordValue;
}
use of io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue in project zeebe by camunda.
the class MessageCorrelationTest method shouldCorrelateFirstPublishedMessage.
@Test
public void shouldCorrelateFirstPublishedMessage() {
// given
engine.deployment().withXmlResource(SINGLE_MESSAGE_PROCESS).deploy();
final PublishMessageClient messageClient = engine.message().withName("message").withCorrelationKey("order-123");
messageClient.withVariables(asMsgPack("nr", 1)).publish();
messageClient.withVariables(asMsgPack("nr", 2)).publish();
// when
final long processInstanceKey = engine.processInstance().ofBpmnProcessId(PROCESS_ID).withVariable("key", "order-123").create();
// then
final Record<ProcessInstanceRecordValue> event = RecordingExporter.processInstanceRecords().withElementType(BpmnElementType.PROCESS).withIntent(ProcessInstanceIntent.ELEMENT_COMPLETED).getFirst();
final Map<String, String> variables = ProcessInstances.getCurrentVariables(processInstanceKey, event.getPosition());
assertThat(variables).containsOnly(entry("key", "\"order-123\""), entry("nr", "1"));
}
use of io.camunda.zeebe.protocol.record.value.ProcessInstanceRecordValue in project zeebe by camunda.
the class MappingIncidentTest method shouldResolveIncidentForInputMappingFailure.
@Test
public void shouldResolveIncidentForInputMappingFailure() {
// given
ENGINE.deployment().withXmlResource(PROCESS_INPUT_MAPPING).deploy();
final long processInstanceKey = ENGINE.processInstance().ofBpmnProcessId("process").create();
final Record<ProcessInstanceRecordValue> failureEvent = RecordingExporter.processInstanceRecords().withElementId("failingTask").withIntent(ProcessInstanceIntent.ELEMENT_ACTIVATING).withProcessInstanceKey(processInstanceKey).getFirst();
final Record<IncidentRecordValue> incidentEvent = RecordingExporter.incidentRecords().withIntent(IncidentIntent.CREATED).withProcessInstanceKey(processInstanceKey).getFirst();
// when
ENGINE.variables().ofScope(failureEvent.getValue().getFlowScopeKey()).withDocument(VARIABLES).update();
final Record<IncidentRecordValue> incidentResolvedEvent = ENGINE.incident().ofInstance(processInstanceKey).withKey(incidentEvent.getKey()).resolve();
// then
final Record<ProcessInstanceRecordValue> followUpEvent = RecordingExporter.processInstanceRecords().withElementId("failingTask").withIntent(ProcessInstanceIntent.ELEMENT_ACTIVATED).withProcessInstanceKey(processInstanceKey).getFirst();
final Record incidentResolveCommand = RecordingExporter.incidentRecords().withIntent(RESOLVE).withRecordKey(incidentEvent.getKey()).getFirst();
assertThat(incidentResolvedEvent.getKey()).isEqualTo(incidentEvent.getKey());
assertThat(incidentResolveCommand.getPosition()).isEqualTo(followUpEvent.getSourceRecordPosition());
assertThat(incidentResolveCommand.getPosition()).isEqualTo(incidentResolvedEvent.getSourceRecordPosition());
Assertions.assertThat(incidentResolvedEvent.getValue()).hasErrorType(ErrorType.IO_MAPPING_ERROR).hasBpmnProcessId("process").hasProcessInstanceKey(processInstanceKey).hasElementId("failingTask").hasElementInstanceKey(failureEvent.getKey()).hasVariableScopeKey(failureEvent.getKey());
assertThat(incidentEvent.getValue().getErrorMessage()).contains("no variable found for name 'foo'");
}
Aggregations