AnsweredAssumed Answered

Activiti-cdi + EJB + Unit test

Question asked by ntanghe on Feb 14, 2013
Latest reply on Feb 21, 2013 by ronald.van.kuijk
Hi,

I would use ejb injection in Javadelegate or taskListener.

So, an example :

public class Service1 implements JavaDelegate {
   @EJB
   private ServiceEJB service;
   
   @Override
   public void execute(DelegateExecution execution) throws Exception {
      
                 // some stuff with process
                …
                // call ejb
      service.update(….)      
   }
}

With activiti-cdi, it's normally possible.

Now, I would like to do some UNIT testing

When I launch my unit test like this
RuntimeService runtimeService = activitiRule.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(xxxx);

I have a nullPointerException for my ejb.
Ok, it's normal, I am not in a CDI container.

My question is :
- How is it possible to mock my injected ejb ?

I saw a class org.activiti.engine.test.mock.Mocks but it seems only to mock EL.


Someone has an idea ?

thanks,
Nicolas

Outcomes