Boundary event testing with camunda-platform-scenario

Hello,

I have been testing my BP schemas with camunda-platform-scenario, but, unfortunately, I was not able to find anywhere how is possible to test scenarios that involves boundary events. To test something like that:

Can you advise how I can test the next scenario: BP instance receives boundary event before timer triggers?

Thanks

Hi @knok16! Thank you for the question. If you’d like to open an issue in the repository, I’m sure @martin.schimak or @RasPelikan would be more than happy to help! :slight_smile:

1 Like

Hi,

Using scenario you define what should be done for each activity. Afterwards you run the process and it is completed in one run without pauses. So, you want to address this receive boundary event which needs to be done by using the runtime API of camunda (get this API by using the rest rule). Unfortunately, you can use the runtime API before running scenario (to early) of after (to late, timer event fired already).

As you want to send the message before the timer event you need to intercept the timer activity using scenario’s API. It looks like this:

when(myScenerio.waitsAtTimerEvent(“my timer”)).then(event → {
rule.getRuntimeApi().correlate message(…);
});

Since I can’t construct a working example at the moment I wrote this by heart. Maybe I hit not exactly the name of the APIs but using an IDE with code completion you should be able to construct a working example.

Cheers,
Stephan

2 Likes

Hello, thanks for your response, yeah I was able to solve it with the next code:
Rule setup

    @Rule
    val processEngineRule: ProcessEngineRule = TestCoverageProcessEngineRuleBuilder
        .create(processEngineConfiguration.buildProcessEngine())
        .assertClassCoverageAtLeast(1.0)
        .withDetailedCoverageLogging()
        .build()

Event sending (inside waitsAtServiceTask or waitsAtTimerEvent)

processEngineRule.processEngine.runtimeService
        .createMessageCorrelation(messageName)
        .correlateWithResult()
1 Like