Test workflow with Spring boot eventing bridge

Hello !

I removed camunda reactor which is deprecated and archived to use the standard spring boot eventing bridge described in the documentation. Everything runs fine except the tests.

The method annotated with @EventListener is never called in my tests. I tried to call it manually but then the Context in camunda-engine is null and produces an NPE.

Here is my listener :

@Component
class WorkflowTaskListener(private val taskDefinitions: WorkflowTaskDefinitionSource) {

    @EventListener(condition = "#delegateExecution.bpmnModelElementInstance.elementType.typeName==‘userTask’")
    fun onTaskEvent(delegateTask: DelegateTask) {
        val taskDefinition = taskDefinitions.findByName(delegateTask.taskDefinitionKey)
...

This is never called in my tests.

This is my configuration file :

internal class CamundaTestEngineConfiguration() :
    StandaloneInMemProcessEngineConfiguration() {

    init {
        databaseSchemaUpdate = DB_SCHEMA_UPDATE_TRUE
        jobExecutorActivate = false
        isDbMetricsReporterActivate = false
        this.historyLevel = HistoryLevel.HISTORY_LEVEL_FULL

        with(processEnginePlugins) {
            add(SpinProcessEnginePlugin())
        }
    }
}

Do I have to keep implementing TaskListener ? The notify method isn’t called either when I rename onTaskEvent to notify in order to override the TaskListener method :frowning:

I assume, you’re running the test with the JUnit ProcessEngineExtension?
In this case, the Spring boot context will not be initialized and only an in memory test is started.
Consider using @SpringBootTest if you want to write integration tests that use Spring features.

Thanks for your answer !
I use StandaloneInMemProcessEngineConfiguration and build the process engine like this :

 private object EngineConfigurationHolder {
        private val engineConfiguration = CamundaTestEngineConfiguration()

        fun getBuiltProcessEngine(): ProcessEngine =
            engineConfiguration.processEngine ?: engineConfiguration.buildProcessEngine()
    }

I already added the SpringBootTest annotation like you said but the method is still not called

You can try the following: When using a @SpringBootTest the engine is set up automatically. You can use a test-specific application.yml file to configure the engine. To access the engine and its services, use the @Autowired annotation on corresponding fields, for example

@Autowired
RuntimeService runtimeService