Search in sources :

Example 1 with TypedEventImpl

use of io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl in project zeebe by camunda-cloud.

the class BlackListStateTest method createRecord.

private TypedEventImpl createRecord(final long processInstanceKey) {
    final ProcessInstanceRecord processInstanceRecord = new ProcessInstanceRecord();
    processInstanceRecord.setElementId("startEvent");
    processInstanceRecord.setBpmnProcessId(wrapString("process1"));
    processInstanceRecord.setProcessInstanceKey(processInstanceKey);
    processInstanceRecord.setFlowScopeKey(1001L);
    processInstanceRecord.setVersion(1);
    processInstanceRecord.setProcessDefinitionKey(2);
    processInstanceRecord.setBpmnElementType(BpmnElementType.START_EVENT);
    final RecordMetadata metadata = new RecordMetadata();
    metadata.intent(ProcessInstanceIntent.ACTIVATE_ELEMENT);
    metadata.valueType(ValueType.PROCESS_INSTANCE);
    final TypedEventImpl typedEvent = new TypedEventImpl(1);
    final LoggedEvent loggedEvent = mock(LoggedEvent.class);
    when(loggedEvent.getPosition()).thenReturn(1024L);
    typedEvent.wrap(loggedEvent, metadata, processInstanceRecord);
    return typedEvent;
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) TypedEventImpl(io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl) LoggedEvent(io.camunda.zeebe.logstreams.log.LoggedEvent) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord)

Example 2 with TypedEventImpl

use of io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl in project zeebe by camunda-cloud.

the class BlackListStateTest method shouldNotCallCallbackIfNotProcessInstanceIntent.

@Test
public void shouldNotCallCallbackIfNotProcessInstanceIntent() {
    // given
    final ProcessInstanceRecord processInstanceRecord = new ProcessInstanceRecord();
    processInstanceRecord.setElementId("PI");
    processInstanceRecord.setBpmnProcessId(wrapString("process1"));
    processInstanceRecord.setProcessInstanceKey(1000L);
    processInstanceRecord.setVersion(1);
    processInstanceRecord.setProcessDefinitionKey(2);
    processInstanceRecord.setBpmnElementType(BpmnElementType.START_EVENT);
    final RecordMetadata metadata = new RecordMetadata();
    metadata.intent(ProcessInstanceIntent.CANCEL);
    metadata.valueType(ValueType.PROCESS_INSTANCE);
    final TypedEventImpl typedEvent = new TypedEventImpl(1);
    final LoggedEvent loggedEvent = mock(LoggedEvent.class);
    when(loggedEvent.getPosition()).thenReturn(1024L);
    typedEvent.wrap(loggedEvent, metadata, processInstanceRecord);
    final var consumer = mock(Consumer.class);
    // when - no blacklisting
    blackListState.tryToBlacklist(typedEvent, consumer);
    // then
    assertThat(blackListState.isOnBlacklist(typedEvent)).isFalse();
    verify(consumer, never()).accept(1000L);
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) TypedEventImpl(io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl) LoggedEvent(io.camunda.zeebe.logstreams.log.LoggedEvent) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) Test(org.junit.jupiter.api.Test)

Example 3 with TypedEventImpl

use of io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl in project zeebe by zeebe-io.

the class BlackListStateTest method createRecord.

private TypedEventImpl createRecord(final long processInstanceKey) {
    final ProcessInstanceRecord processInstanceRecord = new ProcessInstanceRecord();
    processInstanceRecord.setElementId("startEvent");
    processInstanceRecord.setBpmnProcessId(wrapString("process1"));
    processInstanceRecord.setProcessInstanceKey(processInstanceKey);
    processInstanceRecord.setFlowScopeKey(1001L);
    processInstanceRecord.setVersion(1);
    processInstanceRecord.setProcessDefinitionKey(2);
    processInstanceRecord.setBpmnElementType(BpmnElementType.START_EVENT);
    final RecordMetadata metadata = new RecordMetadata();
    metadata.intent(ProcessInstanceIntent.ACTIVATE_ELEMENT);
    metadata.valueType(ValueType.PROCESS_INSTANCE);
    final TypedEventImpl typedEvent = new TypedEventImpl(1);
    final LoggedEvent loggedEvent = mock(LoggedEvent.class);
    when(loggedEvent.getPosition()).thenReturn(1024L);
    typedEvent.wrap(loggedEvent, metadata, processInstanceRecord);
    return typedEvent;
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) TypedEventImpl(io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl) LoggedEvent(io.camunda.zeebe.logstreams.log.LoggedEvent) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord)

