public static VariableRecordStream variableRecords(final VariableIntent intent) { return variableRecords().withIntent(intent); }
public static VariableRecordStream variableRecords(final VariableIntent intent) { return variableRecords().withIntent(intent); }
@Test public void shouldMergeMessagePayload() { // given testClient.deployWithResponse(createWorkflowWithOneMessageStartEvent()); // wait until subscription is opened assertThat( messageStartEventSubscriptionRecords(MessageStartEventSubscriptionIntent.OPENED) .exists()) .isTrue(); // when testClient.publishMessage(MESSAGE_NAME1, "order-123", asMsgPack("foo", "bar")); // then assertThat(RecordingExporter.variableRecords().withName("foo").withValue("\"bar\"").exists()) .isTrue(); }
@Test public void shouldApplyOutputMappingsOfMessageStartEvent() { // given testClient.deployWithResponse(createWorkflowWithMessageStartEventOutputMapping()); // wait until subscription is opened assertThat( messageStartEventSubscriptionRecords(MessageStartEventSubscriptionIntent.OPENED) .exists()) .isTrue(); // when testClient.publishMessage(MESSAGE_NAME1, "order-123", asMsgPack("foo", "bar")); // then assertThat( RecordingExporter.variableRecords().withName("mappedfoo").withValue("\"bar\"").exists()) .isTrue(); }
@Test public void shouldMergeMessagePayload() { // given testClient.deployWithResponse(createWorkflowWithOneMessageStartEvent()); // wait until subscription is opened assertThat( messageStartEventSubscriptionRecords(MessageStartEventSubscriptionIntent.OPENED) .exists()) .isTrue(); // when testClient.publishMessage(MESSAGE_NAME1, "order-123", asMsgPack("foo", "bar")); // then assertThat(RecordingExporter.variableRecords().withName("foo").withValue("\"bar\"").exists()) .isTrue(); }
@Test public void shouldCreateMultipleVariablesFromPayload() { // given testClient.deploy(WORKFLOW); // when testClient.createWorkflowInstance(PROCESS_ID, "{'x':1, 'y':2}"); // then assertThat(RecordingExporter.variableRecords(VariableIntent.CREATED).limit(2)) .extracting(Record::getValue) .extracting(v -> tuple(v.getName(), v.getValue())) .hasSize(2) .contains(tuple("x", "1"), tuple("y", "2")); }
@Test public void shouldCreateVariableByWorkflowInstanceCreation() { // given testClient.deploy(WORKFLOW); // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'x':1}"); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.CREATED).getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeInstanceKey(workflowInstanceKey) .hasName("x") .hasValue("1"); }
@Test public void shouldCreateMultipleVariablesFromPayload() { // given testClient.deploy(WORKFLOW); // when testClient.createWorkflowInstance(PROCESS_ID, "{'x':1, 'y':2}"); // then assertThat(RecordingExporter.variableRecords(VariableIntent.CREATED).limit(2)) .extracting(Record::getValue) .extracting(v -> tuple(v.getName(), v.getValue())) .hasSize(2) .contains(tuple("x", "1"), tuple("y", "2")); }
@Test public void shouldCreateVariableByWorkflowInstanceCreation() { // given testClient.deploy(WORKFLOW); // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'x':1}"); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.CREATED).getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeKey(workflowInstanceKey) .hasName("x") .hasValue("1"); }
@Test public void shouldUpdateMultipleVariablesFromPayload() { // given testClient.deploy(WORKFLOW); testClient.createWorkflowInstance(PROCESS_ID, "{'x':1, 'y':2, 'z':3}"); // when testClient.completeJobOfType("test", "{'x':1, 'y':4, 'z':5}"); // then assertThat(RecordingExporter.variableRecords(VariableIntent.UPDATED).limit(2)) .extracting(Record::getValue) .extracting(v -> tuple(v.getName(), v.getValue())) .hasSize(2) .contains(tuple("y", "4"), tuple("z", "5")); }
@Test public void shouldUpdateMultipleVariablesFromPayload() { // given testClient.deploy(WORKFLOW); testClient.createWorkflowInstance(PROCESS_ID, "{'x':1, 'y':2, 'z':3}"); // when testClient.completeJobOfType("test", "{'x':1, 'y':4, 'z':5}"); // then assertThat(RecordingExporter.variableRecords(VariableIntent.UPDATED).limit(2)) .extracting(Record::getValue) .extracting(v -> tuple(v.getName(), v.getValue())) .hasSize(2) .contains(tuple("y", "4"), tuple("z", "5")); }
@Test public void shouldMergeMessagePayloadByDefault() { // given deployWorkflowWithMapping(e -> {}); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'key': 'order-66'}"); // when testClient.publishMessage("message", "order-66", "{'foo': 'bar'}"); // then final Record<VariableRecordValue> variableEvent = RecordingExporter.variableRecords().withName("foo").getFirst(); Assertions.assertThat(variableEvent.getValue()) .hasValue("\"bar\"") .hasScopeInstanceKey(workflowInstanceKey); }
@Test public void shouldUpdateVariableByUpdatePayload() { // given testClient.deploy(WORKFLOW); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'x':1}"); // when testClient.updatePayload(workflowInstanceKey, "{'x':2}"); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.UPDATED).getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeInstanceKey(workflowInstanceKey) .hasName("x") .hasValue("2"); }
@Test public void shouldCreateVariableByUpdatePayload() { // given testClient.deploy(WORKFLOW); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); // when testClient.updatePayload(workflowInstanceKey, "{'x':1}"); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.CREATED).getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeKey(workflowInstanceKey) .hasName("x") .hasValue("1"); }
@Test public void shouldCreateVariableByJobCompletion() { // given testClient.deploy(WORKFLOW); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("test", "{'x':1}"); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.CREATED).getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeInstanceKey(workflowInstanceKey) .hasName("x") .hasValue("1"); }
@Test public void shouldUpdateVariableByJobCompletion() { // given testClient.deploy(WORKFLOW); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'x':1}"); // when testClient.completeJobOfType("test", "{'x':2}"); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.UPDATED).getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeInstanceKey(workflowInstanceKey) .hasName("x") .hasValue("2"); }
@Test public void shouldMergeMessagePayloadByDefault() { // given deployWorkflowWithMapping(e -> {}); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'key': 'order-66'}"); // when testClient.publishMessage("message", "order-66", "{'foo': 'bar'}"); // then final Record<VariableRecordValue> variableEvent = RecordingExporter.variableRecords().withName("foo").getFirst(); Assertions.assertThat(variableEvent.getValue()) .hasValue("\"bar\"") .hasScopeKey(workflowInstanceKey); }
@Test public void shouldMapMessagePayloadIntoInstancePayload() { // given deployWorkflowWithMapping(e -> e.zeebeOutput("$.foo", "$.message")); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'key': 'order-66'}"); // when testClient.publishMessage("message", "order-66", "{'foo': 'bar'}"); // then final Record<VariableRecordValue> variableEvent = RecordingExporter.variableRecords().withName("message").getFirst(); Assertions.assertThat(variableEvent.getValue()) .hasValue("\"bar\"") .hasScopeInstanceKey(workflowInstanceKey); }
@Test public void shouldMapMessagePayloadIntoInstancePayload() { // given deployWorkflowWithMapping(e -> e.zeebeOutput("$.foo", "$.message")); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'key': 'order-66'}"); // when testClient.publishMessage("message", "order-66", "{'foo': 'bar'}"); // then final Record<VariableRecordValue> variableEvent = RecordingExporter.variableRecords().withName("message").getFirst(); Assertions.assertThat(variableEvent.getValue()) .hasValue("\"bar\"") .hasScopeKey(workflowInstanceKey); }
@Test public void shouldMergeMessagePayload() { // given deployWorkflowWithMapping(e -> e.zeebeOutputBehavior(ZeebeOutputBehavior.merge)); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, "{'key': 'order-66'}"); // when testClient.publishMessage("message", "order-66", "{'foo': 'bar'}"); // then final Record<VariableRecordValue> variableEvent = RecordingExporter.variableRecords().withName("foo").getFirst(); Assertions.assertThat(variableEvent.getValue()) .hasValue("\"bar\"") .hasScopeInstanceKey(workflowInstanceKey); }