use of org.kie.kogito.uow.events.UnitOfWorkAbortEvent in project kogito-runtimes by kiegroup.
the class MongoDBTransactionManagerIT method testAbort.
@Test
void testAbort() {
String testName = "test_abort";
MongoDatabase mongoDatabase = mongoClient.getDatabase(testName);
MongoCollection<Document> mongoCollection = mongoDatabase.getCollection(testName);
mongoCollection.insertOne(new Document().append(DOCUMENT_ID, "test0"));
MongoDBTransactionManager transactionManager = new TestTransactionManager(mongoClient);
String id1 = "test1";
String value1 = "test1";
transactionManager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
mongoCollection.insertOne(transactionManager.getClientSession(), new Document().append(DOCUMENT_ID, id1).append(TEST_KEY, value1));
Document result = mongoCollection.find(transactionManager.getClientSession(), Filters.eq(DOCUMENT_ID, id1)).first();
assertEquals(new Document().append(DOCUMENT_ID, id1).append(TEST_KEY, value1), result);
int size1 = (int) mongoCollection.countDocuments(transactionManager.getClientSession());
assertEquals(2, size1);
int size2 = (int) mongoCollection.countDocuments();
assertEquals(1, size2);
transactionManager.onAfterAbortEvent(new UnitOfWorkAbortEvent(null));
int size3 = (int) mongoCollection.countDocuments();
assertEquals(1, size3);
}
use of org.kie.kogito.uow.events.UnitOfWorkAbortEvent in project kogito-runtimes by kiegroup.
the class MongoDBTransactionManagerTest 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();
}
use of org.kie.kogito.uow.events.UnitOfWorkAbortEvent in project kogito-runtimes by kiegroup.
the class AbstractTransactionManagerIT method testAbort.
@Test
void testAbort() {
String testName = "test_abort";
MongoDatabase mongoDatabase = mongoClient.getDatabase(testName);
MongoCollection<Document> mongoCollection = mongoDatabase.getCollection(testName);
mongoCollection.insertOne(new Document().append(DOCUMENT_ID, "test0"));
AbstractTransactionManager transactionManager = new TestTransactionManager(mongoClient);
String id1 = "test1";
String value1 = "test1";
transactionManager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
mongoCollection.insertOne(transactionManager.getClientSession(), new Document().append(DOCUMENT_ID, id1).append(TEST_KEY, value1));
Document result = mongoCollection.find(transactionManager.getClientSession(), Filters.eq(DOCUMENT_ID, id1)).first();
assertEquals(new Document().append(DOCUMENT_ID, id1).append(TEST_KEY, value1), result);
int size1 = (int) mongoCollection.countDocuments(transactionManager.getClientSession());
assertEquals(2, size1);
int size2 = (int) mongoCollection.countDocuments();
assertEquals(1, size2);
transactionManager.onAfterAbortEvent(new UnitOfWorkAbortEvent(null));
int size3 = (int) mongoCollection.countDocuments();
assertEquals(1, size3);
}
use of org.kie.kogito.uow.events.UnitOfWorkAbortEvent in project kogito-runtimes by kiegroup.
the class MongoDBTransactionManagerTest method enabled.
@Test
void enabled() {
MongoDBTransactionManager manager = new MongoDBTransactionManager(mongoClient) {
@Override
public boolean enabled() {
return false;
}
};
manager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
manager.onAfterAbortEvent(new UnitOfWorkAbortEvent(null));
verify(mongoClient, never()).startSession();
}
use of org.kie.kogito.uow.events.UnitOfWorkAbortEvent 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();
}
Aggregations