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")));
}
Aggregations