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

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


  public void testSetPersistUniNewBoth() throws EntityNotFoundException {
    // Persist A-B as unowned
    UnownedJDOOneToManyUniSetSideA a = new UnownedJDOOneToManyUniSetSideA();
    a.setName("Side A");
    UnownedJDOOneToManyUniSideB b = new UnownedJDOOneToManyUniSideB();
    b.setName("Side B");
    a.addOther(b);

    pm.makePersistent(a);

    Object aId = pm.getObjectId(a);
    Object bId = pm.getObjectId(b);

    pm.evictAll(); // Make sure we go to the datastore

    // Retrieve by id and check
    UnownedJDOOneToManyUniSetSideA a2 = (UnownedJDOOneToManyUniSetSideA)pm.getObjectById(aId);
    assertNotNull(a2);
    assertEquals("Side A", a2.getName());
    Set<UnownedJDOOneToManyUniSideB> others = a2.getOthers();
    assertNotNull(others);
    assertEquals(1, others.size());
    UnownedJDOOneToManyUniSideB b2 = others.iterator().next();
    assertNotNull(b2);
    assertNotNull("Side B", b2.getName());
    assertEquals(bId, pm.getObjectId(b2));
  }
View Full Code Here


  public void testListPersistUniNewBoth() throws EntityNotFoundException {
    // Persist A-B as unowned
    UnownedJDOOneToManyUniListSideA a = new UnownedJDOOneToManyUniListSideA();
    a.setName("Side A");
    UnownedJDOOneToManyUniSideB b = new UnownedJDOOneToManyUniSideB();
    b.setName("Side B");
    a.addOther(b);

    pm.makePersistent(a);

    Object aId = pm.getObjectId(a);
    Object bId = pm.getObjectId(b);

    pm.evictAll(); // Make sure we go to the datastore

    // Retrieve by id and check
    UnownedJDOOneToManyUniListSideA a2 = (UnownedJDOOneToManyUniListSideA)pm.getObjectById(aId);
    assertNotNull(a2);
    assertEquals("Side A", a2.getName());
    List<UnownedJDOOneToManyUniSideB> others = a2.getOthers();
    assertNotNull(others);
    assertEquals(1, others.size());
    UnownedJDOOneToManyUniSideB b2 = others.iterator().next();
    assertNotNull(b2);
    assertNotNull("Side B", b2.getName());
    assertEquals(bId, pm.getObjectId(b2));
  }
View Full Code Here

  }

  public void testSetDeleteOwnerNotDependent() {
    UnownedJDOOneToManyUniSetSideA a = new UnownedJDOOneToManyUniSetSideA();
    a.setName("Side A");
    UnownedJDOOneToManyUniSideB b1 = new UnownedJDOOneToManyUniSideB();
    b1.setName("First B");
    UnownedJDOOneToManyUniSideB b2 = new UnownedJDOOneToManyUniSideB();
    b2.setName("Second B");
    a.addOther(b1);
    a.addOther(b2);
    pm.makePersistent(a);
    pm.close();
View Full Code Here

  }

  public void testListDeleteOwnerNotDependent() {
    UnownedJDOOneToManyUniListSideA a = new UnownedJDOOneToManyUniListSideA();
    a.setName("Side A");
    UnownedJDOOneToManyUniSideB b1 = new UnownedJDOOneToManyUniSideB();
    b1.setName("First B");
    UnownedJDOOneToManyUniSideB b2 = new UnownedJDOOneToManyUniSideB();
    b2.setName("Second B");
    a.addOther(b1);
    a.addOther(b2);
    pm.makePersistent(a);
    pm.close();
View Full Code Here

    assertEquals(2, bs.size());
  }

  public void testUnownedDelete() {
    UnownedJDOOneToManyUniListSideA p = new UnownedJDOOneToManyUniListSideA();
    UnownedJDOOneToManyUniSideB c1 = new UnownedJDOOneToManyUniSideB();
    p.addOther(c1);
    UnownedJDOOneToManyUniSideB c2 = new UnownedJDOOneToManyUniSideB();
    p.addOther(c2);

    pm.makePersistent(p);
    pm.close();
View Full Code Here

  }

  public void testUnownedList() {

    // creat children first, persist
    UnownedJDOOneToManyUniSideB c1 = new UnownedJDOOneToManyUniSideB();
    UnownedJDOOneToManyUniSideB c2 = new UnownedJDOOneToManyUniSideB();
    pm.makePersistent(c1);
    pm.makePersistent(c2);
    pm.evictAll();

    // verify children
View Full Code Here

TOP

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

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.