Search in sources :

Example 11 with DataEvent

use of org.kie.kogito.event.DataEvent in project kogito-runtimes by kiegroup.

the class MongoDBEventPublisherTest method testPublishEvents_withTransaction.

@Test
void testPublishEvents_withTransaction() {
    ClientSession clientSession = mock(ClientSession.class);
    when(transactionManager.getClientSession()).thenReturn(clientSession);
    when(transactionManager.enabled()).thenReturn(true);
    publisher.configure();
    List<DataEvent<?>> events = new ArrayList<>();
    events.add(processInstanceDataEvent);
    events.add(userTaskInstanceDataEvent);
    events.add(variableInstanceDataEvent);
    events.add(event);
    publisher.publish(events);
    verify(mongoCollection, times(3)).insertOne(eq(clientSession), any(AbstractDataEvent.class));
    verify(mongoCollection, times(3)).deleteOne(eq(clientSession), any());
    verify(mongoCollection).insertOne(eq(clientSession), eq(processInstanceDataEvent));
    verify(mongoCollection).deleteOne(eq(clientSession), eq(Filters.eq(ID, "testProcessInstanceEvent")));
    verify(mongoCollection).insertOne(eq(clientSession), eq(userTaskInstanceDataEvent));
    verify(mongoCollection).deleteOne(eq(clientSession), eq(Filters.eq(ID, "testUserTaskInstanceEvent")));
    verify(mongoCollection).insertOne(eq(clientSession), eq(variableInstanceDataEvent));
    verify(mongoCollection).deleteOne(eq(clientSession), eq(Filters.eq(ID, "testVariableInstanceEvent")));
}
Also used : ClientSession(com.mongodb.client.ClientSession) ArrayList(java.util.ArrayList) AbstractDataEvent(org.kie.kogito.event.AbstractDataEvent) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) VariableInstanceDataEvent(org.kie.kogito.event.process.VariableInstanceDataEvent) DataEvent(org.kie.kogito.event.DataEvent) ProcessInstanceDataEvent(org.kie.kogito.event.process.ProcessInstanceDataEvent) AbstractDataEvent(org.kie.kogito.event.AbstractDataEvent) Test(org.junit.jupiter.api.Test)

Aggregations

DataEvent (org.kie.kogito.event.DataEvent)11 ProcessInstanceDataEvent (org.kie.kogito.event.process.ProcessInstanceDataEvent)11 UserTaskInstanceDataEvent (org.kie.kogito.event.process.UserTaskInstanceDataEvent)11 VariableInstanceDataEvent (org.kie.kogito.event.process.VariableInstanceDataEvent)11 Test (org.junit.jupiter.api.Test)10 HashMap (java.util.HashMap)9 Application (org.kie.kogito.Application)9 Model (org.kie.kogito.Model)9 ProcessInstanceEventBody (org.kie.kogito.event.process.ProcessInstanceEventBody)9 Processes (org.kie.kogito.process.Processes)9 UnitOfWork (org.kie.kogito.uow.UnitOfWork)9 ArrayList (java.util.ArrayList)6 List (java.util.List)5 Person (org.kie.kogito.codegen.data.Person)3 VariableInstanceEventBody (org.kie.kogito.event.process.VariableInstanceEventBody)3 Collection (java.util.Collection)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 MilestoneEventBody (org.kie.kogito.event.process.MilestoneEventBody)2