Search in sources :

Example 1 with MongoDBTransactionManager

use of org.kie.kogito.mongodb.transaction.MongoDBTransactionManager in project kogito-runtimes by kiegroup.

the class KogitoProcessInstancesFactoryIT method test.

@Test
void test() {
    MongoDBTransactionManager transactionManager = mock(MongoDBTransactionManager.class);
    KogitoProcessInstancesFactory factory = new KogitoProcessInstancesFactory(getMongoClient()) {

        @Override
        public String dbName() {
            return DB_NAME;
        }

        @Override
        public MongoDBTransactionManager transactionManager() {
            return transactionManager;
        }

        @Override
        public boolean lock() {
            return false;
        }
    };
    assertNotNull(factory);
    assertThat(factory.dbName()).isEqualTo(DB_NAME);
    Process<?> process = mock(Process.class);
    lenient().when(process.id()).thenReturn(PROCESS_NAME);
    lenient().when(process.name()).thenReturn(PROCESS_NAME);
    MongoDBProcessInstances<?> instance = factory.createProcessInstances(process);
    assertNotNull(instance);
    assertEquals(transactionManager, factory.transactionManager());
}
Also used : MongoDBTransactionManager(org.kie.kogito.mongodb.transaction.MongoDBTransactionManager) KogitoProcessInstancesFactory(org.kie.kogito.persistence.KogitoProcessInstancesFactory) Test(org.junit.jupiter.api.Test)

Example 2 with MongoDBTransactionManager

use of org.kie.kogito.mongodb.transaction.MongoDBTransactionManager in project kogito-runtimes by kiegroup.

the class MongoDBProcessInstancesIT method testValuesReadMode.

@Test
void testValuesReadMode() {
    MongoDBTransactionManager transactionManager = new MongoDBTransactionManager(mongoClient) {

        @Override
        public boolean enabled() {
            return false;
        }
    };
    testValuesReadMode(transactionManager);
}
Also used : MongoDBTransactionManager(org.kie.kogito.mongodb.transaction.MongoDBTransactionManager) Test(org.junit.jupiter.api.Test)

Example 3 with MongoDBTransactionManager

use of org.kie.kogito.mongodb.transaction.MongoDBTransactionManager in project kogito-runtimes by kiegroup.

the class MongoDBProcessInstancesIT method testValuesReadModeWithTransaction.

@Test
void testValuesReadModeWithTransaction() {
    MongoDBTransactionManager transactionManager = new MongoDBTransactionManager(mongoClient) {

        @Override
        public boolean enabled() {
            return true;
        }
    };
    transactionManager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
    testValuesReadMode(transactionManager);
    transactionManager.onAfterEndEvent(new UnitOfWorkEndEvent(null));
}
Also used : MongoDBTransactionManager(org.kie.kogito.mongodb.transaction.MongoDBTransactionManager) UnitOfWorkStartEvent(org.kie.kogito.uow.events.UnitOfWorkStartEvent) UnitOfWorkEndEvent(org.kie.kogito.uow.events.UnitOfWorkEndEvent) Test(org.junit.jupiter.api.Test)

Example 4 with MongoDBTransactionManager

use of org.kie.kogito.mongodb.transaction.MongoDBTransactionManager in project kogito-runtimes by kiegroup.

the class MongoDBProcessInstancesIT method testFindByIdReadModeWithTransaction.

@Test
void testFindByIdReadModeWithTransaction() {
    MongoDBTransactionManager transactionManager = new MongoDBTransactionManager(mongoClient) {

        @Override
        public boolean enabled() {
            return true;
        }
    };
    transactionManager.onBeforeStartEvent(new UnitOfWorkStartEvent(null));
    testFindByIdReadMode(transactionManager);
    transactionManager.onAfterEndEvent(new UnitOfWorkEndEvent(null));
}
Also used : MongoDBTransactionManager(org.kie.kogito.mongodb.transaction.MongoDBTransactionManager) UnitOfWorkStartEvent(org.kie.kogito.uow.events.UnitOfWorkStartEvent) UnitOfWorkEndEvent(org.kie.kogito.uow.events.UnitOfWorkEndEvent) Test(org.junit.jupiter.api.Test)

Example 5 with MongoDBTransactionManager

use of org.kie.kogito.mongodb.transaction.MongoDBTransactionManager in project kogito-runtimes by kiegroup.

the class MongoDBProcessInstancesIT method testFindByIdReadMode.

@Test
void testFindByIdReadMode() {
    MongoDBTransactionManager transactionManager = new MongoDBTransactionManager(mongoClient) {

        @Override
        public boolean enabled() {
            return false;
        }
    };
    testFindByIdReadMode(transactionManager);
}
Also used : MongoDBTransactionManager(org.kie.kogito.mongodb.transaction.MongoDBTransactionManager) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)9 MongoDBTransactionManager (org.kie.kogito.mongodb.transaction.MongoDBTransactionManager)9 UnitOfWorkEndEvent (org.kie.kogito.uow.events.UnitOfWorkEndEvent)4 UnitOfWorkStartEvent (org.kie.kogito.uow.events.UnitOfWorkStartEvent)4 MongoClient (com.mongodb.client.MongoClient)2 Document (org.bson.Document)2 ClassPathResource (org.drools.core.io.impl.ClassPathResource)2 BpmnProcess (org.kie.kogito.process.bpmn2.BpmnProcess)2 BpmnVariables (org.kie.kogito.process.bpmn2.BpmnVariables)2 ClientSession (com.mongodb.client.ClientSession)1 MongoClients (com.mongodb.client.MongoClients)1 MongoCollection (com.mongodb.client.MongoCollection)1 MongoDatabase (com.mongodb.client.MongoDatabase)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1