Search in sources :

Example 6 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class SqlCriteriaTest method assertCriteria.

@Override
public void assertCriteria(final long expected, final Criteria<Movie2> criteria) {
    try (VTransactionWritable tx = transactionManager.createCurrentTransaction()) {
        final long count = storeManager.getDataStore().find(dtDefinitionMovie, criteria).size();
        Assert.assertEquals(expected, count);
    }
}
Also used : VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable)

Example 7 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class HibernateConnectionProviderTest method ping.

@Test
public void ping() throws SQLException {
    final SqlConnectionProvider sqlConnectionProvider = sqlDataBaseManager.getConnectionProvider(SqlDataBaseManager.MAIN_CONNECTION_PROVIDER_NAME);
    final String testQuery = sqlConnectionProvider.getDataBase().getSqlDialect().getTestQuery();
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final SqlConnection connection = sqlConnectionProvider.obtainConnection();
        try {
            sqlDataBaseManager.executeQuery(SqlStatement.builder(testQuery).build(), Integer.class, 1, connection);
        } finally {
            connection.release();
        }
    }
}
Also used : SqlConnectionProvider(io.vertigo.database.sql.connection.SqlConnectionProvider) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) SqlConnection(io.vertigo.database.sql.connection.SqlConnection) Test(org.junit.Test)

Example 8 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class AccountManagerTest method testLoginSuccess.

@Test
public void testLoginSuccess() {
    try (VTransactionWritable tx = obtainTx()) {
        final Optional<Account> accountAdmin = accountManager.getAccountByAuthToken("admin");
        final Optional<Account> accountBill = accountManager.getAccountByAuthToken("bill.clinton@yopmail.com");
        Assert.assertTrue("Authent fail", accountAdmin.isPresent() || accountBill.isPresent());
    }
}
Also used : VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 9 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class AbstractKVStoreManagerTest method testRemove.

@Test
public void testRemove() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final Optional<Flower> flower = kvStoreManager.find("flowers", "10", Flower.class);
        Assert.assertFalse("There is already a flower id 10", flower.isPresent());
        kvStoreManager.put("flowers", "10", buildFlower("daisy", 60));
        kvStoreManager.put("flowers", "11", buildFlower("tulip", 100));
        final Optional<Flower> flower1 = kvStoreManager.find("flowers", "10", Flower.class);
        final Optional<Flower> flower2 = kvStoreManager.find("flowers", "11", Flower.class);
        Assert.assertTrue("Flower id 10 not found", flower1.isPresent());
        Assert.assertTrue("Flower id 11 not found", flower2.isPresent());
        transaction.commit();
    }
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final Optional<Flower> flower = kvStoreManager.find("flowers", "10", Flower.class);
        Assert.assertTrue("Flower id 10 not found", flower.isPresent());
        kvStoreManager.remove("flowers", "10");
        final Optional<Flower> flower1 = kvStoreManager.find("flowers", "10", Flower.class);
        final Optional<Flower> flower2 = kvStoreManager.find("flowers", "11", Flower.class);
        Assert.assertFalse("Remove flower id 10 failed", flower1.isPresent());
        Assert.assertTrue("Flower id 11 not found", flower2.isPresent());
    }
}
Also used : Flower(io.vertigo.dynamo.kvstore.data.Flower) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 10 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class AbstractKVStoreManagerTest method testCount.

@Test
public void testCount() {
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final int nbFlowers = kvStoreManager.count("flowers");
        Assert.assertEquals(0, nbFlowers);
        final Flower tulip1 = buildFlower("tulip", 100);
        kvStoreManager.put("flowers", "1", tulip1);
        final Flower tulip2 = buildFlower("tulip", 110);
        kvStoreManager.put("flowers", "2", tulip2);
        final Flower tulip3 = buildFlower("tulip", 120);
        kvStoreManager.put("flowers", "3", tulip3);
        // count after 3 inserts
        final int nbFlowers2 = kvStoreManager.count("flowers");
        Assert.assertEquals(3, nbFlowers2);
        // count after 1 more insert of same value
        kvStoreManager.put("flowers", "4", tulip3);
        final int nbFlowers3 = kvStoreManager.count("flowers");
        Assert.assertEquals(4, nbFlowers3);
        // count after 1 insert of same key : update
        kvStoreManager.put("flowers", "3", tulip3);
        final int nbFlowers4 = kvStoreManager.count("flowers");
        Assert.assertEquals(4, nbFlowers4);
    }
}
Also used : Flower(io.vertigo.dynamo.kvstore.data.Flower) 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