use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testWhereIn2200.
/**
* Test where in avec 2200 Id a inclure.
*/
@Test
public void testWhereIn2200() {
superHeroDataBase.populateSuperHero(storeManager, 4500);
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO where ID in (#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
final DtList<SuperHero> ids = new DtList<>(SuperHero.class);
for (int i = 0; i < 2200; i++) {
ids.add(createSuperHero(10001L + 2 * i));
}
final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(2200, resultList.size());
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testWhereInTab.
/**
* Test exécution d'une tache.
*/
@Test
public void testWhereInTab() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO where\tID in\t(#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
final DtList<SuperHero> ids = DtList.of(createSuperHero(10001L + 1), createSuperHero(10001L + 3));
final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(2, resultList.size());
Assert.assertEquals(10001L + 1, resultList.get(0).getId().longValue());
Assert.assertEquals(10001L + 3, resultList.get(1).getId().longValue());
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class TaskEngineSelectDynamicTest method testScriptVar.
/**
* Test des scripts.
*/
@Test
public void testScriptVar() {
try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final TaskDefinition taskDefinition = registerTaskObject("TK_SCRIPT_TEST", "select * from SUPER_HERO <%if(dtoSuperHero.getId() == 10002L) {%>where ID = #DTO_SUPER_HERO.ID#<%}%>");
final SuperHero superHero = new SuperHero();
superHero.setId(10001L + 1);
final Task task = Task.builder(taskDefinition).addValue(DTO_SUPER_HERO, superHero).build();
final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
Assert.assertEquals(1, resultList.size());
Assert.assertEquals(10001L + 1, resultList.get(0).getId().longValue());
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class CachedStoreManagerTest method testAddFamille.
/**
* On charge une liste, ajoute un element et recharge la liste pour verifier l'ajout.
*/
@Override
@Test
public void testAddFamille() {
// ce test est modifier car le cache n'est pas transactionnel : la liste n'est pas accessible sans commit
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final DtListURI allFamilles = new DtListURIForCriteria<>(dtDefinitionFamille, null, null);
final DtList<Famille> dtc = storeManager.getDataStore().findAll(allFamilles);
Assert.assertEquals(0, dtc.size());
// -----
final Famille famille = new Famille();
famille.setLibelle("encore un");
final Famille createdFamille = storeManager.getDataStore().create(famille);
// on attend un objet avec un ID non null ?
Assert.assertNotNull(createdFamille.getFamId());
transaction.commit();
}
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final DtListURI allFamilles = new DtListURIForCriteria<>(dtDefinitionFamille, null, null);
final DtList<Famille> dtc = storeManager.getDataStore().findAll(allFamilles);
Assert.assertEquals(1, dtc.size());
}
}
use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.
the class JpaDataStorePlugin method checkJpaStore.
@HealthChecked(name = "testQuery", feature = "jpa")
public HealthMeasure checkJpaStore() {
final HealthMeasureBuilder healthMeasureBuilder = HealthMeasure.builder();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
getEntityManager().createNativeQuery("select 1", Integer.class).getFirstResult();
healthMeasureBuilder.withGreenStatus();
} catch (final Exception e) {
healthMeasureBuilder.withRedStatus(e.getMessage(), e).build();
}
return healthMeasureBuilder.build();
}
Aggregations