use of org.jboss.arquillian.transaction.api.annotation.Transactional in project pnc by project-ncl.
the class ProductVersionRepositoryTest method shouldGetProductVersion.
@Test
@Transactional
public void shouldGetProductVersion() {
// given
Product pruduct = Product.Builder.newBuilder().abbreviation("mp").name("MyProduct").build();
ProductVersion productVersion = ProductVersion.Builder.newBuilder().version("1.0").product(pruduct).build();
BuildConfigurationSet buildConfigurationSet = BuildConfigurationSet.Builder.newBuilder().name("set1").build();
Set<BuildConfigurationSet> buildConfigurationSets = new HashSet<>();
buildConfigurationSets.add(buildConfigurationSet);
BuildConfigurationSet buildConfigurationSetSaved = buildConfigurationSetRepository.save(buildConfigurationSet);
productVersion.setBuildConfigurationSets(buildConfigurationSets);
// when
productRepository.save(pruduct);
ProductVersion saved = productVersionRepository.save(productVersion);
// then
ProductVersion productVersionFromDb = productVersionRepository.queryById(productVersion.getId());
Assert.assertNotNull(productVersionFromDb);
Assert.assertEquals(productVersionFromDb.getVersion(), productVersion.getVersion());
assertThat(productVersionFromDb.getBuildConfigurationSets()).containsExactly(buildConfigurationSetSaved);
}
use of org.jboss.arquillian.transaction.api.annotation.Transactional in project tomee by apache.
the class JPATest method persist.
@Test
@Transactional(TransactionMode.ROLLBACK)
public void persist() {
assertNotNull(em);
// do something with the em
final Person p = new Person();
p.setName("Apache OpenEJB");
em.persist(p);
}
use of org.jboss.arquillian.transaction.api.annotation.Transactional in project tomee by apache.
the class PersistenceTest method testWithTransaction.
@Test
// default with persistence extension
@Transactional(TransactionMode.COMMIT)
@UsingDataSet("datasets/users.yml")
@ShouldMatchDataSet("datasets/expected-users.yml")
public void testWithTransaction() throws Exception {
assertEquals(2, em.createQuery("select count(e) from User e", Number.class).getSingleResult().intValue());
transactionalCaller.call(new Callable() {
public Object call() throws Exception {
seriouslyYouAlreadyForgotOpenEJB_questionMark();
return null;
}
});
}
Aggregations