Package com.google.appengine.datanucleus.test.jpa.HasRecursiveParentJPA

Examples of com.google.appengine.datanucleus.test.jpa.HasRecursiveParentJPA.HasRecursiveParent


*/
public class JPARecursiveParentTest extends JPATestCase {

  public void testCreateParentAndChildDifferentTxn() {

    HasRecursiveParent p = new HasRecursiveParent();
    p.setName("yam");
    beginTxn();
    em.persist(p);
    commitTxn();
    String pid = p.getId();

    beginTxn();
    HasRecursiveParent p2 = em.find(HasRecursiveParent.class, pid);
    HasRecursiveParent c = new HasRecursiveParent();
    c.setName("yum");
    c.setParent(p2);
    p2.getChildren().add(c);
    commitTxn();
    String cid = c.getId();

    beginTxn();
    HasRecursiveParent c2 = em.find(HasRecursiveParent.class, cid);
    HasRecursiveParent p3 = c2.getParent();
    assertEquals(1, p3.getChildren().size());
    assertEquals("yam", p3.getName());
    assertEquals(p3.getChildren().iterator().next(), c2);
    commitTxn();
  }
View Full Code Here


    commitTxn();
  }

  public void testCreateParentAndChildSameTxn() {

    HasRecursiveParent p = new HasRecursiveParent();
    p.setName("yam");
    HasRecursiveParent c = new HasRecursiveParent();
    c.setName("yum");
    c.setParent(p);
    p.getChildren().add(c);
    beginTxn();
    em.persist(p);
    commitTxn();
    String pid = p.getId();
    String cid = c.getId();

    beginTxn();
    HasRecursiveParent p2 = em.find(HasRecursiveParent.class, pid);
    assertEquals(1, p2.getChildren().size());
    HasRecursiveParent c2 = p2.getChildren().iterator().next();
    assertEquals(cid, c2.getId());
    assertEquals("yum", c2.getName());
    assertEquals(c2.getParent(), p2);
    commitTxn();
  }
View Full Code Here

    commitTxn();
  }

  public void testCreateParentHierarchie() {

    HasRecursiveParent p, p0 = p = new HasRecursiveParent();
    p.setName("yam4");
    for (int i = 3; i > 0; i--) {
      HasRecursiveParent c = new HasRecursiveParent();
      c.setName("yam" + i);
      c.setParent(p);
      p.getChildren().add(c);
      p = c;
    }

    beginTxn();
    em.persist(p0);
    commitTxn();
    String cid = p.getId();

    beginTxn();
    HasRecursiveParent c = em.find(HasRecursiveParent.class, cid);
    int i = 1;
    while (c.getParent() != null) {
      assertEquals("yam" + (i++), c.getName());
      c = c.getParent();
    }

    commitTxn();
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.HasRecursiveParentJPA.HasRecursiveParent

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.