ProcessInstance instance = mock(ProcessInstance.class);
when(instance.getId()).thenReturn(processInstanceId);
ProcessInstanceQuery query = mock(ProcessInstanceQuery.class);
when(query.singleResult()).thenReturn(instance);
when(query.processInstanceBusinessKey(eq(businessKey))).thenReturn(query);
RuntimeService runtimeService = mock(RuntimeService.class);
when(runtimeService.createProcessInstanceQuery()).thenReturn(query);
when(runtimeService.getVariable(eq(processInstanceId), eq(CoreProcessVariables.PROVIDER)))
.thenReturn(providerId);