Package com.force.sdk.jpa.entities

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


        cal.set(2010, 1, 1, Digit.AZERO.value, Digit.AZERO.value, Digit.AZERO.value);
        cal.set(Calendar.MILLISECOND, Digit.AZERO.value);
        //final Date d = cal.getTime();

        Object [][] groupableVals = new Object[][]{
                {new TestEntity(), "byteType",      (byte) 0,               new Byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}},
                {new TestEntity(), "byteObject",    Byte.valueOf((byte) 0)new Byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}},
//check in once W-854513 is fixed
//                {new TestEntity(), "boolType",      Boolean.TRUE,           new Boolean[]{true}},
//                {new TestEntity(), "booleanObject", Boolean.FALSE,          new Boolean[]{true}},
//                {new TestEntity(), "date",          getCal(false, Digit.AZERO, false).getTime(), new Date[]{d}},
//                {new TestEntity(), "dateTemporal",  getCal(false, Digit.AZERO, false).getTime(), new Date[]{d}},
                {new TestEntity(), "charType",          'A',                new Character[]{'A', 'E', 'F', 'N', 'O', 'S', 'T'}},
                {new TestEntity(), "characterObject",   'A',                new Character[]{'A', 'E', 'F', 'N', 'O', 'S', 'T'}},
        };
       
        Object [][] nonGroupableVals = new Object[][]{
                {new TestEntity(), "shortType",     (short) 0,                new Object[]{}},
                {new TestEntity(), "intType",       0,                        new Object[]{}},
                {new TestEntity(), "longType",      (long) 0,                 new Object[]{}},
                {new TestEntity(), "floatType",     (float) 0,                new Object[]{}},
                {new TestEntity(), "doubleType",    (double) 0,               new Object[]{}},
                {new TestEntity(), "shortObject",   Short.valueOf((short) 0), new Object[]{}},
                {new TestEntity(), "integerObject", Integer.valueOf(0),       new Object[]{}},
                {new TestEntity(), "longObject",    Long.valueOf(0),          new Object[]{}},
                {new TestEntity(), "floatObject",   new Float(0),             new Object[]{}},
                {new TestEntity(), "doubleObject"new Double(0),            new Object[]{}},
                {new TestEntity(), "bigDecimalObject", new BigDecimal(0),     new Object[]{}},
                {new TestEntity(), "bigIntegerObject", BigInteger.valueOf(0),   new Object[]{}},
                {new TestEntity(), "percent",        0,                         new Object[]{}},
                {new TestEntity(), "dateTimeCal",   getCal(false, Digit.AZERO, true),   new Object[]{}},
                {new TestEntity(), "dateTimeGCal",  getCal(true, Digit.AZERO, true),    new Object[]{}},
        };
       
        final String em = "foobar@salesforce.com";
        final String ph = "415-123-";
        final String ur = "http://localhost:";
        Object [][] stringVals = new Object[][]{
                {new TestEntity(), "stringObject",   Digit.AZERO.toString(),
                    new String[]{"AZERO", "EIGHT", "FIVE", "FOUR", "NINE", "ONE", "SEVEN", "SIX", "THREE", "TWO"}},
                {new TestEntity(), "phone", "415-123-0000",
                    new String[]{ph + "0000", ph + "1111", ph + "2222", ph + "3333", ph + "4444", ph + "5555",
                                    ph + "6666", ph + "7777", ph + "8888", ph + "9999"}},
                {new TestEntity(), "email", "0foobar@salesforce.com",
                    new String[]{"0" + em, "1" + em, "2" + em, "3" + em, "4" + em, "5" + em, "6" + em,
                                    "7" + em, "8" + em, "9" + em}},
                {new TestEntity(), "url",   new URL("http://localhost:0000"),
                    new URL[]{new URL(ur + "0000"), new URL(ur + "1111"), new URL(ur + "2222"), new URL(ur + "3333"),
                              new URL(ur + "4444"), new URL(ur + "5555"), new URL(ur + "6666"), new URL(ur + "7777"),
                              new URL(ur + "8888"), new URL(ur + "9999")}},
        };
       
View Full Code Here


    }
   
    @DataProvider
    public Object[][] deleteData() throws NumberFormatException, MalformedURLException {
        Object [][] entities = new Object[][]{
                {new TestEntity(), 10, 0},
                {new ParentTestEntity(), 2, 0},
        };
        return entities;
    }
View Full Code Here

    }
   
    @DataProvider
    public Object[][] deleteWhereData(Method test) throws NumberFormatException, MalformedURLException {
        Object [][] primitiveVals = new Object[][]{
                {new TestEntity(), "boolType",  Boolean.TRUE, 10, 0},
        };
        Object [][] primitiveNumberVals = new Object[][]{
                {new TestEntity(), "shortType"(short) 0, 10, 9},
                {new TestEntity(), "intType",    0, 10, 9},
                {new TestEntity(), "longType",   (long) 0, 10, 9},
                {new TestEntity(), "doubleType", (double) 0, 10, 9},
                {new TestEntity(), "floatType"(float) 0, 10, 9},
                {new TestEntity(), "charType",   'A', 10, 9},
        };
       
        Object[][] objectNumberVals = new Object[][]{
                {new TestEntity(), "shortObject",    Short.valueOf((short) 0), 10, 9},
                {new TestEntity(), "integerObject",  Integer.valueOf(0), 10, 9},
                {new TestEntity(), "longObject",     Long.valueOf(0), 10, 9},
                {new TestEntity(), "doubleObject",   new Double(0), 10, 9},
                {new TestEntity(), "floatObject",    new Float(0), 10, 9},
                {new TestEntity(), "characterObject", 'A', 10, 9},
                {new TestEntity(), "bigDecimalObject", new BigDecimal(0), 10, 9},
                {new TestEntity(), "bigIntegerObject", BigInteger.valueOf(0), 10, 9},
                {new TestEntity(), "percent",        0, 10, 9},
        };
       
        Object [][] stringVals = new Object[][]{
                {new TestEntity(), "stringObject",   Digit.AZERO.toString(), 10, 9},
                {new TestEntity(), "phone",          "415-123-0000", 10, 9},
                {new TestEntity(), "email",          "0foobar@salesforce.com", 10, 9},
                {new TestEntity(), "url",            new URL("http://localhost:0000"), 10, 9},
                {new TestEntity(), "characterObject", 'A', 10, 9},
        };
       
        Object [][] objectVals = new Object[][]{
//TODO: verify what the behavior for Master objects should be               
//                {new TestEntity(), "parent",              parent, 10, 0},
//                {new TestEntity(), "parentMasterDetail",  parentMD, 10, 0},
                {new TestEntity(), "booleanObject",  Boolean.FALSE, 10, 10},
                {new TestEntity(), "byteObject",     Byte.valueOf("0"), 10, 9},
                {new TestEntity(), "date",           getCal(false, Digit.AZERO, false).getTime(), 10, 0},
                {new TestEntity(), "dateTimeCal",    getCal(false, Digit.AZERO, true), 10, 9},
                {new TestEntity(), "dateTimeGCal",   getCal(true, Digit.AZERO, true), 10, 9},
                {new TestEntity(), "dateTemporal",   getCal(false, Digit.AZERO, false).getTime(), 10, 0},
        };
       
        if (test.getName().contains("AllTypes")) {
            return concat(objectVals, primitiveVals, primitiveNumberVals, objectNumberVals, stringVals);
        } else {
View Full Code Here

    public void testMaxStringLength() {
        testMaxStringLengthInternal(em);
    }
   
    public void testMaxStringLengthInternal(EntityManager testEm) {
        TestEntity entity = new TestEntity();
        JPATestUtils.initializeTestEntity(entity);
        entity.setStringObject(longString);
        EntityTransaction tx = testEm.getTransaction();
        try {
            tx.begin();
            testEm.persist(entity);
            tx.commit();
View Full Code Here

     * @hierarchy javasdk
     * @userStory xyz
     */
    public void testBasicPersist() {
        txMgr = (PlatformTransactionManager) applicationContext.getBean("transactionManager");
        entity = new TestEntity();
        JPATestUtils.initializeTestEntity(entity);
        ParentTestEntity parent = JPATestUtils.setMasterDetailRelationship(entity);
        Assert.assertFalse(entityManager.contains(entity) || entityManager.contains(parent), "Entity is not transient.");
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
View Full Code Here

     * This test retrieves an entity created by {@see testBasicPersist}. The test dependency is defined via TestNG.
     * @hierarchy javasdk
     * @userStory xyz
     */   
    public void testBasicRetrieve() throws Exception {
        TestEntity retrieved = entityManager.find(TestEntity.class, entity.getId());
        Assert.assertTrue(JPATestUtils.annotatedEntityEqual(entity, retrieved),
                "Retrieved entity is different from inserted entity.");
        Assert.assertTrue(entityManager.contains(retrieved), "Entity is not managed.");
    }
View Full Code Here

     */   
    public void testBasicUpdate() throws Exception {
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
        TransactionStatus txStatus = txMgr.getTransaction(def);
        TestEntity retrieved = entityManager.find(TestEntity.class, entity.getId());
        retrieved.setBigDecimalObject(BigDecimal.valueOf(100, 2));
        retrieved.setBoolType(false);
        retrieved.setIntType(10000);
        retrieved.setLongType(1000000);
        retrieved.setStringObject("update");
        entityManager.merge(retrieved);
        txMgr.commit(txStatus);
        entityManager.clear();
        TestEntity updated = entityManager.find(TestEntity.class, retrieved.getId());
        Assert.assertEquals(updated.getBigDecimalObject(), retrieved.getBigDecimalObject(), "Entity was not updated correctly.");
        Assert.assertEquals(updated.getBoolType(), retrieved.getBoolType(), "Entity was not updated correctly.");
        Assert.assertEquals(updated.getIntType(), retrieved.getIntType(), "Entity was not updated correctly.");
        Assert.assertEquals(updated.getLongType(), retrieved.getLongType(), "Entity was not updated correctly.");
        Assert.assertEquals(updated.getStringObject(), retrieved.getStringObject(), "Entity was not updated correctly.");
    }
View Full Code Here

     */
    public void testPersistenceContextRollback() {
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
        TransactionStatus txStatus = txMgr.getTransaction(def);
        TestEntity t = new TestEntity();
        ParentTestEntity p = JPATestUtils.setMasterDetailRelationship(t);
        Assert.assertFalse(entityManager.contains(t) || entityManager.contains(p), "Entities are not transient.");
        entityManager.persist(p);
        entityManager.persist(t);
        Assert.assertTrue(entityManager.contains(t) && entityManager.contains(p), "Entities are not managed.");
View Full Code Here

     */
    public void testCreateNullEntity() {
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
        TransactionStatus txStatus = txMgr.getTransaction(def);
        TestEntity testEntity = new TestEntity();
        JPATestUtils.initializeNullTestEntity(testEntity);
        ParentTestEntity parent = new ParentTestEntity();
        parent.init();
        testEntity.setParentMasterDetail(parent);
        entityManager.persist(parent);
        entityManager.persist(testEntity);
        txMgr.commit(txStatus);
        Assert.assertNotNull(testEntity.getId(), testEntity.getClass().getName() + " ID was not generated.");
        Assert.assertFalse(entityManager.contains(testEntity), "Entity is still managed but should be detached.");
        Assert.assertNotNull(entityManager.find(TestEntity.class, testEntity.getId()),
                "The entity was not stored to the database.");
    }
View Full Code Here

TOP

Related Classes of com.force.sdk.jpa.entities.TestEntity

Copyright © 2018 www.massapicom. 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.