use of org.drools.core.event.ProcessStartedEventImpl in project jbpm by kiegroup.
the class IdentityProviderAwareProcessListenerTest method testSetUser.
@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);
}
use of org.drools.core.event.ProcessStartedEventImpl in project jbpm by kiegroup.
the class IdentityProviderAwareProcessListenerTest method testUserNotSet.
@Test
public void testUserNotSet() {
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);
assertTrue(metaData.isEmpty());
verify(processInstance, never()).setVariable(anyString(), anyString());
}
Aggregations