ProcessEngine static method Mocking using junit

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:

  1. 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.
  2. 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.

I am too late to answer this, but I just found out a workaround using Reflection

		ProcessEngines processEngines = mock(ProcessEngines.class);
		Map<String, ProcessEngine> processEngineMap = new HashMap<String, ProcessEngine>();
		ProcessEngine processEngine = mock(ProcessEngine.class);
		processEngineMap.put("default",processEngine);
		ReflectionTestUtils.setField(processEngines, "processEngines", processEngineMap);
		ReflectionTestUtils.setField(processEngines, "isInitialized", true);