Introduction to Camunda

Camunda is a popular open-source platform for workflow and process automation. It enables developers to model, automate, and optimize business processes. Camunda integrates well with Java applications, offering robust capabilities for managing complex workflows and business rules.
Understanding the Error
When performing integration testing in Camunda, you might encounter the following error:
org.camunda.bpm.engine.exception.NullValueException: No startFormHandler defined in process 'SalesOrderProcess_v2:1:cee4056f-a1d8-11eb-9f61-6683657f7a30': startFormHandler is null
This error occurs because the start event of the process expects a form handler to be defined, but none is provided. The startFormHandler is responsible for managing the form associated with the start event. When it is not defined, Camunda throws a NullValueException
. This problem likely cause because of, usually camunda will have BpmnParser class that when reading the XML bpmn file, it will construct the event handler. But in your test, you not inject it
Solution: Mocking the Start Event Handler
To resolve this issue, you can mock the start event handler in your integration tests. The following example demonstrates how to set up a mock start event handler to bypass the error and proceed with the testing.
Truncate table to make sure it clean state before test
- ACT_HI_ACTINST - ACT_HI_DETAIL - ACT_HI_PROCINST - ACT_HI_TASKINST - ACT_RU_EXECUTION - ACT_RU_IDENTITYLINK - ACT_RU_TASK - ACT_RU_VARIABLE - ACT_RE_PROCDEF - ACT_RE_DEPLOYMENT - ACT_ID_USER - ACT_ID_GROUP - ACT_ID_MEMBERSHIP - ACT_ID_INFO - ACT_ID_TENANT - ACT_ID_TENANT_MEMBER - ACT_GE_BYTEARRAY
In this solution:
- The deployment cache is purged to ensure a clean state.
- The process definition is retrieved based on the process definition key.
- The deployment entity associated with the process definition is obtained.
- A
DefaultStartFormHandler
is created and associated with the deployment. - The form key is set using the
ExpressionManager
. - The
DelegateStartFormHandler
is assigned to the process definition. - The process definition is added back to the deployment cache.
