Package com.google.appengine.datanucleus.test.jdo

Examples of com.google.appengine.datanucleus.test.jdo.HasKeyAncestorStringPkJDO


  public void testUpdateKeyAncestor_SetNewKey() {
    Key parentKey = ds.put(new Entity(Flight.class.getSimpleName()));
    Key key = ds.put(new Entity(HasKeyAncestorStringPkJDO.class.getSimpleName(), parentKey));

    beginTxn();
    HasKeyAncestorStringPkJDO pojo = pm.getObjectById(
        HasKeyAncestorStringPkJDO.class, KeyFactory.keyToString(key));
    pojo.setAncestorKey(KeyFactory.createKey(key.getKind(), 33));

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


  public void testUpdateKeyAncestor_NullKey() {
    Key parentKey = ds.put(new Entity(Flight.class.getSimpleName()));
    Key key = ds.put(new Entity(HasKeyAncestorStringPkJDO.class.getSimpleName(), parentKey));

    beginTxn();
    HasKeyAncestorStringPkJDO pojo = pm.getObjectById(
        HasKeyAncestorStringPkJDO.class, KeyFactory.keyToString(key));
    pojo.setAncestorKey(null);
    try {
      commitTxn();
      fail("expected exception");
    } catch (JDOFatalUserException e) {
      // good
View Full Code Here

    assertKeyParentEquals(parent.getId(), childEntity, childEntity.getKey());
  }

  public void testOneToOnePersistChildWithKeyAncestorCascadeAll() throws EntityNotFoundException {
    HasOneToOnesWithDifferentCascadesJDO parent = new HasOneToOnesWithDifferentCascadesJDO();
    HasKeyAncestorStringPkJDO child = new HasKeyAncestorStringPkJDO();
    parent.setCascadeAllChildWithKeyAncestor(child);

    beginTxn();
    pm.makePersistent(parent);
    commitTxn();

    beginTxn();
    parent = pm.getObjectById(HasOneToOnesWithDifferentCascadesJDO.class, parent.getId());
    child = pm.getObjectById(HasKeyAncestorStringPkJDO.class, child.getKey());
    assertEquals(parent.getId(), KeyFactory.keyToString(child.getAncestorKey()));
    assertNotNull(parent.getCascadeAllChildWithKeyAncestor());
    commitTxn();

    Entity childEntity = ds.get(KeyFactory.stringToKey(child.getKey()));
    assertKeyParentEquals(parent.getId(), childEntity, childEntity.getKey());
  }
View Full Code Here

  }

  public void testInsertWithStringPkAndKeyAncestor_IdGen() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasKeyAncestorStringPkJDO hk1 = new HasKeyAncestorStringPkJDO();
    hk1.setAncestorKey(e.getKey());
    beginTxn();
    pm.makePersistent(hk1);
    String key = hk1.getKey();
    Key ancestorKey = hk1.getAncestorKey();
    commitTxn();
    Entity reloaded = ds.get(KeyFactory.stringToKey(key));
    assertEquals(ancestorKey, reloaded.getKey().getParent());
  }
View Full Code Here

  }

  public void testInsertWithStringPkAndKeyAncestor_NamedKey() throws EntityNotFoundException {
    Entity e = new Entity("yam");
    ds.put(e);
    HasKeyAncestorStringPkJDO hk1 = new HasKeyAncestorStringPkJDO();
    Key keyToSet =
        new Entity(HasKeyAncestorStringPkJDO.class.getSimpleName(), "yar", e.getKey()).getKey();
    hk1.setKey(KeyFactory.keyToString(keyToSet));
    beginTxn();
    pm.makePersistent(hk1);
    String key = hk1.getKey();
    assertEquals(e.getKey(), hk1.getAncestorKey());
    commitTxn();
    Entity reloaded = ds.get(KeyFactory.stringToKey(key));
    assertEquals(e.getKey(), reloaded.getKey().getParent());
  }
View Full Code Here

  }

  public void testInsertWithStringPkAndKeyAncestor_SetAncestorAndPk() throws EntityNotFoundException {
    Entity parentEntity = new Entity("yam");
    ds.put(parentEntity);
    HasKeyAncestorStringPkJDO hk1 = new HasKeyAncestorStringPkJDO();
    Key keyToSet =
        new Entity(HasKeyAncestorStringPkJDO.class.getSimpleName(), "yar", parentEntity.getKey()).getKey();
    hk1.setKey(KeyFactory.keyToString(keyToSet));
    hk1.setAncestorKey(keyToSet);
    beginTxn();
    try {
      pm.makePersistent(hk1);
      fail("expected exception");
    } catch (JDOFatalUserException e) {
View Full Code Here

    ds.put(parent);
    Entity child = new Entity(HasKeyAncestorStringPkJDO.class.getSimpleName(), parent.getKey());
    ds.put(child);
    commitTxn();
    beginTxn();
    HasKeyAncestorStringPkJDO hk =
        pm.getObjectById(HasKeyAncestorStringPkJDO.class, KeyFactory.keyToString(child.getKey()));
    assertNotNull(hk.getKey());
    assertEquals(parent.getKey(), hk.getAncestorKey());
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jdo.HasKeyAncestorStringPkJDO

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.