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

Examples of com.google.appengine.datanucleus.test.jpa.UnownedJPAOneToManyUniSideB


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

    em.persist(a);

    Long aId = a.getId();
    Long bId = b.getId();

    em.clear(); // Make sure we go to the datastore

    // Retrieve by id and check
    UnownedJPAOneToManyUniSetSideA a2 = em.find(UnownedJPAOneToManyUniSetSideA.class, aId);
    assertNotNull(a2);
    assertEquals("Side A", a2.getName());
    Set<UnownedJPAOneToManyUniSideB> others = a2.getBs();
    assertNotNull(others);
    assertEquals(1, others.size());
    UnownedJPAOneToManyUniSideB b2 = others.iterator().next();
    assertNotNull(b2);
    assertNotNull("Side B", b2.getName());
    assertEquals(bId, b2.getId());
  }
View Full Code Here


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

    em.persist(a);

    Long aId = a.getId();
    Long bId = b.getId();

    em.clear(); // Make sure we go to the datastore

    // Retrieve by id and check
    UnownedJPAOneToManyUniListSideA a2 = em.find(UnownedJPAOneToManyUniListSideA.class, aId);
    assertNotNull(a2);
    assertEquals("Side A", a2.getName());
    List<UnownedJPAOneToManyUniSideB> others = a2.getBs();
    assertNotNull(others);
    assertEquals(1, others.size());
    UnownedJPAOneToManyUniSideB b2 = others.iterator().next();
    assertNotNull(b2);
    assertNotNull("Side B", b2.getName());
    assertEquals(bId, b2.getId());
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.UnownedJPAOneToManyUniSideB

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.