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

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


  }

  void testRemoveAll(HasOneToManyJDO pojo, BidirectionalChildJDO bidir1,
                     BidirectionalChildJDO bidir2, BidirectionalChildJDO bidir3, StartEnd startEnd)
      throws EntityNotFoundException {
    Flight f1 = new Flight();
    Flight f2 = new Flight();
    Flight f3 = new Flight();
    pojo.addFlight(f1);
    pojo.addFlight(f2);
    pojo.addFlight(f3);

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

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

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

    assertEquals(2, pojo.getFlights().size());
    Set<String> flightIds = Utils.newHashSet(f1.getId(), f2.getId(), f3.getId());
    for (Flight f : pojo.getFlights()) {
      flightIds.remove(f.getId());
    }
    assertEquals(1, flightIds.size());
    assertEquals(f2.getId(), flightIds.iterator().next());

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

    Entity flightEntity1 = ds.get(KeyFactory.stringToKey(f1.getId()));
    Entity flightEntity3 = ds.get(KeyFactory.stringToKey(f3.getId()));
    Entity bidirEntity1 = ds.get(KeyFactory.stringToKey(bidir1.getId()));
    Entity bidirEntity3 = ds.get(KeyFactory.stringToKey(bidir3.getId()));
    if (isIndexed() && getStorageVersion(pm) == StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN) {
      assertEquals(0L, flightEntity1.getProperty("flights_INTEGER_IDX"));
      assertEquals(1L, flightEntity3.getProperty("flights_INTEGER_IDX"));
View Full Code Here


  }

  void testRemoveAll_LongPkOnParent(HasOneToManyLongPkJDO pojo, BidirectionalChildLongPkJDO bidir1,
                     BidirectionalChildLongPkJDO bidir2, BidirectionalChildLongPkJDO bidir3, StartEnd startEnd)
      throws EntityNotFoundException {
    Flight f1 = new Flight();
    Flight f2 = new Flight();
    Flight f3 = new Flight();
    pojo.addFlight(f1);
    pojo.addFlight(f2);
    pojo.addFlight(f3);

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

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

    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
    assertEquals(2, pojo.getFlights().size());
    Set<String> flightIds = Utils.newHashSet(f1.getId(), f2.getId(), f3.getId());
    for (Flight f : pojo.getFlights()) {
      flightIds.remove(f.getId());
    }
    assertEquals(1, flightIds.size());
    assertEquals(f2.getId(), flightIds.iterator().next());

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

    Entity flightEntity1 = ds.get(KeyFactory.stringToKey(f1.getId()));
    Entity flightEntity3 = ds.get(KeyFactory.stringToKey(f3.getId()));
    Entity bidirEntity1 = ds.get(KeyFactory.stringToKey(bidir1.getId()));
    Entity bidirEntity3 = ds.get(KeyFactory.stringToKey(bidir3.getId()));
    if (isIndexed() && getStorageVersion(pm) == StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN) {
      assertEquals(0L, flightEntity1.getProperty("flights_INTEGER_IDX_longpk"));
      assertEquals(1L, flightEntity3.getProperty("flights_INTEGER_IDX_longpk"));
View Full Code Here

  void testRemoveAll_UnencodedStringPkOnParent(HasOneToManyUnencodedStringPkJDO pojo, BidirectionalChildUnencodedStringPkJDO bidir1,
                     BidirectionalChildUnencodedStringPkJDO bidir2,
                     BidirectionalChildUnencodedStringPkJDO bidir3, StartEnd startEnd)
      throws EntityNotFoundException {
    Flight f1 = new Flight();
    Flight f2 = new Flight();
    Flight f3 = new Flight();
    pojo.addFlight(f1);
    pojo.addFlight(f2);
    pojo.addFlight(f3);

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

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

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

    assertEquals(2, pojo.getFlights().size());
    Set<String> flightIds = Utils.newHashSet(f1.getId(), f2.getId(), f3.getId());
    for (Flight f : pojo.getFlights()) {
      flightIds.remove(f.getId());
    }
    assertEquals(1, flightIds.size());
    assertEquals(f2.getId(), flightIds.iterator().next());

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

    Entity flightEntity1 = ds.get(KeyFactory.stringToKey(f1.getId()));
    Entity flightEntity3 = ds.get(KeyFactory.stringToKey(f3.getId()));
    Entity bidirEntity1 = ds.get(KeyFactory.stringToKey(bidir1.getId()));
    Entity bidirEntity3 = ds.get(KeyFactory.stringToKey(bidir3.getId()));
    if (isIndexed() && getStorageVersion(pm) == StorageVersion.PARENTS_DO_NOT_REFER_TO_CHILDREN) {
      assertEquals(0L, flightEntity1.getProperty("flights_INTEGER_IDX_unencodedstringpk"));
      assertEquals(1L, flightEntity3.getProperty("flights_INTEGER_IDX_unencodedstringpk"));
View Full Code Here

    }
  }

  void testChangeParent(HasOneToManyJDO pojo, HasOneToManyJDO pojo2, StartEnd startEnd) {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    Flight f1 = new Flight();
    pojo.addFlight(f1);

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

      }
    }
  }

  void testNewParentNewChild_NamedKeyOnChild(HasOneToManyJDO pojo, StartEnd startEnd) throws EntityNotFoundException {
    Flight f1 = new Flight();
    pojo.addFlight(f1);
    f1.setId(KeyFactory.keyToString(
        KeyFactory.createKey(Flight.class.getSimpleName(), "named key")));
    startEnd.start();
    pm.makePersistent(pojo);
    startEnd.end();

    Entity flightEntity = ds.get(KeyFactory.stringToKey(f1.getId()));
    assertEquals("named key", flightEntity.getKey().getName());
  }
View Full Code Here

    assertEquals("named key", flightEntity.getKey().getName());
  }

  void testAddAlreadyPersistedChildToParent_NoTxnDifferentPm(HasOneToManyJDO pojo) {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    Flight f1 = new Flight();
    pm.makePersistent(f1);
    f1 = pm.detachCopy(f1);
    pm.close();
    pm = pmf.getPersistenceManager();
    f1 = pm.makePersistent(f1);
View Full Code Here

    assertEquals(1, countForClass(Flight.class));
  }

  void testAddAlreadyPersistedChildToParent_NoTxnSamePm(HasOneToManyJDO pojo) {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    Flight f1 = new Flight();
    pm.makePersistent(f1);
    pojo.addFlight(f1);
    try {
      pm.makePersistent(pojo);
      fail("expected exception");
View Full Code Here

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

    startEnd.start();
    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
    Flight f = new Flight();
    pojo.addFlight(f);
    pojo.addBidirChild(bidirChild);
    startEnd.end();
    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    Entity bidirEntity = ds.get(KeyFactory.stringToKey(bidirChild.getId()));
    Entity pojoEntity = ds.get(KeyFactory.createKey(pojo.getClass().getSimpleName(), pojo.getId()));
    assertEquals(pojoEntity.getKey(), flightEntity.getParent());
    assertEquals(pojoEntity.getKey(), bidirEntity.getParent());
  }
View Full Code Here

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

    startEnd.start();
    pojo = pm.getObjectById(pojo.getClass(), pojo.getId());
    Flight f = new Flight();
    pojo.addFlight(f);
    pojo.addBidirChild(bidirChild);
    startEnd.end();
    Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
    Entity bidirEntity = ds.get(KeyFactory.stringToKey(bidirChild.getId()));
    Entity pojoEntity = ds.get(KeyFactory.createKey(pojo.getClass().getSimpleName(), pojo.getId()));
    assertEquals(pojoEntity.getKey(), flightEntity.getParent());
    assertEquals(pojoEntity.getKey(), bidirEntity.getParent());
  }
View Full Code Here

    PutPolicy policy = new PutPolicy();
    DatastoreServiceInterceptor.install(getStoreManager(), policy);
    try {
      pmf.close();
      switchDatasource(startEnd.getPmfName());
      Flight flight = new Flight();
      pojo.addFlight(flight);
      pojo.addBidirChild(bidir);
      HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
      pojo.addHasKeyPk(hasKeyPk);
View Full Code Here

TOP

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

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.