/** * An entry point for VariableRecordValueAssert to follow AssertJ standard <code>assertThat()</code> statements.<br> * With a static import, one can write directly: <code>assertThat(myVariableRecordValue)</code> and get specific assertion with code completion. * @param actual the VariableRecordValue we want to make assertions on. * @return a new <code>{@link VariableRecordValueAssert}</code> */ @org.assertj.core.util.CheckReturnValue public static VariableRecordValueAssert assertThat(VariableRecordValue actual) { return new VariableRecordValueAssert(actual); } }
@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 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 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 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); }
Assertions.assertThat(variableEvent.getValue()).hasValue("3");
@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 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); }
Assertions.assertThat(variableEvent.getValue()).hasValue("3");
@Test public void shouldWriteVariableCreatedEvent() { // given testClient.deploy(WORKFLOW); // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, payload); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.CREATED).getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeInstanceKey(workflowInstanceKey) .hasName("x") .hasValue(expectedValue); } }
@Test public void shouldWriteVariableCreatedEvent() { // given testClient.deploy(WORKFLOW); // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, payload); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.CREATED).getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeKey(workflowInstanceKey) .hasName("x") .hasValue(expectedValue); } }
@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\"") .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); }
/** * Creates a new instance of <code>{@link io.zeebe.exporter.record.value.VariableRecordValueAssert}</code>. * * @param actual the actual value. * @return the created assertion object. */ @org.assertj.core.util.CheckReturnValue public static io.zeebe.exporter.record.value.VariableRecordValueAssert assertThat(io.zeebe.exporter.record.value.VariableRecordValue actual) { return new io.zeebe.exporter.record.value.VariableRecordValueAssert(actual); }
@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 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()) .hasScopeKey(workflowInstanceKey) .hasName("x") .hasValue("2"); }
@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 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()) .hasScopeKey(workflowInstanceKey) .hasName("x") .hasValue("1"); }