Examples of UnidirTop


Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

  void testUpdate_UpdateChildWithMerge(HasOneToManyJDO pojo,
      BidirectionalSuperclassTableChildJDO.BidirTop bidir, StartEnd startEnd,
      String expectedBidirKind, String expectedUnidirKind,
      UnidirLevel unidirLevel, int count) throws EntityNotFoundException {
    UnidirTop unidir = newUnidir(unidirLevel);

    pojo.addUnidirChild(unidir);
    pojo.addBidirChild(bidir);
    bidir.setParent(pojo);

    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();

    assertNotNull(unidir.getId());
    assertNotNull(bidir.getId());
    assertNotNull(pojo.getId());

    startEnd.start();
    unidir.setStr("yam");
    bidir.setChildVal("yap");
    pm.makePersistent(pojo);
    startEnd.end();

    Entity unidirChildEntity = ds.get(KeyFactory.stringToKey(unidir.getId()));
    assertNotNull(unidirChildEntity);
    assertEquals(expectedUnidirKind, unidirChildEntity.getKind());
    int numProps = unidir.getPropertyCount();
    if (hasIndexPropertyInChild(pm)) {
      numProps += getIndexPropertyCount();
    }
    assertEquals(numProps, unidirChildEntity.getProperties().size());
    assertEquals(unidirLevel.discriminator, unidirChildEntity.getProperty("TYPE"));
    assertEquals("yam", unidirChildEntity.getProperty("str"));
    PolymorphicTestUtils.assertKeyParentEquals(pojo.getId(), unidirChildEntity, unidir.getId());
    if (isIndexed() && hasIndexPropertyInChild(pm)) {
      assertEquals(0L, unidirChildEntity.getProperty("unidirChildren_INTEGER_IDX"));
    }

    Entity bidirEntity = ds.get(KeyFactory.stringToKey(bidir.getId()));
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

 
  void testUpdate_UpdateChild(HasOneToManyJDO pojo,
      BidirectionalSuperclassTableChildJDO.BidirTop bidir, StartEnd startEnd,
      String expectedBidirKind, String expectedUnidirKind,
      UnidirLevel unidirLevel, int count) throws EntityNotFoundException {
    UnidirTop unidir = newUnidir(unidirLevel);

    pojo.addUnidirChild(unidir);
    pojo.addBidirChild(bidir);
    bidir.setParent(pojo);

    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();

    assertNotNull(unidir.getId());
    assertNotNull(bidir.getId());
    assertNotNull(pojo.getId());

    startEnd.start();
    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
    pojo.getUnidirChildren().iterator().next().setStr("yam");
    pojo.getBidirChildren().iterator().next().setChildVal("yap");
    startEnd.end();

    Entity unidirChildEntity = ds.get(KeyFactory.stringToKey(unidir.getId()));
    assertNotNull(unidirChildEntity);
    assertEquals(expectedUnidirKind, unidirChildEntity.getKind());
    int numProps = unidir.getPropertyCount();
    if (hasIndexPropertyInChild(pm)) {
      numProps += getIndexPropertyCount();
    }
    assertEquals(numProps, unidirChildEntity.getProperties().size());
    assertEquals(unidirLevel.discriminator, unidirChildEntity.getProperty("TYPE"));
    assertEquals("yam", unidirChildEntity.getProperty("str"));
    PolymorphicTestUtils.assertKeyParentEquals(pojo.getId(), unidirChildEntity, unidir.getId());
    if (isIndexed() && hasIndexPropertyInChild(pm)) {
      assertEquals(0L, unidirChildEntity.getProperty("unidirChildren_INTEGER_IDX"));
    }

    Entity bidirEntity = ds.get(KeyFactory.stringToKey(bidir.getId()));
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

 
  void testUpdate_NullOutChildren(HasOneToManyJDO pojo,
    BidirectionalSuperclassTableChildJDO.BidirTop bidir, StartEnd startEnd,
    UnidirLevel unidirLevel, int count) throws EntityNotFoundException {
    UnidirTop unidir = newUnidir(unidirLevel);

    pojo.addUnidirChild(unidir);
    pojo.addBidirChild(bidir);
    bidir.setParent(pojo);

    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();

    assertCountsInDatastore(pojo.getClass(), bidir.getClass(), count, 1);

    startEnd.start();
    String unidirId = unidir.getId();
    String bidirChildId = bidir.getId();

    pojo.nullUnidirChildren();
    pojo.nullBidirChildren();
    pm.makePersistent(pojo);
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

 
  void testUpdate_ClearOutChildren(HasOneToManyJDO pojo,
      BidirectionalSuperclassTableChildJDO.BidirTop bidir, StartEnd startEnd,
      UnidirLevel unidirLevel, int count) throws EntityNotFoundException {
    UnidirTop unidir = newUnidir(unidirLevel);

    pojo.addUnidirChild(unidir);
    pojo.addBidirChild(bidir);
    bidir.setParent(pojo);

    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();
    String unidirId = unidir.getId();
    String bidirChildId = bidir.getId();
    assertCountsInDatastore(pojo.getClass(), bidir.getClass(), count, 1);

    startEnd.start();
    pojo = pm.makePersistent(pojo);
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

    pm.makePersistent(pojo);
    startEnd.end();
   
    startEnd.start();
    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
    UnidirTop unidir = newUnidir(UnidirLevel.Bottom);
    unidir.setStr("str1");
    unidir.setName("name 1");
    pojo.getUndirByStrAndName().add(unidir);
    unidir = newUnidir(UnidirLevel.Top);
    unidir.setStr("str2");
    unidir.setName("name 2");
    pojo.getUndirByStrAndName().add(unidir);
    unidir = newUnidir(UnidirLevel.Bottom);
    unidir.setStr("str1");
    unidir.setName("name 0");
    pojo.getUndirByStrAndName().add(unidir);
    startEnd.end();
   
    startEnd.start();
    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

  }

  void testRemoveAll(HasOneToManyJDO pojo, BidirectionalSuperclassTableChildJDO.BidirTop bidir1,
                     BidirectionalSuperclassTableChildJDO.BidirTop bidir2, BidirectionalSuperclassTableChildJDO.BidirTop bidir3, StartEnd startEnd)
      throws EntityNotFoundException {
    UnidirTop unidir1 = new UnidirTop();
    UnidirTop unidir2 = new UnidirMiddle();
    UnidirTop unidir3 = new UnidirBottom();
    pojo.addUnidirChild(unidir1);
    pojo.addUnidirChild(unidir2);
    pojo.addUnidirChild(unidir3);

    pojo.addBidirChild(bidir1);
    pojo.addBidirChild(bidir2);
    pojo.addBidirChild(bidir3);

    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();
    startEnd.start();
    pojo = pm.makePersistent(pojo);
    String unidir2Id = unidir2.getId();
    String bidir2Id = bidir2.getId();
    pojo.removeUnidirChildren(Collections.singleton(unidir2));
    pojo.removeBidirChildren(Collections.singleton(bidir2));
    startEnd.end();
    startEnd.start();

    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());

    assertEquals(2, pojo.getUnidirChildren().size());
    Set<String> unidirIds = Utils.newHashSet(unidir1.getId(), unidir2.getId(), unidir3.getId());
    for (UnidirTop unidir : pojo.getUnidirChildren()) {
      unidirIds.remove(unidir.getId());
    }
    assertEquals(1, unidirIds.size());
    assertEquals(unidir2.getId(), unidirIds.iterator().next());

    assertEquals(2, pojo.getBidirChildren().size());
    Set<String> bidirIds = Utils.newHashSet(bidir1.getId(), bidir2.getId(), bidir3.getId());
    for (BidirectionalSuperclassTableChildJDO.BidirTop b : pojo.getBidirChildren()) {
      bidirIds.remove(b.getId());
    }
    assertEquals(1, bidirIds.size());
    assertEquals(bidir2.getId(), bidirIds.iterator().next());
    startEnd.end();

    Entity unidirEntity1 = ds.get(KeyFactory.stringToKey(unidir1.getId()));
    Entity unidirEntity3 = ds.get(KeyFactory.stringToKey(unidir3.getId()));
    Entity bidirEntity1 = ds.get(KeyFactory.stringToKey(bidir1.getId()));
    Entity bidirEntity3 = ds.get(KeyFactory.stringToKey(bidir3.getId()));
    if (isIndexed() && hasIndexPropertyInChild(pm)) {
      // Only have index property when using older storageVersions
      assertEquals(0L, unidirEntity1.getProperty("unidirChildren_INTEGER_IDX"));
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop


  void testRemoveAll_LongPkOnParent(HasOneToManyLongPkJDO pojo, BidirTopLongPk bidir1,
      BidirTopLongPk bidir2, BidirTopLongPk bidir3, StartEnd startEnd)
      throws EntityNotFoundException {
    UnidirTop unidir1 = new UnidirBottom();
    UnidirTop unidir2 = new UnidirMiddle();
    UnidirTop unidir3 = new UnidirTop();
    pojo.addUnidirChild(unidir1);
    pojo.addUnidirChild(unidir2);
    pojo.addUnidirChild(unidir3);

    pojo.addBidirChild(bidir1);
    pojo.addBidirChild(bidir2);
    pojo.addBidirChild(bidir3);

    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();
    startEnd.start();
    pojo = pm.makePersistent(pojo);
    String f2Id = unidir2.getId();
    String bidir2Id = bidir2.getId();
    pojo.removeUnidirChildren(Collections.singleton(unidir2));
    pojo.removeBidirChildren(Collections.singleton(bidir2));
    startEnd.end();
    startEnd.start();

    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
    assertEquals(2, pojo.getUnidirChildren().size());
    Set<String> unidirIds = Utils.newHashSet(unidir1.getId(), unidir2.getId(), unidir3.getId());
    for (UnidirTop f : pojo.getUnidirChildren()) {
      unidirIds.remove(f.getId());
    }
    assertEquals(1, unidirIds.size());
    assertEquals(unidir2.getId(), unidirIds.iterator().next());

    assertEquals(2, pojo.getBidirChildren().size());
    Set<String> bidirIds = Utils.newHashSet(bidir1.getId(), bidir2.getId(), bidir3.getId());
    for (BidirTopLongPk b : pojo.getBidirChildren()) {
      bidirIds.remove(b.getId());
    }
    assertEquals(1, bidirIds.size());
    assertEquals(bidir2.getId(), bidirIds.iterator().next());
    startEnd.end();

    Entity unidirEntity1 = ds.get(KeyFactory.stringToKey(unidir1.getId()));
    Entity unidirEntity3 = ds.get(KeyFactory.stringToKey(unidir3.getId()));
    Entity bidirEntity1 = ds.get(KeyFactory.stringToKey(bidir1.getId()));
    Entity bidirEntity3 = ds.get(KeyFactory.stringToKey(bidir3.getId()));
    if (isIndexed() && hasIndexPropertyInChild(pm)) {
      // Only have index property when using older storageVersions
      assertEquals(0L, unidirEntity1.getProperty("unidirChildren_INTEGER_IDX_longpk"));
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

 
  void testRemoveAll_UnencodedStringPkOnParent(HasOneToManyUnencodedStringPkJDO pojo, BidirTopUnencodedStringPkJDO bidir1,
      BidirTopUnencodedStringPkJDO bidir2,
      BidirTopUnencodedStringPkJDO bidir3, StartEnd startEnd)
      throws EntityNotFoundException {
    UnidirTop unidir1 = new UnidirBottom();
    UnidirTop unidir2 = new UnidirTop();
    UnidirTop unidir3 = new UnidirMiddle();
    pojo.addUnidirChild(unidir1);
    pojo.addUnidirChild(unidir2);
    pojo.addUnidirChild(unidir3);

    pojo.addBidirChild(bidir1);
    pojo.addBidirChild(bidir2);
    pojo.addBidirChild(bidir3);

    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();
    startEnd.start();
    pojo = pm.makePersistent(pojo);
    String f2Id = unidir2.getId();
    String bidir2Id = bidir2.getId();
    pojo.removeUnidirChildren(Collections.singleton(unidir2));
    pojo.removeBidirChildren(Collections.singleton(bidir2));
    startEnd.end();
    startEnd.start();

    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());

    assertEquals(2, pojo.getUnidirChildren().size());
    Set<String> unidirIds = Utils.newHashSet(unidir1.getId(), unidir2.getId(), unidir3.getId());
    for (UnidirTop f : pojo.getUnidirChildren()) {
      unidirIds.remove(f.getId());
    }
    assertEquals(1, unidirIds.size());
    assertEquals(unidir2.getId(), unidirIds.iterator().next());

    assertEquals(2, pojo.getBidirChildren().size());
    Set<String> bidirIds = Utils.newHashSet(bidir1.getId(), bidir2.getId(), bidir3.getId());
    for (BidirTopUnencodedStringPkJDO b : pojo.getBidirChildren()) {
      bidirIds.remove(b.getId());
    }
    assertEquals(1, bidirIds.size());
    assertEquals(bidir2.getId(), bidirIds.iterator().next());
    startEnd.end();

    Entity unidirEntity1 = ds.get(KeyFactory.stringToKey(unidir1.getId()));
    Entity unidirEntity3 = ds.get(KeyFactory.stringToKey(unidir3.getId()));
    Entity bidirEntity1 = ds.get(KeyFactory.stringToKey(bidir1.getId()));
    bidirEntity1.setProperty("DISCRIMINATOR", "B");
    Entity bidirEntity3 = ds.get(KeyFactory.stringToKey(bidir3.getId()));
    bidirEntity3.setProperty("DISCRIMINATOR", "M");
    if (isIndexed() && hasIndexPropertyInChild(pm)) {
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

 
  void testChangeParent(HasOneToManyJDO pojo, HasOneToManyJDO pojo2,
      StartEnd startEnd, UnidirLevel unidirLevel) {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    UnidirTop unidir1 = newUnidir(unidirLevel);
    pojo.addUnidirChild(unidir1);

    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jdo.UnidirectionalSuperclassTableChildJDO.UnidirTop

    }
  }

  void testNewParentNewChild_NamedKeyOnChild(HasOneToManyJDO pojo, StartEnd startEnd,
      UnidirLevel unidirLevel) throws EntityNotFoundException {
    UnidirTop unidir1 = newUnidir(unidirLevel);
    pojo.addUnidirChild(unidir1);
    unidir1.setId(KeyFactory.keyToString(
        KeyFactory.createKey(getEntityKind(UnidirTop.class), "named key")));
    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();

    Entity unidirEntity = ds.get(KeyFactory.stringToKey(unidir1.getId()));
    assertEquals("named key", unidirEntity.getKey().getName());
  }
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.