Examples of AccountEntity


Examples of com.force.sdk.jpa.entities.AccountEntity

        OpportunityEntity opp2 = new OpportunityEntity();
        opp2.setStageName("Prospecting");
        opp2.setCloseDate(Calendar.getInstance().getTime());
        opp2.setName("opp2 subquery");

        AccountEntity parentAccount = new AccountEntity();
        parentAccount.setName(accName);
        opp1.setTheAccount(parentAccount);
        opp2.setTheAccount(parentAccount);

        addTestDataInTx(Lists.newArrayList(parentAccount, opp1, opp2));
View Full Code Here

Examples of com.force.sdk.jpa.entities.AccountEntity

*/
public class BasicTransactionTest extends BaseJPAFTest {

    @Test
    public void testPersistDetachedEntityFromRollback() {
        AccountEntity entity = new AccountEntity();
        entity.setName("BasicTransactionTest.testPersistDetachedEntityFromRollback");

        EntityTransaction transaction = em.getTransaction();
        transaction.begin();
        em.persist(entity);
        transaction.rollback();

        Assert.assertNull(entity.getId(), "expected a null id for rolled back entity, but got: " + entity.getId());
        Assert.assertFalse(em.contains(entity),
                "Transaction was rolled back, yet the entity manager still contains the persisted entity.");

        transaction = em.getTransaction();
        transaction.begin();
        em.persist(entity);
        transaction.commit();

        Assert.assertNotNull(entity.getId(), "expected an id after entity was committed, but the id was null");
        Assert.assertNotNull(em.find(AccountEntity.class, entity.getId()).getName(),
                "expected a result from retrieving the committed entity from the db, but received a null result");
    }
View Full Code Here

Examples of com.force.sdk.jpa.entities.AccountEntity

*/
public class NegativeDetachPersistTest extends BaseJPAFTest {

    @Test
    public void testPersistDetachedEntityByRemoval() {
        AccountEntity account = createTestAccount(true);

        EntityTransaction transaction = null;
       
        try {
            transaction = em.getTransaction();
            transaction.begin();

            em.remove(account);

            Assert.fail("Entity " + account.toString() + " should be detached and should not be allowed to be persisted.");
        } catch (IllegalArgumentException iae) {
            Assert.assertTrue(iae.getMessage().contains("detached yet this operation requires it to be attached"),
                    "unexpected error message: " + iae.getMessage());
        } finally {
           if (transaction != null) transaction.rollback();
View Full Code Here

Examples of com.force.sdk.jpa.entities.AccountEntity

        }
    }

    @Test
    public void testPersistDetachedEntityByEntityManagerClear() {
        AccountEntity account = createTestAccount(false);

        EntityTransaction transaction = null;
       
        try {
            transaction = em.getTransaction();
            transaction.begin();
            em.persist(account);

            Assert.assertTrue(em.contains(account), "The AccountEntity was just persisted, but is not managed.");
            em.clear();
            Assert.assertFalse(em.contains(account),
                    "The entity manager was cleared, but it still contains " + account.toString());

            em.persist(account);
            Assert.fail("Entity " + account.toString() + " should be detached and should not be allowed to be persisted.");
        } catch (EntityExistsException e) {
            Assert.assertEquals(e.getMessage(),
                    "Entity already exists. Use merge to save changes.", "unexpected error message: " + e.getMessage());
        } finally {
            if (transaction != null) transaction.rollback();
View Full Code Here

Examples of com.force.sdk.jpa.entities.AccountEntity

        }
    }

    @Test
    public void testMergeDetachedEntityByEntityManagerClear() {
        AccountEntity account = createTestAccount(false);
        EntityTransaction transaction = null;
        try {
            transaction = em.getTransaction();
            transaction.begin();
            em.persist(account);

            Assert.assertTrue(em.contains(account), "The AccountEntity was just persisted, but is not managed.");
            em.clear();
            Assert.assertFalse(em.contains(account),
                    "The entity manager was cleared, but it still contains " + account.toString());

            em.merge(account);

            Assert.fail("Entity " + account.toString() + " should be detached and should not be allowed to be persisted.");
        } catch (IllegalArgumentException e) {
            Assert.assertEquals(e.getMessage(), "Detached entity with null id cannot be merged.",
                    "unexpected error message: " + e.getMessage());
        } finally {
            if (transaction != null) transaction.rollback();
View Full Code Here

Examples of com.force.sdk.jpa.entities.AccountEntity

        }
    }

    @Test
    public void testCloseEntityManagerThenPersist() {
        AccountEntity account = createTestAccount(false);
        EntityManager em = emfac.createEntityManager();
        // recreating the em is expensive
        // TODO: mock the em so we don't actually close and recreate
        try {
            em.close();
View Full Code Here

Examples of com.force.sdk.jpa.entities.AccountEntity

        }
    }

    @Test
    public void testPersistFlushAndRollback() {
        AccountEntity account = createTestAccount(false);

        EntityTransaction transaction = em.getTransaction();
        transaction.begin();
        em.persist(account);
        em.flush();
        transaction.rollback();
        Assert.assertNull(account.getId(), "Entity should not have been saved.");
    }
View Full Code Here

Examples of com.force.sdk.jpa.entities.AccountEntity

        transaction.rollback();
        Assert.assertNull(account.getId(), "Entity should not have been saved.");
    }
   
    private AccountEntity createTestAccount(boolean create) {
        AccountEntity account = new AccountEntity();
        account.setName("Test" + String.valueOf(new Random().nextInt(10000)));

        if (create) {
            EntityTransaction transaction = em.getTransaction();
            transaction.begin();
            em.persist(account);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.