Search in sources :

Example 76 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class AbstractStoreManagerTest method testTxCrudInsertTwoCommit.

@Test(expected = IllegalStateException.class)
public void testTxCrudInsertTwoCommit() {
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final Car car = createNewCar();
        storeManager.getDataStore().create(car);
        transaction.commit();
        transaction.commit();
    }
}
Also used : Car(io.vertigo.dynamo.store.data.domain.car.Car) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 77 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class AbstractStoreManagerTest method testSelectCountCars.

@Test
public void testSelectCountCars() {
    final TaskDefinition taskDefinition = TaskDefinition.builder("TK_COUNT_CARS").withEngine(TaskEngineSelect.class).withRequest("select count(*) from CAR").withOutRequired("count", Domain.builder("DO_COUNT", DataType.Long).build()).build();
    try (VTransactionWritable tx = transactionManager.createCurrentTransaction()) {
        final Task task = Task.builder(taskDefinition).build();
        final long count = taskManager.execute(task).getResult();
        // -----
        Assert.assertEquals(9, count);
    }
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 78 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class AbstractStoreManagerTest method testTxNativeInsertCrudInsertCommit.

@Test
public void testTxNativeInsertCrudInsertCommit() {
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final Car car = createNewCar();
        final Car car2 = createNewCar();
        nativeInsertCar(car2);
        storeManager.getDataStore().create(car);
        transaction.commit();
    }
}
Also used : Car(io.vertigo.dynamo.store.data.domain.car.Car) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 79 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class AbstractStoreManagerTest method testTxNativeInsertCrudSelectRollback.

@Test
public void testTxNativeInsertCrudSelectRollback() {
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final Car car = createNewCar();
        nativeInsertCar(car);
        // on récupère la liste des voitures
        checkCrudCarsCount(1);
    }
}
Also used : Car(io.vertigo.dynamo.store.data.domain.car.Car) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 80 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class SqlUtil method execRequests.

public static void execRequests(final VTransactionManager transactionManager, final TaskManager taskManager, final List<String> requests, final String taskName, final Optional<String> optDataSpace) {
    // A chaque test on recrée la table famille
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        for (final String request : requests) {
            final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineProc.class).withRequest(request).withDataSpace(optDataSpace.orElse(null)).build();
            final Task task = Task.builder(taskDefinition).build();
            taskManager.execute(task);
        }
    }
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) TaskEngineProc(io.vertigo.dynamox.task.TaskEngineProc) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable)

Aggregations

VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)80 Test (org.junit.Test)63 Car (io.vertigo.dynamo.store.data.domain.car.Car)22 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)22 Task (io.vertigo.dynamo.task.model.Task)22 SuperHero (io.vertigo.dynamo.task.data.domain.SuperHero)18 DtList (io.vertigo.dynamo.domain.model.DtList)7 Flower (io.vertigo.dynamo.kvstore.data.Flower)6 Famille (io.vertigo.dynamo.store.data.domain.famille.Famille)6 SqlConnection (io.vertigo.database.sql.connection.SqlConnection)5 DtListURI (io.vertigo.dynamo.domain.model.DtListURI)5 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)4 DtListURIForCriteria (io.vertigo.dynamo.domain.model.DtListURIForCriteria)4 URI (io.vertigo.dynamo.domain.model.URI)4 Item (io.vertigo.dynamo.search.data.domain.Item)4 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)4 Car (io.vertigo.dynamo.search_2_4.data.domain.Car)4 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)4 ArrayList (java.util.ArrayList)4 Domain (io.vertigo.dynamo.domain.metamodel.Domain)3