Example 4 with TypedEventImpl

use of io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl in project zeebe by zeebe-io.

the class BlackListStateTest method shouldNotCallCallbackIfNotProcessInstanceIntent.

@Test
public void shouldNotCallCallbackIfNotProcessInstanceIntent() {
    // given
    final ProcessInstanceRecord processInstanceRecord = new ProcessInstanceRecord();
    processInstanceRecord.setElementId("PI");
    processInstanceRecord.setBpmnProcessId(wrapString("process1"));
    processInstanceRecord.setProcessInstanceKey(1000L);
    processInstanceRecord.setVersion(1);
    processInstanceRecord.setProcessDefinitionKey(2);
    processInstanceRecord.setBpmnElementType(BpmnElementType.START_EVENT);
    final RecordMetadata metadata = new RecordMetadata();
    metadata.intent(ProcessInstanceIntent.CANCEL);
    metadata.valueType(ValueType.PROCESS_INSTANCE);
    final TypedEventImpl typedEvent = new TypedEventImpl(1);
    final LoggedEvent loggedEvent = mock(LoggedEvent.class);
    when(loggedEvent.getPosition()).thenReturn(1024L);
    typedEvent.wrap(loggedEvent, metadata, processInstanceRecord);
    final var consumer = mock(Consumer.class);
    // when - no blacklisting
    blackListState.tryToBlacklist(typedEvent, consumer);
    // then
    assertThat(blackListState.isOnBlacklist(typedEvent)).isFalse();
    verify(consumer, never()).accept(1000L);
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) TypedEventImpl(io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl) LoggedEvent(io.camunda.zeebe.logstreams.log.LoggedEvent) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) Test(org.junit.jupiter.api.Test)

Example 5 with TypedEventImpl

use of io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl in project zeebe by camunda.

the class BlackListStateTest method shouldNotCallCallbackIfNotProcessInstanceIntent.

@Test
public void shouldNotCallCallbackIfNotProcessInstanceIntent() {
    // given
    final ProcessInstanceRecord processInstanceRecord = new ProcessInstanceRecord();
    processInstanceRecord.setElementId("PI");
    processInstanceRecord.setBpmnProcessId(wrapString("process1"));
    processInstanceRecord.setProcessInstanceKey(1000L);
    processInstanceRecord.setVersion(1);
    processInstanceRecord.setProcessDefinitionKey(2);
    processInstanceRecord.setBpmnElementType(BpmnElementType.START_EVENT);
    final RecordMetadata metadata = new RecordMetadata();
    metadata.intent(ProcessInstanceIntent.CANCEL);
    metadata.valueType(ValueType.PROCESS_INSTANCE);
    final TypedEventImpl typedEvent = new TypedEventImpl(1);
    final LoggedEvent loggedEvent = mock(LoggedEvent.class);
    when(loggedEvent.getPosition()).thenReturn(1024L);
    typedEvent.wrap(loggedEvent, metadata, processInstanceRecord);
    final var consumer = mock(Consumer.class);
    // when - no blacklisting
    blackListState.tryToBlacklist(typedEvent, consumer);
    // then
    assertThat(blackListState.isOnBlacklist(typedEvent)).isFalse();
    verify(consumer, never()).accept(1000L);
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) TypedEventImpl(io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl) LoggedEvent(io.camunda.zeebe.logstreams.log.LoggedEvent) ProcessInstanceRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord) Test(org.junit.jupiter.api.Test)

Aggregations

TypedEventImpl (io.camunda.zeebe.engine.processing.streamprocessor.TypedEventImpl)6 LoggedEvent (io.camunda.zeebe.logstreams.log.LoggedEvent)6 RecordMetadata (io.camunda.zeebe.protocol.impl.record.RecordMetadata)6 ProcessInstanceRecord (io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord)6 Test (org.junit.jupiter.api.Test)3