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

Examples of com.google.appengine.datanucleus.test.jpa.BidirectionalSingleTableChildListJPA.BidirMiddleList


  }

  public void testUpdate_ClearOutChildren() throws Exception {
    testUpdate_ClearOutChildren(new BidirBottomList(), new HasOneToManyListJPA(),
        TXN_START_END, UnidirLevel.Top, 1);
    testUpdate_ClearOutChildren(new BidirMiddleList(), new HasOneToManyListJPA(),
        TXN_START_END, UnidirLevel.Middle, 2);
    testUpdate_ClearOutChildren(new BidirTopList(), new HasOneToManyListJPA(),
        TXN_START_END, UnidirLevel.Bottom, 3);
  }
View Full Code Here


        TXN_START_END, UnidirLevel.Bottom, 3);
  }
  public void testUpdate_ClearOutChildren_NoTxn() throws Exception {
    testUpdate_ClearOutChildren(new BidirTopList(), new HasOneToManyListJPA(),
        NEW_EM_START_END, UnidirLevel.Bottom, 1);
    testUpdate_ClearOutChildren(new BidirMiddleList(), new HasOneToManyListJPA(),
        NEW_EM_START_END, UnidirLevel.Middle, 2);
    testUpdate_ClearOutChildren(new BidirBottomList(), new HasOneToManyListJPA(),
        NEW_EM_START_END, UnidirLevel.Top, 3);
  }
View Full Code Here

    assertCountsInDatastore(HasOneToManyListJPA.class, BidirTopList.class, 1, 1);
  }

  public void testRemoveObject() throws Exception {
    testRemoveObject(new HasOneToManyListJPA(), new BidirTopList(),
        new BidirMiddleList(), TXN_START_END, UnidirLevel.Top, UnidirLevel.Middle, 1);
    testRemoveObject(new HasOneToManyListJPA(), new BidirMiddleList(),
        new BidirBottomList(), TXN_START_END, UnidirLevel.Middle, UnidirLevel.Bottom, 2);
    testRemoveObject(new HasOneToManyListJPA(), new BidirTopList(),
        new BidirBottomList(), TXN_START_END, UnidirLevel.Bottom, UnidirLevel.Top, 3);
  }
View Full Code Here

    testRemoveObject(new HasOneToManyListJPA(), new BidirTopList(),
        new BidirBottomList(), TXN_START_END, UnidirLevel.Bottom, UnidirLevel.Top, 3);
  }

  public void testRemoveObject_NoTxn() throws Exception {
    testRemoveObject(new HasOneToManyListJPA(), new BidirMiddleList(),
        new BidirTopList(), NEW_EM_START_END, UnidirLevel.Middle, UnidirLevel.Top, 1);
    testRemoveObject(new HasOneToManyListJPA(), new BidirBottomList(),
        new BidirTopList(), NEW_EM_START_END, UnidirLevel.Bottom, UnidirLevel.Top, 2);
    testRemoveObject(new HasOneToManyListJPA(), new BidirMiddleList(),
        new BidirBottomList(), NEW_EM_START_END, UnidirLevel.Top, UnidirLevel.Bottom, 3);
  }
