Search in sources :

Example 1 with VTransactionWritable

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);
    }
}
Also used : VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 2 with VTransactionWritable

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"));
}
Also used : Car(io.vertigo.dynamo.search_2_4.data.domain.Car) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 3 with VTransactionWritable

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"));
}
Also used : Car(io.vertigo.dynamo.search_2_4.data.domain.Car) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 4 with VTransactionWritable

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();
    }
}
Also used : VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) SqlConnection(io.vertigo.database.sql.connection.SqlConnection)

Example 5 with VTransactionWritable

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();
}
Also used : CarDataBase(io.vertigo.dynamo.search_2_4.data.domain.CarDataBase) Car(io.vertigo.dynamo.search_2_4.data.domain.Car) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) SqlConnection(io.vertigo.database.sql.connection.SqlConnection)

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