Search in sources :

Example 66 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();
    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();
}
Also used : Item(io.vertigo.dynamo.search.data.domain.Item) ItemDataBase(io.vertigo.dynamo.search.data.domain.ItemDataBase) 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)

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

Example 69 with VTransactionWritable

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

Example 70 with VTransactionWritable

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

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