View Full Code Here

  private void testAddAtPosition(StartEnd startEnd) throws Exception {
    HasOneToManyListJPA pojo = new HasOneToManyListJPA();
    pojo.setVal("yar");
    BidirTopList bidir1 = new BidirBottomList();
    BidirTopList bidir2 = new BidirMiddleList();
    bidir1.setChildVal("yam1");
    bidir2.setChildVal("yam2");
    UnidirTop unidir1 = newUnidir(UnidirLevel.Middle);
    UnidirTop unidir2 = newUnidir(UnidirLevel.Top);
    unidir2.setName("max");
    unidir2.setStr("another str");
    HasKeyPkJPA hasKeyPk1 = new HasKeyPkJPA();
    HasKeyPkJPA hasKeyPk2 = new HasKeyPkJPA();
    hasKeyPk2.setStr("yar 2");
    pojo.getUnidirChildren().add(unidir1);
    pojo.getHasKeyPks().add(hasKeyPk1);
    pojo.getBidirChildren().add(bidir1);

    startEnd.start();
    em.persist(pojo);
    startEnd.end();

    assertCountsInDatastore(HasOneToManyListJPA.class, BidirTopList.class, 1, 1);

    startEnd.start();
    pojo = em.find(pojo.getClass(), pojo.getId());
    String bidir1Id = pojo.getBidirChildren().get(0).getId();
    String bookId = pojo.getUnidirChildren().get(0).getId();
    Key hasKeyPk1Key = pojo.getHasKeyPks().get(0).getId();
    pojo.getBidirChildren().add(0, bidir2);
    pojo.getUnidirChildren().add(0, unidir2);
    pojo.getHasKeyPks().add(0, hasKeyPk2);
    startEnd.end();

    startEnd.start();
    assertNotNull(pojo.getId());
    assertEquals(2, pojo.getUnidirChildren().size());
    assertEquals(2, pojo.getHasKeyPks().size());
    assertEquals(2, pojo.getBidirChildren().size());
    assertNotNull(bidir2.getId());
    assertNotNull(bidir2.getParent());
    assertNotNull(unidir2.getId());
    assertNotNull(hasKeyPk2.getId());

    Entity pojoEntity = ds.get(KeyFactory.stringToKey(pojo.getId()));
    assertNotNull(pojoEntity);
    assertEquals(4, pojoEntity.getProperties().size());
    assertEquals(Utils.newArrayList(KeyFactory.stringToKey(bidir2.getId()), KeyFactory.stringToKey(bidir1Id)), pojoEntity.getProperty("bidirChildren"));
    assertEquals(Utils.newArrayList(KeyFactory.stringToKey(unidir2.getId()), KeyFactory.stringToKey(bookId)), pojoEntity.getProperty("unidirChildren"));
    assertEquals(Utils.newArrayList(hasKeyPk2.getId(), hasKeyPk1Key), pojoEntity.getProperty("hasKeyPks"));

    startEnd.end();

    ds.get(KeyFactory.stringToKey(bidir1Id));
    ds.get(KeyFactory.stringToKey(bookId));
    ds.get(hasKeyPk1Key);

    Entity bidirChildEntity1 = ds.get(KeyFactory.stringToKey(bidir1Id));
    assertNotNull(bidirChildEntity1);
   
    Entity bidirChildEntity2 = ds.get(KeyFactory.stringToKey(bidir2.getId()));
    assertNotNull(bidirChildEntity2);
    assertEquals("yam2", bidirChildEntity2.getProperty("childVal"));
    assertEquals(bidir2.getPropertyCount(), bidirChildEntity2.getProperties().size());
    assertEquals(bidir2.getClass().getName(), bidirChildEntity2.getProperty("DTYPE"));
    assertEquals(KeyFactory.stringToKey(bidir2.getId()), bidirChildEntity2.getKey());
    assertKeyParentEquals(pojo.getId(), bidirChildEntity2, bidir2.getId());

    Entity unidirEntity1 = ds.get(KeyFactory.stringToKey(bookId));
    Entity unidirEntity2 = ds.get(KeyFactory.stringToKey(unidir2.getId()));
    assertNotNull(unidirEntity2);
    assertEquals("max", unidirEntity2.getProperty("name"));
View Full Code Here

    testAddQueriedParentToBidirChild(NEW_EM_START_END);
  }
  private void testAddQueriedParentToBidirChild(StartEnd startEnd) throws Exception {
    testAddQueriedParentToBidirChild(new HasOneToManyListJPA(), new BidirTopList(),
  startEnd);
    testAddQueriedParentToBidirChild(new HasOneToManyListJPA(), new BidirMiddleList(),
  startEnd);
    testAddQueriedParentToBidirChild(new HasOneToManyListJPA(), new BidirBottomList(),
  startEnd);
  }
View Full Code Here

    testAddFetchedParentToBidirChild(NEW_EM_START_END);
  }
  private void testAddFetchedParentToBidirChild(StartEnd startEnd) throws Exception {
    testAddFetchedParentToBidirChild(new HasOneToManyListJPA(), new BidirBottomList(),
        startEnd);
    testAddFetchedParentToBidirChild(new HasOneToManyListJPA(), new BidirMiddleList(),
        startEnd);
    testAddFetchedParentToBidirChild(new HasOneToManyListJPA(), new BidirTopList(),
        startEnd);
  }
View Full Code Here

    testOnlyOneParentPutOnParentAndChildUpdate(NEW_EM_START_END);
  }
  private void testOnlyOneParentPutOnParentAndChildUpdate(StartEnd startEnd) throws Throwable {
    testOnlyOneParentPutOnParentAndChildUpdate(new HasOneToManyListJPA(), new BidirTopList(),
  startEnd);
    testOnlyOneParentPutOnParentAndChildUpdate(new HasOneToManyListJPA(), new BidirMiddleList(),
  startEnd);
    testOnlyOneParentPutOnParentAndChildUpdate(new HasOneToManyListJPA(), new BidirBottomList(),
  startEnd);
  }
View Full Code Here

    testOnlyOnePutOnChildUpdate(NEW_EM_START_END);
  }
  private void testOnlyOnePutOnChildUpdate(StartEnd startEnd) throws Throwable {
    testOnlyOnePutOnChildUpdate(new HasOneToManyListJPA(), new BidirTopList(),
  startEnd);
    testOnlyOnePutOnChildUpdate(new HasOneToManyListJPA(), new BidirMiddleList(),
  startEnd);
    testOnlyOnePutOnChildUpdate(new HasOneToManyListJPA(), new BidirBottomList(),
  startEnd);
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.BidirectionalSingleTableChildListJPA.BidirMiddleList

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.