After looking at your tutorial, I tried to test my processes in similar way, but in Java. However, I am unable to mock the service task. My test runs the actual service task instead of the mock. I have also built TestConfiguration for MockExpressionManager, but still does not work.
Test
@RunWith(SpringRunner.class) @SpringBootTest
public class PortfolioProcessTest {
It looks everything is done correctly here, so I don’t know what doesn’t work. The only thing you haven’t shown is how the bean is called in the process definition - is it done by the EL expression?
If it is, the only thing I can think of is that something is not initialized properly. If you look into MockExpressionManager you will see its order of resolvers:
Where MockElResolver uses Mocks.get() to get your bean. Try to stop there with a breakpoint to check if it’s even called. If not, something is wrong with your initialization and the MockExpressionManager bean is not used.
Also I kept the breakpoint where MockElResolver uses Mocks.get(). It does not reach there.
However,MockExpressionManager gets initialized but the method “createElResolver(VariableContainer variableContainer)” is not called.
public class MyConfigurer implements EngineConfigurationConfigurer {
public void configure(SpringProcessEngineConfiguration processEngineConfiguration) {
// advanced configuration
MockExpressionManager mockExpressionManager = new MockExpressionManager();
processEngineConfiguration.setExpressionManager(mockExpressionManager);
}
Unfortunately from my point of view this should work and I cannot see any bugs in the above code. Maybe something has been changed in Flowable?
I can hint you with following things only:
In my BPMN editor flowable used activity namespace not flowable, for example <serviceTask id="banUserTask" name="Ban user" activiti:expression="#{banUserServiceTask.ban(userId)}"></serviceTask>
Before MockElResolver you have ProcessVariableScopeELResolver - is this possible that you have the process variable named rejectMailPms which points to the original bean? If so, it’d be resolved by this resolver.
If MockExpressionManager.createElResolver() isn’t even called, you probably work with DefaultExpressionManager. You can stop with breakpoint in its createElResolver() method and check. If so, you need to dig deeper to find out why your MockElResolver is not properly registered in flowable engine with this configuration.