public void testInsert_NamedKey() {
Entity flightEntity = Flight.newFlightEntity("parent named key", "max", "bos", "mia", 3, 4);
ds.put(flightEntity);
Key flightKey = flightEntity.getKey();
Key key = new Entity(HasStringAncestorStringPkJDO.class.getSimpleName(), "named key", flightKey).getKey();
HasStringAncestorStringPkJDO ha = new HasStringAncestorStringPkJDO(null, KeyFactory.keyToString(key));
makePersistentInTxn(ha, TXN_START_END);
Key keyWithParent = KeyFactory.stringToKey(ha.getId());
assertEquals(flightKey, keyWithParent.getParent());
// now we'll issue an ancestor query directly against the datastore and see
// if our object comes back.
Query q = new Query(ha.getClass().getSimpleName());
q.setAncestor(flightKey);
Entity result = ds.prepare(q).asSingleEntity();
assertEquals(flightKey, result.getKey().getParent());
assertEquals("named key", result.getKey().getName());
assertEquals("parent named key", result.getKey().getParent().getName());