use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class TaskProxyTest method testCount.
/**
* Test where in avec 2200 Id a exclure.
*/
@Test
public void testCount() {
superHeroDataBase.populateSuperHero(storeManager, 100);
// ---
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final int count = superHeroDao.count();
Assert.assertEquals(100 + 33, count);
}
}
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 Car car = createNewCar();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
storeManager.getDataStore().create(car);
transaction.commit();
}
waitIndexation();
Assert.assertEquals(initialDbCarSize + 1, query("*:*"));
Assert.assertEquals(1, query("DESCRIPTION:légende"));
car.setDescription("Vendue");
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
storeManager.getDataStore().update(car);
transaction.commit();
}
waitIndexation();
Assert.assertEquals(initialDbCarSize + 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 SearchManagerStoreTest method testIndexNewData.
/**
* Test de mise à jour de l'index après une creation.
* La création s'effectue dans une seule transaction.
*/
@Test
public void testIndexNewData() {
testIndexAllQuery();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final Car car = createNewCar();
storeManager.getDataStore().create(car);
transaction.commit();
}
waitIndexation();
Assert.assertEquals(initialDbCarSize + 1, query("*:*"));
Assert.assertEquals(1, query("DESCRIPTION:légende"));
}
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 doSetUp.
@Override
protected void doSetUp() throws Exception {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
carIndexDefinition = definitionSpace.resolve(IDX_CAR, 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 car(ID BIGINT, MAKE 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) );");
execCallableStatement(connection, "create sequence SEQ_CAR start with 10001 increment by 1");
}
// On supprime tout
remove("*:*");
final CarDataBase carDataBase = new CarDataBase();
carDataBase.loadDatas();
initialDbCarSize = carDataBase.size();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
for (final Car car : carDataBase.getAllCars()) {
car.setId(null);
storeManager.getDataStore().create(car);
}
transaction.commit();
}
waitIndexation();
}
Aggregations