public Record<DeploymentRecordValue> receiveFirstDeploymentEvent( final DeploymentIntent intent, final long deploymentKey) { return receiveDeployments().withIntent(intent).withKey(deploymentKey).getFirst(); }
public DeploymentRecordStream receiveDeployments() { return RecordingExporter.deploymentRecords().withPartitionId(partitionId); }
@Override protected DeploymentRecordStream supply( final Stream<Record<DeploymentRecordValue>> wrappedStream) { return new DeploymentRecordStream(wrappedStream); }
public Record<DeploymentRecordValue> getFirstDeploymentCreateCommand() { return apiRule .partitionClient(DEPLOYMENT_PARTITION) .receiveDeployments() .withIntent(DeploymentIntent.CREATE) .getFirst(); } }
public static DeploymentRecordStream deploymentRecords(final DeploymentIntent intent) { return deploymentRecords().withIntent(intent); }
@Test public void shouldStartWorkflowInstanceAtNoneStartEvent() { // given apiRule .partitionClient() .deploy(Bpmn.createExecutableProcess("process").startEvent("foo").endEvent().done()); // when TestUtil.waitUntil(() -> RecordingExporter.deploymentRecords().withPartitionId(2).exists()); final ExecuteCommandResponse workflowInstanceWithResponse = apiRule.partitionClient(2).createWorkflowInstanceWithResponse("process"); // then partition id is encoded in the returned getKey final long key = workflowInstanceWithResponse.getKey(); final int partitionId = Protocol.decodePartitionId(key); assertThat(partitionId).isEqualTo(2); } }
public DeploymentRecordStream withDeployedWorkflows( final List<DeployedWorkflow> deployedWorkflows) { return valueFilter(v -> deployedWorkflows.equals(v.getDeployedWorkflows())); }
@Test public void shouldReplaceTimerStartWithNoneStart() { // when testClient.deploy(REPEATING_MODEL); assertThat(RecordingExporter.timerRecords(TimerIntent.CREATED).exists()).isTrue(); brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThat(RecordingExporter.timerRecords(TimerIntent.TRIGGERED).exists()).isTrue(); // when final BpmnModelInstance nonTimerModel = Bpmn.createExecutableProcess("process").startEvent("start_4").endEvent("end_4").done(); testClient.deploy(nonTimerModel); assertThat(RecordingExporter.deploymentRecords(DeploymentIntent.CREATED).limit(2).count()) .isEqualTo(2); brokerRule.getClock().addTime(Duration.ofSeconds(2)); // then assertThat(RecordingExporter.timerRecords(TimerIntent.CANCELED).exists()).isTrue(); assertThat(RecordingExporter.timerRecords(TimerIntent.TRIGGERED).exists()).isTrue(); final long workflowInstanceKey = testClient.createWorkflowInstance("process"); final WorkflowInstanceRecordValue lastRecord = RecordingExporter.workflowInstanceRecords(EVENT_ACTIVATED) .withElementId("end_4") .getFirst() .getValue(); Assertions.assertThat(lastRecord) .hasVersion(2) .hasBpmnProcessId("process") .hasWorkflowInstanceKey(workflowInstanceKey); }
@Test public void shouldCreateTimer() { // when testClient.deploy(SIMPLE_MODEL); // then assertThat(RecordingExporter.deploymentRecords(DeploymentIntent.CREATED).exists()).isTrue(); final TimerRecordValue timerRecord = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst().getValue(); Assertions.assertThat(timerRecord) .hasDueDate(brokerRule.getClock().getCurrentTimeInMillis() + 1000) .hasHandlerFlowNodeId("start_1") .hasElementInstanceKey(NO_ELEMENT_INSTANCE); }
public Record<DeploymentRecordValue> getFirstDeploymentCreateCommand() { return apiRule .partitionClient(DEPLOYMENT_PARTITION) .receiveDeployments() .withIntent(DeploymentIntent.CREATE) .getFirst(); } }
public static DeploymentRecordStream deploymentRecords(final DeploymentIntent intent) { return deploymentRecords().withIntent(intent); }
@Test public void shouldStartWorkflowInstanceAtNoneStartEvent() { // given apiRule .partitionClient() .deploy(Bpmn.createExecutableProcess("process").startEvent("foo").endEvent().done()); // when TestUtil.waitUntil(() -> RecordingExporter.deploymentRecords().withPartitionId(2).exists()); final ExecuteCommandResponse workflowInstanceWithResponse = apiRule.partitionClient(2).createWorkflowInstanceWithResponse("process"); // then partition id is encoded in the returned getKey final long key = workflowInstanceWithResponse.getKey(); final int partitionId = Protocol.decodePartitionId(key); assertThat(partitionId).isEqualTo(2); } }
public DeploymentRecordStream withDeployedWorkflow(final DeployedWorkflow deployedWorkflow) { return valueFilter(v -> v.getDeployedWorkflows().contains(deployedWorkflow)); } }
@Test public void shouldReplaceTimerStartWithNoneStart() { // when testClient.deploy(REPEATING_MODEL); assertThat(RecordingExporter.timerRecords(TimerIntent.CREATED).exists()).isTrue(); brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThat(RecordingExporter.timerRecords(TimerIntent.TRIGGERED).exists()).isTrue(); // when final BpmnModelInstance nonTimerModel = Bpmn.createExecutableProcess("process").startEvent("start_4").endEvent("end_4").done(); testClient.deploy(nonTimerModel); assertThat(RecordingExporter.deploymentRecords(DeploymentIntent.CREATED).limit(2).count()) .isEqualTo(2); brokerRule.getClock().addTime(Duration.ofSeconds(2)); // then assertThat(RecordingExporter.timerRecords(TimerIntent.CANCELED).exists()).isTrue(); assertThat(RecordingExporter.timerRecords(TimerIntent.TRIGGERED).exists()).isTrue(); final long workflowInstanceKey = testClient.createWorkflowInstance("process"); final WorkflowInstanceRecordValue lastRecord = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .withElementId("end_4") .getFirst() .getValue(); Assertions.assertThat(lastRecord) .hasVersion(2) .hasBpmnProcessId("process") .hasWorkflowInstanceKey(workflowInstanceKey); }
@Test public void shouldCreateTimer() { // when testClient.deploy(SIMPLE_MODEL); // then assertThat(RecordingExporter.deploymentRecords(DeploymentIntent.CREATED).exists()).isTrue(); final TimerRecordValue timerRecord = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst().getValue(); Assertions.assertThat(timerRecord) .hasDueDate(brokerRule.getClock().getCurrentTimeInMillis() + 1000) .hasHandlerFlowNodeId("start_1") .hasElementInstanceKey(NO_ELEMENT_INSTANCE); }
public Record<DeploymentRecordValue> receiveFirstDeploymentEvent( final DeploymentIntent intent, final long deploymentKey) { return receiveDeployments().withIntent(intent).withKey(deploymentKey).getFirst(); }
private void assertAnyCreatedDeploymentEventResources( final int expectedPartition, final Consumer<Record> deploymentAssert) { final Record deploymentCreatedEvent = apiRule .partitionClient(expectedPartition) .receiveDeployments() .withIntent(DeploymentIntent.CREATED) .getFirst(); assertThat(deploymentCreatedEvent.getMetadata().getPartitionId()).isEqualTo(expectedPartition); deploymentAssert.accept(deploymentCreatedEvent); } }
public DeploymentRecordStream withDeployedWorkflows( final List<DeployedWorkflow> deployedWorkflows) { return valueFilter(v -> deployedWorkflows.equals(v.getDeployedWorkflows())); }
public DeploymentRecordStream receiveDeployments() { return RecordingExporter.deploymentRecords().withPartitionId(partitionId); }
@Override protected DeploymentRecordStream supply( final Stream<Record<DeploymentRecordValue>> wrappedStream) { return new DeploymentRecordStream(wrappedStream); }