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

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


* @author Max Ross <maxr@google.com>
*/
public class JDOFetchGroupTest extends JDOTestCase {

  public void testDefaultFetchGroup() {
    HasFetchGroupsJDO pojo = new HasFetchGroupsJDO();
    pojo.setStr1("1");
    pojo.setStr2("2");
    pojo.setStr3("3");
    pojo.setStr4("4");
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    pm.close();
    pm = pmf.getPersistenceManager();
    beginTxn();
    pojo = pm.detachCopy(pm.getObjectById(HasFetchGroupsJDO.class, pojo.getId()));
    commitTxn();
    assertEquals("1", pojo.getStr1());
    assertEquals("2", pojo.getStr2());
    assertNull(pojo.getStr3());
    assertEquals("4", pojo.getStr4());
    beginTxn();
    pojo = pm.getObjectById(HasFetchGroupsJDO.class, pojo.getId());
    pojo.getStr3();
    pojo = pm.detachCopy(pojo);
    commitTxn();
    beginTxn();
    pojo = pm.getObjectById(HasFetchGroupsJDO.class, pojo.getId());
    assertEquals("1", pojo.getStr1());
    assertEquals("2", pojo.getStr2());
    assertEquals("3", pojo.getStr3());
    assertEquals("4", pojo.getStr4());
    commitTxn();
  }
View Full Code Here


    assertEquals("4", pojo.getStr4());
    commitTxn();
  }

  public void testCustomFetchGroup_ReplaceDefault() {
    HasFetchGroupsJDO pojo = new HasFetchGroupsJDO();
    pojo.setStr1("1");
    pojo.setStr2("2");
    pojo.setStr3("3");
    pojo.setStr4("4");
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    beginTxn();
    pm.getFetchPlan().setGroup("fg1");
    pojo = pm.detachCopy(pm.getObjectById(HasFetchGroupsJDO.class, pojo.getId()));
    commitTxn();
    assertNull(pojo.getStr1());
    assertNull(pojo.getStr2());
    assertEquals("3", pojo.getStr3());
    assertNull(pojo.getStr4());
  }
View Full Code Here

    assertEquals("3", pojo.getStr3());
    assertNull(pojo.getStr4());
  }

  public void testCustomFetchGroup_AddToDefault() {
    HasFetchGroupsJDO pojo = new HasFetchGroupsJDO();
    pojo.setStr1("1");
    pojo.setStr2("2");
    pojo.setStr3("3");
    pojo.setStr4("4");
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    beginTxn();
    pm.getFetchPlan().addGroup("fg1");
    pojo = pm.detachCopy(pm.getObjectById(HasFetchGroupsJDO.class, pojo.getId()));
    commitTxn();
    assertEquals("1", pojo.getStr1());
    assertEquals("2", pojo.getStr2());
    assertEquals("3", pojo.getStr3());
    assertEquals("4", pojo.getStr4());
  }
View Full Code Here

    assertEquals("3", pojo.getStr3());
    assertEquals("4", pojo.getStr4());
  }

  public void testFetchGroupWithQuery() {
    HasFetchGroupsJDO pojo = new HasFetchGroupsJDO();
    pojo.setStr1("1");
    pojo.setStr2("2");
    pojo.setStr3("3");
    pojo.setStr4("4");
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();
    beginTxn();
    Query q = pm.newQuery(HasFetchGroupsJDO.class);
    q.setUnique(true);
    pojo = (HasFetchGroupsJDO) pm.detachCopy(q.execute());
    commitTxn();
    assertEquals("1", pojo.getStr1());
    assertEquals("2", pojo.getStr2());
    assertNull(pojo.getStr3());
    assertEquals("4", pojo.getStr4());

    beginTxn();
    pm.getFetchPlan().addGroup("fg1");
    pojo = (HasFetchGroupsJDO) pm.detachCopy(q.execute());
    commitTxn();
    assertEquals("1", pojo.getStr1());
    assertEquals("2", pojo.getStr2());
    assertEquals("3", pojo.getStr3());
    assertEquals("4", pojo.getStr4());

    beginTxn();
    q = pm.newQuery(HasFetchGroupsJDO.class);
    q.setUnique(true);
    pm.getFetchPlan().setGroup("fg1");
    pojo = (HasFetchGroupsJDO) pm.detachCopy(q.execute());
    commitTxn();
    assertNull(pojo.getStr1());
    assertNull(pojo.getStr2());
    assertEquals("3", pojo.getStr3());
    assertNull(pojo.getStr4());
  }
View Full Code Here

    assertEquals("3", pojo.getStr3());
    assertNull(pojo.getStr4());
  }

  public void testFetchGroupOverridesCanBeManuallyUndone() {   
    HasFetchGroupsJDO pojo = new HasFetchGroupsJDO();
    pojo.setLink(new Link("blarg"));
    makePersistentInTxn(pojo, TXN_START_END);
    beginTxn();
    pojo = pm.detachCopy(pm.getObjectById(HasFetchGroupsJDO.class, pojo.getId()));
    commitTxn();
    assertNull(pojo.getLink());
  }
View Full Code Here

TOP

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

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.