Hi Camunda Team,
I have created a simple BPMN file which fetch the data from DB and print on console. While testing process deployment using JUnit test case my service throwing NullPointerException it is only throwing NPE in test cases.
Do we have any alternative way in camunda to inject/mock the service?
Here is my test case:
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
public class WorkflowDeploymentTest {
@Rule
public ProcessEngineRule rule = new ProcessEngineRule(
new StandaloneInMemProcessEngineConfiguration()
.buildProcessEngine());
@Test
@Deployment(resources = "EmployeeTracker.bpmn")
public void processDeploymentTest() {
ProcessEngine processEngine = rule.getProcessEngine();
ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("Employee_Progress_Tracker");
Assert.assertNotNull(processInstance);
}
}
Here is my Employee Tracker Delegates:
@Slf4j
@Component
public class EmpTracker implements JavaDelegate {
@Autowired
private EmployeeService service;
@Override
public void execute(DelegateExecution execution) throws Exception {
log.info("{} initiated!", this.getClass().getSimpleName());
/*
* Fetch employee based on progress status
*/
List<EmployeeProgress> indices = service.pollingOnStatus(PROGRESS,
EmployeeProgress.class, INCL_EMPLOYEE_PROGRESS_SOURCE);
for(EmployeeProgress emp : indices)
{
log.info("Employee detail is: {}", emp)
}
}
}
Could you help to inject service to avoid NPE at service.pollingOnStatus(…) Appreciate your help,
Cheers,
Tim