use of io.camunda.zeebe.process.test.filters.RecordStream in project spring-zeebe by camunda-community-hub.
the class ZeebeTestExecutionListener method beforeTestMethod.
public void beforeTestMethod(@NonNull TestContext testContext) {
final RecordStream recordStream = RecordStream.of(zeebeEngine.getRecordStreamSource());
BpmnAssert.initRecordStream(recordStream);
ZeebeTestThreadSupport.setEngineForCurrentThread(zeebeEngine);
}
use of io.camunda.zeebe.process.test.filters.RecordStream in project zeebe-process-test by camunda-cloud.
the class ZeebeProcessTestExtension method beforeEach.
/**
* Before each test a new test engine gets created and started. A client to communicate with the
* engine will also be created. Together with a {@link RecordStream} these will be injected in the
* fields of the test class, if they are available.
*
* @param extensionContext jUnit5 extension context
*/
@Override
public void beforeEach(final ExtensionContext extensionContext) {
final ZeebeTestEngine engine = EngineFactory.create();
engine.start();
final ZeebeClient client = engine.createClient();
final RecordStream recordStream = RecordStream.of(engine.getRecordStreamSource());
try {
injectFields(extensionContext, engine, client, recordStream);
} catch (final Exception ex) {
client.close();
engine.stop();
throw ex;
}
BpmnAssert.initRecordStream(recordStream);
getStore(extensionContext).put(KEY_ZEEBE_CLIENT, client);
getStore(extensionContext).put(KEY_ZEEBE_ENGINE, engine);
}
use of io.camunda.zeebe.process.test.filters.RecordStream in project zeebe-process-test by camunda-cloud.
the class EngineClientTest method shouldPrintRecords.
@Test
void shouldPrintRecords() {
// given
zeebeClient.newDeployCommand().addProcessModel(Bpmn.createExecutableProcess("simpleProcess").startEvent().endEvent().done(), "simpleProcess.bpmn").send().join();
// when
zeebeClient.newCreateInstanceCommand().bpmnProcessId("simpleProcess").latestVersion().variables(Map.of("test", 1)).send().join();
// then
final RecordStream recordStream = RecordStream.of(zeebeEngine.getRecordStreamSource());
Awaitility.await().untilAsserted(() -> {
final Optional<Record<ProcessInstanceRecordValue>> processRecords = StreamSupport.stream(recordStream.processInstanceRecords().spliterator(), false).filter(r -> r.getValue().getBpmnElementType() == BpmnElementType.PROCESS).filter(r -> r.getIntent() == ProcessInstanceIntent.ELEMENT_COMPLETED).findFirst();
assertThat(processRecords).isNotEmpty();
});
recordStream.print(true);
}
use of io.camunda.zeebe.process.test.filters.RecordStream in project zeebe-process-test by camunda-cloud.
the class ZeebeProcessTestExtension method beforeEach.
/**
* Before each test the {@link ContainerizedEngine} is started. A client to communicate with the
* engine will be created, together with a {@link RecordStream}. These will be injected in the
* fields of the test class, if they are available.
*
* @param extensionContext jUnit5 extension context
*/
@Override
public void beforeEach(final ExtensionContext extensionContext) {
final Object engineContent = getStore(extensionContext.getParent().get()).get(KEY_ZEEBE_ENGINE);
final ContainerizedEngine engine = (ContainerizedEngine) engineContent;
engine.start();
final ZeebeClient client = engine.createClient();
final RecordStream recordStream = RecordStream.of(new RecordStreamSourceImpl(engine));
BpmnAssert.initRecordStream(recordStream);
getStore(extensionContext).put(KEY_ZEEBE_CLIENT, client);
injectFields(extensionContext, engine, client, recordStream);
}
use of io.camunda.zeebe.process.test.filters.RecordStream in project zeebe-process-test by camunda.
the class EngineClientTest method shouldPrintRecords.
@Test
void shouldPrintRecords() {
// given
zeebeClient.newDeployCommand().addProcessModel(Bpmn.createExecutableProcess("simpleProcess").startEvent().endEvent().done(), "simpleProcess.bpmn").send().join();
// when
zeebeClient.newCreateInstanceCommand().bpmnProcessId("simpleProcess").latestVersion().variables(Map.of("test", 1)).send().join();
// then
final RecordStream recordStream = RecordStream.of(zeebeEngine.getRecordStreamSource());
Awaitility.await().untilAsserted(() -> {
final Optional<Record<ProcessInstanceRecordValue>> processRecords = StreamSupport.stream(recordStream.processInstanceRecords().spliterator(), false).filter(r -> r.getValue().getBpmnElementType() == BpmnElementType.PROCESS).filter(r -> r.getIntent() == ProcessInstanceIntent.ELEMENT_COMPLETED).findFirst();
assertThat(processRecords).isNotEmpty();
});
recordStream.print(true);
}
Aggregations