Need to write junit for service class whose process engine is as below
ProcessEngine processEngine= ProcessEngines.getDefaultProcessEngine();
DecisionService decisionService = processEngine.getDecisionService();
Map<String, Object> listOfObjects = new HashMap<String, Object>();
listOfObjects = delegateExecution.getVariables();
Have tried all the possible ways to mock the static method using mockito but it always returns
as below.
when() requires an argument which has to be ‘a method call on a mock’.
For example:
when(mock.getArticles()).thenReturn(articles);Also, this error might show up because:
- you stub either of: final/private/equals()/hashCode() methods.
Those methods cannot be stubbed/verified.
Mocking methods declared on non-public parent classes is not supported.- inside when() you don’t call method on mock but on some other object.
@Before
public void mockProcess() {
engine=mock(ProcessEngine.class);
engines=mock(ProcessEngines.class);
}
when(engines.getDefaultProcessEngine()).thenReturn(engine);
Have tried with the class name directly too. Please suggest a way to mock this process engine using mockito.