Examples of SuperParentWithSuperChild


Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalOneToManySubclassesJDO.SuperParentWithSuperChild

    assertEquals(0, countForClass(superChild.getClass()));
  }

  public void testSuperParentWithSuperChild() throws EntityNotFoundException {
    // insertion
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("super parent string");

    SuperChild superChild = new SuperChild();
    superChild.setAString("a string");
    parent.getSuperParentSuperChildren().add(superChild);

    beginTxn();
    pm.makePersistent(parent);
    commitTxn();
    Entity parentEntity =
        ds.get(KeyFactory.createKey(kindForClass(parent.getClass()), parent.getId()));
    Entity superParentSuperChildEntity = ds.get(superChild.getId());
    assertEquals(2, parentEntity.getProperties().size());
    assertEquals("super parent string", parentEntity.getProperty("superParentString"));
    assertEquals(Collections.singletonList(superParentSuperChildEntity.getKey()),
                 parentEntity.getProperty("superChildren"));
    assertEquals(1, superParentSuperChildEntity.getProperties().size());
    assertEquals("a string", superParentSuperChildEntity.getProperty("aString"));

    // lookup
    beginTxn();
    parent = pm.getObjectById(parent.getClass(), parent.getId());
    assertEquals("super parent string", parent.getSuperParentString());
    assertEquals(1, parent.getSuperParentSuperChildren().size());
    assertEquals(superChild.getId(), parent.getSuperParentSuperChildren().get(0).getId());
    commitTxn();

    beginTxn();
    superChild = pm.getObjectById(superChild.getClass(), superChild.getId());
    assertEquals("a string", superChild.getAString());
    commitTxn();

    // cascade delete
    beginTxn();
    pm.deletePersistent(parent);
    commitTxn();

    assertEquals(0, countForClass(parent.getClass()));
    assertEquals(0, countForClass(superChild.getClass()));
  }
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalOneToManySubclassesJDO.SuperParentWithSuperChild

    assertEquals(0, countForClass(parent.getClass()));
    assertEquals(0, countForClass(subChild.getClass()));
  }

  public void testWrongChildType() {
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("a string");
    SubChild child = new SubChild();
    parent.getSuperParentSuperChildren().add(child);

    beginTxn();
    try {
      pm.makePersistent(parent);
      fail("expected exception");
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalOneToManySubclassesJDO.SuperParentWithSuperChild

  public void testWrongChildType_Update() throws InstantiationException, IllegalAccessException {
    // need a non-txn datasource so we can access multiple entity groups
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    SubChild child = SubChild.class.newInstance();
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("a string");
    beginTxn();
    pm.makePersistent(parent);
    commitTxn();
    parent = pm.getObjectById(parent.getClass(), parent.getId());

    try {
      parent.getSuperParentSuperChildren().add(child);
      pm.close();
      fail("expected exception");
    } catch (UnsupportedOperationException uoe) {
      // good
    }
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalOneToOneSubclassesJDO.SuperParentWithSuperChild

    assertEquals(0, countForClass(superChild.getClass()));
  }

  public void testSuperParentWithSuperChild() throws EntityNotFoundException {
    // insertion
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("super parent string");

    SuperChild superChild = new SuperChild();
    superChild.setAString("a string");
    parent.setSuperParentSuperChild(superChild);

    beginTxn();
    pm.makePersistent(parent);
    commitTxn();
    Entity parentEntity =
        ds.get(KeyFactory.createKey(kindForClass(parent.getClass()), parent.getId()));
    Entity superParentSuperChildEntity = ds.get(superChild.getId());
    assertEquals(2, parentEntity.getProperties().size());
    assertEquals("super parent string", parentEntity.getProperty("superParentString"));
    assertEquals(superParentSuperChildEntity.getKey(), parentEntity.getProperty("superChild_id_OID"));
    assertEquals(1, superParentSuperChildEntity.getProperties().size());
    assertEquals("a string", superParentSuperChildEntity.getProperty("aString"));

    // lookup
    beginTxn();
    parent = pm.getObjectById(parent.getClass(), parent.getId());
    assertEquals("super parent string", parent.getSuperParentString());
    assertEquals(superChild.getId(), parent.getSuperParentSuperChild().getId());
    commitTxn();

    beginTxn();
    superChild = pm.getObjectById(superChild.getClass(), superChild.getId());
    assertEquals("a string", superChild.getAString());
    commitTxn();

    // cascade delete
    beginTxn();
    pm.deletePersistent(parent);
    commitTxn();

    assertEquals(0, countForClass(parent.getClass()));
    assertEquals(0, countForClass(superChild.getClass()));
  }
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalOneToOneSubclassesJDO.SuperParentWithSuperChild

    assertEquals(0, countForClass(parent.getClass()));
    assertEquals(0, countForClass(subChild.getClass()));
  }

  public void testWrongChildType() throws IllegalAccessException, InstantiationException {
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("a string");
    // working around more runtime enhancer madness
    Object child = SubChild.class.newInstance();
    parent.setSuperParentSuperChild((SuperChild) child);

    beginTxn();
    try {
      pm.makePersistent(parent);
      fail("expected exception");
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalOneToOneSubclassesJDO.SuperParentWithSuperChild

    }
    rollbackTxn();
  }

  public void testWrongChildType_Update() throws IllegalAccessException, InstantiationException {
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("a string");
    beginTxn();
    pm.makePersistent(parent);
    commitTxn();

    beginTxn();
    parent = pm.getObjectById(parent.getClass(), parent.getId());
    // working around more runtime enhancer madness
    Object child = SubChild.class.newInstance();
    parent.setSuperParentSuperChild((SuperChild) child);

    try {
      commitTxn();
      fail("expected exception");
    } catch (UnsupportedOperationException uoe) {
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.UnidirectionalOneToManySubclassesJPA.SuperParentWithSuperChild

    assertEquals(0, countForClass(superChild.getClass()));
  }

  public void testSuperParentWithSuperChild() throws EntityNotFoundException {
    // insertion
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("super parent string");

    SuperChild superChild = new SuperChild();
    superChild.setAString("a string");
    parent.getSuperParentSuperChildren().add(superChild);

    beginTxn();
    em.persist(parent);
    commitTxn();
    Entity parentEntity =
        ds.get(KeyFactory.createKey(kindForClass(parent.getClass()), parent.getId()));
    Entity superParentSuperChildEntity = ds.get(superChild.getId());
    assertEquals(2, parentEntity.getProperties().size());
    assertEquals("super parent string", parentEntity.getProperty("superParentString"));
    assertEquals(Collections.singletonList(superParentSuperChildEntity.getKey()), parentEntity.getProperty("superChildren"));
    assertEquals(1, superParentSuperChildEntity.getProperties().size());
    assertEquals("a string", superParentSuperChildEntity.getProperty("aString"));

    // lookup
    beginTxn();
    parent = em.find(parent.getClass(), parent.getId());
    assertEquals("super parent string", parent.getSuperParentString());
    assertEquals(1, parent.getSuperParentSuperChildren().size());
    assertEquals(superChild.getId(), parent.getSuperParentSuperChildren().get(0).getId());
    commitTxn();

    beginTxn();
    superChild = em.find(superChild.getClass(), superChild.getId());
    assertEquals("a string", superChild.getAString());
    commitTxn();

    // cascade delete
    beginTxn();
    em.remove(em.merge(parent));
    commitTxn();

    assertEquals(0, countForClass(parent.getClass()));
    assertEquals(0, countForClass(superChild.getClass()));
  }
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.UnidirectionalOneToManySubclassesJPA.SuperParentWithSuperChild

    assertEquals(0, countForClass(parent.getClass()));
    assertEquals(0, countForClass(subChild.getClass()));
  }

  public void testWrongChildType() {
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("a string");
    SubChild child = new SubChild();
    parent.getSuperParentSuperChildren().add(child);

    beginTxn();
    em.persist(parent);
    try {
      commitTxn();
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.UnidirectionalOneToManySubclassesJPA.SuperParentWithSuperChild

      // good
    }
  }

  public void testWrongChildType_Update() {
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("a string");
    beginTxn();
    em.persist(parent);
    commitTxn();

    beginTxn();
    parent = em.find(parent.getClass(), parent.getId());
    SubChild child = new SubChild();
    parent.getSuperParentSuperChildren().add(child);

    try {
      commitTxn();
      fail("expected exception");
    } catch (UnsupportedOperationException uoe) {
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.UnidirectionalOneToOneSubclassesJPA.SuperParentWithSuperChild

    assertEquals(0, countForClass(superChild.getClass()));
  }

  public void testSuperParentWithSuperChild() throws EntityNotFoundException {
    // insertion
    SuperParentWithSuperChild parent = new SuperParentWithSuperChild();
    parent.setSuperParentString("super parent string");

    SuperChild superChild = new SuperChild();
    superChild.setAString("a string");
    parent.setSuperParentSuperChild(superChild);

    beginTxn();
    em.persist(parent);
    commitTxn();
    Entity parentEntity =
        ds.get(KeyFactory.createKey(kindForClass(parent.getClass()), parent.getId()));
    Entity superParentSuperChildEntity = ds.get(superChild.getId());
    assertEquals(2, parentEntity.getProperties().size());
    assertEquals("super parent string", parentEntity.getProperty("superParentString"));
    assertEquals(superParentSuperChildEntity.getKey(), parentEntity.getProperty("superChild_id"));
    assertEquals(1, superParentSuperChildEntity.getProperties().size());
    assertEquals("a string", superParentSuperChildEntity.getProperty("aString"));

    // lookup
    beginTxn();
    parent = em.find(parent.getClass(), parent.getId());
    assertEquals("super parent string", parent.getSuperParentString());
    assertEquals(superChild.getId(), parent.getSuperParentSuperChild().getId());
    commitTxn();

    beginTxn();
    superChild = em.find(superChild.getClass(), superChild.getId());
    assertEquals("a string", superChild.getAString());
    commitTxn();

    // cascade delete
    beginTxn();
    em.remove(em.merge(parent));
    commitTxn();

    assertEquals(0, countForClass(parent.getClass()));
    assertEquals(0, countForClass(superChild.getClass()));
  }
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.