use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class SearchManagerStoreTest method doSetUp.
@Override
protected void doSetUp() throws Exception {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
itemIndexDefinition = definitionSpace.resolve(IDX_ITEM, SearchIndexDefinition.class);
// A chaque test on recrée la table famille
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final SqlConnection connection = dataBaseManager.getConnectionProvider(SqlDataBaseManager.MAIN_CONNECTION_PROVIDER_NAME).obtainConnection();
execCallableStatement(connection, "create table item(ID BIGINT, MANUFACTURER varchar(50), MODEL varchar(255), DESCRIPTION varchar(512), YEAR INT, KILO INT, PRICE INT, CONSOMMATION NUMERIC(8,2), MOTOR_TYPE varchar(50), OPTIONAL_NUMBER BIGINT, OPTIONAL_STRING varchar(50), LAST_MODIFIED timestamp );");
execCallableStatement(connection, "create sequence SEQ_ITEM start with 10001 increment by 1");
}
// On supprime tout
remove("*:*");
final ItemDataBase itemDataBase = new ItemDataBase();
initialDbItemSize = itemDataBase.size();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
for (final Item item : itemDataBase.getAllItems()) {
item.setId(null);
storeManager.getDataStore().create(item);
}
transaction.commit();
}
waitIndexation();
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class SearchManagerStoreTest method doTearDown.
/**
* {@inheritDoc}
*/
@Override
protected void doTearDown() throws Exception {
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
// A chaque fin de test on arréte la base.
final SqlConnection connection = dataBaseManager.getConnectionProvider(SqlDataBaseManager.MAIN_CONNECTION_PROVIDER_NAME).obtainConnection();
execCallableStatement(connection, "shutdown;");
transaction.commit();
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class SearchManagerStoreTest method testIndexUpdateData.
/**
* Test de mise à jour de l'index après une creation.
* La création s'effectue dans une seule transaction.
*/
@Test
public void testIndexUpdateData() {
testIndexAllQuery();
final Item item = createNewItem();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
storeManager.getDataStore().create(item);
transaction.commit();
}
waitIndexation();
Assert.assertEquals(initialDbItemSize + 1, query("*:*"));
Assert.assertEquals(1, query("DESCRIPTION:légende"));
item.setDescription("Vendue");
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
storeManager.getDataStore().update(item);
transaction.commit();
}
waitIndexation();
Assert.assertEquals(initialDbItemSize + 1, query("*:*"));
Assert.assertEquals(0, query("DESCRIPTION:légende"));
Assert.assertEquals(1, query("DESCRIPTION:vendue"));
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class AbstractStoreManagerTest method testTxCrudInsertCommitCrudDeleteCommit.
@Test
public void testTxCrudInsertCommitCrudDeleteCommit() {
final Car car = createNewCar();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
storeManager.getDataStore().create(car);
checkCrudCarsCount(1);
transaction.commit();
}
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
storeManager.getDataStore().delete(car.getURI());
checkCrudCarsCount(0);
transaction.commit();
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class AbstractStoreManagerTest method testTxCrudInsertCrudSelectRollback.
@Test
public void testTxCrudInsertCrudSelectRollback() {
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final Car car = createNewCar();
storeManager.getDataStore().create(car);
// on récupère la liste des voitures
checkCrudCarsCount(1);
}
}
Aggregations