cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti-cdi + EJB + Unit test

ntanghe
Champ in-the-making
Champ in-the-making
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
3 REPLIES 3

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Use arquillian… Works great…

ntanghe
Champ in-the-making
Champ in-the-making
Thanks for your response.
It's a great solution.

But no way to simply mock objects ?

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise