Examples of TestEntity


Examples of au.com.motodetail.poi.entity.TestEntity

        }
    }

    public void DebugAddTestEntity()
    {
        TestEntity testEntity = new TestEntity();

        //set local attributes
        testEntity.setMsg(BaseUtil.GenerateRandomString(10));

        //type relationship .. get it from DB
        try
        {
            List<BasicEntityType> basicEntityType = basicEntityTypeService.getAll();
            for(BasicEntityType bet:basicEntityType)
            {
                if(bet.getType() == EntityType.TEST)
                {
                    testEntity.setEntityType(bet);
                    testEntityService.create(testEntity);
                    break;
                }
            }
        }
View Full Code Here

Examples of com.alibaba.json.test.entity.TestEntity

public class DefaultExtJSONParserTest_1 extends TestCase {

    public void test_0() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"f1\":true}");
        TestEntity entity = parser.parseObject(TestEntity.class);
        Assert.assertEquals(true, entity.isF1());
    }
View Full Code Here

Examples of com.alibaba.json.test.entity.TestEntity

        Assert.assertEquals(true, entity.isF1());
    }

    public void test_1() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"f2\":true}");
        TestEntity entity = parser.parseObject(TestEntity.class);
        Assert.assertEquals(Boolean.TRUE, entity.getF2());
    }
View Full Code Here

Examples of com.alibaba.json.test.entity.TestEntity

        TestEntity entity = parser.parseObject(TestEntity.class);
        Assert.assertEquals(Boolean.TRUE, entity.getF2());
    }

    public void f_test_2() throws Exception {
        TestEntity a = new TestEntity();
        a.setF1(true);
        a.setF2(Boolean.TRUE);
        a.setF3((byte) 123);
        a.setF4((byte) 123);
        a.setF5((short) 123);
        a.setF6((short) 123);
        a.setF7((int) 123);
        a.setF8((int) 123);
        a.setF9((long) 123);
        a.setF10((long) 123);
        a.setF11(new BigInteger("123"));
        a.setF12(new BigDecimal("123"));
        a.setF13("abc");
        a.setF14(null);
        a.setF15(12.34F);
        a.setF16(12.35F);
        a.setF17(12.345D);
        a.setF18(12.345D);

        String text = JSON.toJSONString(a);
        System.out.println(text);

        TestEntity b = new TestEntity();
        {
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            parser.parseObject(b);
        }

        Assert.assertEquals("f1", a.isF1(), b.isF1());
        Assert.assertEquals("f2", a.getF2(), b.getF2());
        Assert.assertEquals("f3", a.getF3(), b.getF3());
        Assert.assertEquals("f4", a.getF4(), b.getF4());
        Assert.assertEquals("f5", a.getF5(), b.getF5());
        Assert.assertEquals("f6", a.getF6(), b.getF6());
        Assert.assertEquals("f7", a.getF7(), b.getF7());
        Assert.assertEquals("f8", a.getF8(), b.getF8());
        Assert.assertEquals("f9", a.getF9(), b.getF9());
        Assert.assertEquals(a.getF10(), b.getF10());
        Assert.assertEquals(a.getF11(), b.getF11());
        Assert.assertEquals(a.getF12(), b.getF12());
        Assert.assertEquals(a.getF13(), b.getF13());
        Assert.assertEquals(a.getF14(), b.getF14());
        Assert.assertEquals(a.getF15(), b.getF15());
        Assert.assertEquals(a.getF16(), b.getF16());
        Assert.assertEquals(a.getF17(), b.getF17());
        Assert.assertEquals(a.getF18(), b.getF18());

    }
View Full Code Here

Examples of com.cloudera.cdk.data.hbase.avro.entities.TestEntity

    DatasetWriter<TestEntity> writer = ds.newWriter();
    writer.open();
    try {
      for (int i = 2; i < 10; ++i) {
        TestEntity entity = createSpecificEntity(i);
        writer.write(entity);
      }
    } finally {
      writer.close();
    }

    // ensure the new entities are what we expect with get operations
    for (int i = 0; i < 10; ++i) {
      String iStr = Long.toString(i);
      Key key = new Key.Builder(ds)
          .add("part1", "part1_" + iStr)
          .add("part2", "part2_" + iStr).build();
      compareEntitiesWithString(i, ds.get(key));
    }

    // ensure the new entities are what we expect with scan operations
    int cnt = 0;
    DatasetReader<TestEntity> reader = ds.newReader();
    reader.open();
    try {
      for (TestEntity entity : reader) {
        compareEntitiesWithString(cnt, entity);
        cnt++;
      }
      assertEquals(10, cnt);
    } finally {
      reader.close();
    }

    Key key = new Key.Builder(ds)
        .add("part1", "part1_5")
        .add("part2", "part2_5").build();

    // test delete
    ds.delete(key);
    TestEntity deletedRecord = ds.get(key);
    assertNull(deletedRecord);
  }
View Full Code Here

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

     * can call persist/remove/merge/refresh without a transaction.
     * @hierarchy javasdk
     * @userStory xyz
     */           
    public void testExtendedBehavior() {
        TestEntity t = new TestEntity();
        JPATestUtils.initializeTestEntity(t);
        //new/transient
        ParentTestEntity p = JPATestUtils.setMasterDetailRelationship(t);
        t.setParent(p);
        Assert.assertFalse(emExt.contains(t), "Entity is not transient.");
        emExt.persist(p);
        emExt.persist(t);
//        Assert.assertNull(t.getId(), "Entity was already committed.");//fails
        EntityTransaction tx = emExt.getTransaction();
        tx.begin();
        //managed       
        tx.commit();
        Assert.assertTrue((emExt.contains(t) && emExt.contains(p)), "Entities are not managed.");
        Assert.assertNotNull(t.getId(), "ID was not generated.");
        Assert.assertNotNull(emExt.find(TestEntity.class, t.getId()), "The entity was not stored to the database.");
        String firstTE = t.getId();
        //now remove first TE and replace it with another TE
        emExt.remove(t);
        //another EM should still see the entity
//        Assert.assertNotNull(em.find(TestEntity.class, firstTE), "The entity is already deleted.");//fails
        TestEntity second = new TestEntity();
        JPATestUtils.initializeTestEntity(second);
        second.setParentMasterDetail(p);
        second.setParent(p);
        emExt.persist(second);
        Assert.assertTrue(emExt.contains(second), "Second entity is managed.");
//        Assert.assertNull(second.getId(), "Second was already committed.");//fails
        tx = emExt.getTransaction();
        tx.begin();
        Assert.assertTrue((emExt.contains(second) && emExt.contains(p)), "Entities are not managed.");
//        Assert.assertFalse(emExt.contains(t), "Removed entity is still managed.");//fails
        tx.commit();
        Assert.assertFalse(firstTE.equals(second.getId()), "The first entity was not replaced by a new.");
        //now make changes on TE, then refresh (reverts changes) and merge outside of a tx
        String origName = second.getName();
        second.setName("testExtendedBehavior");
        emExt.refresh(second);
        Assert.assertEquals(second.getName(), origName, "Refresh did not reset the name.");
        second.setName("newname");
//        emExt.merge(second);//should make the new name persistent upon next commit //FAILS due to tx required - this is very odd
        Assert.assertEquals(em.find(TestEntity.class, second.getId()).getName(), origName,
                "Merge instantly committed the changes."); //should still see the old name
        tx = emExt.getTransaction();
        tx.begin();
        tx.rollback();
        Assert.assertEquals(emExt.find(TestEntity.class, second.getId()).getName(), origName, "Name update was not rolled back.");
    }
View Full Code Here

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

     * Tests the correct lifecycle behavior of transactions in an application managed extended persistence context.
     * @hierarchy javasdk
     * @userStory xyz
     */           
    public void testTxBehavior() {
        TestEntity t = new TestEntity();
        JPATestUtils.initializeTestEntity(t);
        //new/transient
        ParentTestEntity p = JPATestUtils.setMasterDetailRelationship(t);
        t.setParent(p);
        Assert.assertFalse(em.contains(t), "Entity is not transient.");
        EntityTransaction tx = em.getTransaction();
        if (tx.isActive())tx.commit();
        try {
            em.persist(p);
            //TODO
//            Assert.fail("Persist should require a transaction.");//fails
        } catch (IllegalStateException ise) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ise.printStackTrace(pw);
            Assert.assertTrue(ise.getMessage()
                    .contains("Transaction is not active. You need to define a transaction around this"),
                    "Caught wrong exception:\n" + sw.toString());
        }
        tx = em.getTransaction();
        tx.begin();
//        em.persist(p);//fails since persist above is successful
        em.persist(t);
        tx.commit();
        t.setName("refresh");
        try {
            em.refresh(t);
            Assert.fail("Refresh should require a transaction.");
        } catch (Exception e) {
            //TODO: this currently throws java.lang.IllegalArgumentException:
            // Entity "com.force.sdk.jpa.entities.TestEntity@4631f1f8" isnt managed and so you cant use this method
            // We need to change that
//            Assert.assertTrue(e.getMessage()
//                    .contains("Transaction is not active. You need to define a transaction around this"),
//                    "Caught wrong exception:\n" + e.getStackTrace());           
        }
        t.setName("testTxBehavior");
        try {
            em.merge(t);
            //TODO
//            Assert.fail("Merge should require a transaction.");//fails
        } catch (Exception e) {
View Full Code Here

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

     * @hierarchy javasdk
     * @userStory xyz
     */           
    public void testFetchtypeEager(EntityManager e, boolean isExtended) {
        String eId = prepareTest(e, isExtended);
        TestEntity entity = e.find(TestEntity.class, eId);
        String errMsg = "Tx scoped: ";
        if (isExtended) {
            errMsg = "Extended: ";
        }
        Assert.assertTrue(e.contains(entity), errMsg + " Entity is not managed.");
        Assert.assertTrue(e.contains(entity.getParent()), errMsg + " Parent is not managed.");
        ParentTestEntity parent = entity.getParent();
        String pid = parent.getId();
        EntityTransaction tx = e.getTransaction();
        tx.begin();
        tx.commit();
        if (isExtended) {
View Full Code Here

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

        String eId = prepareTest(e, isExtended);
        String errMsg = "Tx scoped: ";
        if (isExtended) {
            errMsg = "Extended: ";
        }
        TestEntity entity = e.find(TestEntity.class, eId);
        //managed
        Assert.assertTrue(e.contains(entity), errMsg + " Entity is not managed.");
        EntityTransaction tx = e.getTransaction();
        tx.begin();
        tx.commit();
View Full Code Here

Examples of com.oltpbenchmark.benchmarks.jpab.objects.TestEntity

    try {
      em.getTransaction().begin();
      int graphSize = getGraphSize(); // > 1 only in NodeTest
      int operCount = batchSize / graphSize;
      for (int i = 0; i < operCount && !entityInventory.isEmpty(); i++) {
          TestEntity t=entityInventory.pop();
          //System.out.println(t.toString());
        em.persist(t);
        increaseActionCount(graphSize);
      }
      em.getTransaction().commit();
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.