@Test
public void testSetUser() {

    final IdentityProvider identityProvider = mock(IdentityProvider.class);
    final String userId = "userId";
    when(identityProvider.getName()).thenReturn(userId);
    when(environment.get("IdentityProvider")).thenReturn(identityProvider);
    final WorkflowProcessInstance processInstance = mock(WorkflowProcessInstance.class);
    final HashMap<String, Object> metaData = new HashMap<>();
    when(processInstance.getMetaData()).thenReturn(metaData);
    final ProcessStartedEvent event = new ProcessStartedEventImpl(processInstance, mock(KieRuntime.class ));
    listener.beforeProcessStarted(event);
    assertEquals(userId, metaData.get("OwnerId"));
    verify(processInstance).setVariable("initiator", userId);
}