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