Search in sources :

Example 1 with Transactional

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);
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) Product(org.jboss.pnc.model.Product) ProductVersion(org.jboss.pnc.model.ProductVersion) HashSet(java.util.HashSet) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Transactional(org.jboss.arquillian.transaction.api.annotation.Transactional)

Example 2 with Transactional

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);
}
Also used : Person(org.superbiz.model.Person) Test(org.junit.Test) Transactional(org.jboss.arquillian.transaction.api.annotation.Transactional)

Example 3 with Transactional

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;
        }
    });
}
Also used : Callable(java.util.concurrent.Callable) UsingDataSet(org.jboss.arquillian.persistence.UsingDataSet) Test(org.junit.Test) ShouldMatchDataSet(org.jboss.arquillian.persistence.ShouldMatchDataSet) Transactional(org.jboss.arquillian.transaction.api.annotation.Transactional)

Aggregations

Transactional (org.jboss.arquillian.transaction.api.annotation.Transactional)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)1 Callable (java.util.concurrent.Callable)1 ShouldMatchDataSet (org.jboss.arquillian.persistence.ShouldMatchDataSet)1 UsingDataSet (org.jboss.arquillian.persistence.UsingDataSet)1 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)1 Product (org.jboss.pnc.model.Product)1 ProductVersion (org.jboss.pnc.model.ProductVersion)1 ContainerTest (org.jboss.pnc.test.category.ContainerTest)1 Person (org.superbiz.model.Person)1