Search in sources :

Example 16 with UnitOfWorkStartEvent

use of org.kie.kogito.uow.events.UnitOfWorkStartEvent in project kogito-runtimes by kiegroup.

the class AbstractTransactionManagerTest method onAfterEndEvent.

@Test
void onAfterEndEvent() {
    manager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
    manager.onAfterEndEvent(new UnitOfWorkEndEvent(null));
    verify(clientSession, times(1)).commitTransaction();
    verify(clientSession, times(1)).close();
}
Also used : UnitOfWorkStartEvent(org.kie.kogito.uow.events.UnitOfWorkStartEvent) UnitOfWorkEndEvent(org.kie.kogito.uow.events.UnitOfWorkEndEvent) Test(org.junit.jupiter.api.Test)

Example 17 with UnitOfWorkStartEvent

use of org.kie.kogito.uow.events.UnitOfWorkStartEvent in project kogito-runtimes by kiegroup.

the class AbstractTransactionManagerTest method enabled.

@Test
void enabled() {
    AbstractTransactionManager manager = new AbstractTransactionManager(mongoClient, false) {
    };
    manager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
    manager.onAfterAbortEvent(new UnitOfWorkAbortEvent(null));
    verify(mongoClient, never()).startSession();
}
Also used : UnitOfWorkStartEvent(org.kie.kogito.uow.events.UnitOfWorkStartEvent) UnitOfWorkAbortEvent(org.kie.kogito.uow.events.UnitOfWorkAbortEvent) Test(org.junit.jupiter.api.Test)

Example 18 with UnitOfWorkStartEvent

use of org.kie.kogito.uow.events.UnitOfWorkStartEvent in project kogito-runtimes by kiegroup.

the class AbstractTransactionManagerTest method onBeforeStartEvent.

@Test
void onBeforeStartEvent() {
    manager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
    verify(clientSession, times(1)).startTransaction(any());
}
Also used : UnitOfWorkStartEvent(org.kie.kogito.uow.events.UnitOfWorkStartEvent) Test(org.junit.jupiter.api.Test)

Example 19 with UnitOfWorkStartEvent

use of org.kie.kogito.uow.events.UnitOfWorkStartEvent in project kogito-runtimes by kiegroup.

the class AbstractTransactionManagerTest method onAfterAbortEvent.

@Test
void onAfterAbortEvent() {
    manager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
    manager.onAfterAbortEvent(new UnitOfWorkAbortEvent(null));
    verify(clientSession, times(1)).abortTransaction();
    verify(clientSession, times(1)).close();
}
Also used : UnitOfWorkStartEvent(org.kie.kogito.uow.events.UnitOfWorkStartEvent) UnitOfWorkAbortEvent(org.kie.kogito.uow.events.UnitOfWorkAbortEvent) Test(org.junit.jupiter.api.Test)

Example 20 with UnitOfWorkStartEvent

use of org.kie.kogito.uow.events.UnitOfWorkStartEvent in project kogito-runtimes by kiegroup.

the class AbstractTransactionManagerTest method getClientSession.

@Test
void getClientSession() {
    assertNull(manager.getClientSession());
    manager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
    assertEquals(clientSession, manager.getClientSession());
}
Also used : UnitOfWorkStartEvent(org.kie.kogito.uow.events.UnitOfWorkStartEvent) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)21 UnitOfWorkStartEvent (org.kie.kogito.uow.events.UnitOfWorkStartEvent)21 UnitOfWorkEndEvent (org.kie.kogito.uow.events.UnitOfWorkEndEvent)11 UnitOfWorkAbortEvent (org.kie.kogito.uow.events.UnitOfWorkAbortEvent)8 MongoDatabase (com.mongodb.client.MongoDatabase)6 ExecutorService (java.util.concurrent.ExecutorService)6 Document (org.bson.Document)6 ArrayList (java.util.ArrayList)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 Future (java.util.concurrent.Future)4 AbstractTransactionManager (org.kie.kogito.mongodb.transaction.AbstractTransactionManager)3 MongoClient (com.mongodb.client.MongoClient)2 MongoClients (com.mongodb.client.MongoClients)2 MongoCollection (com.mongodb.client.MongoCollection)2 MongoCursor (com.mongodb.client.MongoCursor)2 Filters (com.mongodb.client.model.Filters)2 List (java.util.List)2 Objects (java.util.Objects)2 ExecutionException (java.util.concurrent.ExecutionException)2 Executors (java.util.concurrent.Executors)2