void wrap(LoggedEvent rawEvent) { final RecordMetadataImpl metadata = new RecordMetadataImpl( objectMapper, partitionId, rawMetadata.getIntent(), rawMetadata.getRecordType(), rawMetadata.getRejectionType(), BufferUtil.bufferAsString(rawMetadata.getRejectionReason()), rawMetadata.getValueType()); record = recordMapper.map(rawEvent, metadata); exporterIndex = 0; shouldExecuteSideEffects = record != null; }
void wrap(LoggedEvent rawEvent) { final RecordMetadataImpl metadata = new RecordMetadataImpl( objectMapper, partitionId, rawMetadata.getIntent(), rawMetadata.getRecordType(), rawMetadata.getRejectionType(), BufferUtil.bufferAsString(rawMetadata.getRejectionReason()), rawMetadata.getValueType()); record = recordMapper.map(rawEvent, metadata); exporterIndex = 0; shouldExecuteSideEffects = record != null; }
@Override public void writeRejection(TypedRecord<?> rejection) { final RecordMetadata metadata = rejection.getMetadata(); stage( RecordType.COMMAND_REJECTION, metadata.getIntent(), rejection.getKey(), rejection.getMetadata().getRejectionType(), rejection.getMetadata().getRejectionReason(), rejection.getMetadata(), rejection.getValue()); }
@Override public void writeRejection(TypedRecord<?> rejection) { final RecordMetadata metadata = rejection.getMetadata(); stage( RecordType.COMMAND_REJECTION, metadata.getIntent(), rejection.getKey(), rejection.getMetadata().getRejectionType(), rejection.getMetadata().getRejectionReason(), rejection.getMetadata(), rejection.getValue()); }
@Test public void shouldRejectCancellationInDirectSuccession() { // given streamProcessorRule.deploy(SERVICE_TASK_WORKFLOW); streamProcessor.blockAfterJobEvent(r -> r.getMetadata().getIntent() == JobIntent.CREATE); final TypedRecord<WorkflowInstanceRecord> createdEvent = streamProcessorRule.createWorkflowInstance(PROCESS_ID); waitUntil(() -> streamProcessor.isBlocked()); envRule.writeCommand( createdEvent.getKey(), WorkflowInstanceIntent.CANCEL, createdEvent.getValue()); envRule.writeCommand( createdEvent.getKey(), WorkflowInstanceIntent.CANCEL, createdEvent.getValue()); // when streamProcessor.unblock(); // then streamProcessorRule.awaitElementInState("process", WorkflowInstanceIntent.ELEMENT_TERMINATED); final List<WorkflowInstanceIntent> workflowInstanceLifecycle = envRule.events().onlyStatesOf("process").collect(Collectors.toList()); LifecycleAssert.assertThat(workflowInstanceLifecycle).compliesWithCompleteLifecycle(); final TypedRecord<WorkflowInstanceRecord> rejection = envRule.events().onlyWorkflowInstanceRecords().onlyRejections().findFirst().get(); assertThat(rejection.getMetadata().getIntent()).isEqualTo(WorkflowInstanceIntent.CANCEL); assertThat(BufferUtil.bufferAsString(rejection.getMetadata().getRejectionReason())) .isEqualTo( "Expected to cancel a workflow instance with key '" + createdEvent.getKey() + "', but no such workflow was found"); }
@Test public void shouldRejectCancellationInDirectSuccession() { // given streamProcessorRule.deploy(SERVICE_TASK_WORKFLOW); streamProcessor.blockAfterJobEvent(r -> r.getMetadata().getIntent() == JobIntent.CREATE); final TypedRecord<WorkflowInstanceRecord> createdEvent = streamProcessorRule.createWorkflowInstance(PROCESS_ID); waitUntil(() -> streamProcessor.isBlocked()); envRule.writeCommand( createdEvent.getKey(), WorkflowInstanceIntent.CANCEL, createdEvent.getValue()); envRule.writeCommand( createdEvent.getKey(), WorkflowInstanceIntent.CANCEL, createdEvent.getValue()); // when streamProcessor.unblock(); // then streamProcessorRule.awaitElementInState("process", WorkflowInstanceIntent.ELEMENT_TERMINATED); final List<WorkflowInstanceIntent> workflowInstanceLifecycle = envRule.events().onlyStatesOf("process").collect(Collectors.toList()); LifecycleAssert.assertThat(workflowInstanceLifecycle).compliesWithCompleteLifecycle(); final TypedRecord<WorkflowInstanceRecord> rejection = envRule.events().onlyWorkflowInstanceRecords().onlyRejections().findFirst().get(); assertThat(rejection.getMetadata().getIntent()).isEqualTo(WorkflowInstanceIntent.CANCEL); assertThat(BufferUtil.bufferAsString(rejection.getMetadata().getRejectionReason())) .isEqualTo( "Expected to cancel a workflow instance with key '" + createdEvent.getKey() + "', but no such workflow was found"); }
.hasRecordType(metadata.getRecordType()) .hasRejectionType(metadata.getRejectionType()) .hasRejectionReason(bufferAsString(metadata.getRejectionReason())) .hasValueType(metadata.getValueType());
.hasRecordType(metadata.getRecordType()) .hasRejectionType(metadata.getRejectionType()) .hasRejectionReason(bufferAsString(metadata.getRejectionReason())) .hasValueType(metadata.getValueType());