private void testInsert_NewParentAndChild(StartEnd startEnd) throws EntityNotFoundException {
Flight f = newFlight();
HasKeyPkJDO hasKeyPk = new HasKeyPkJDO();
HasOneToOneParentJDO hasParent = new HasOneToOneParentJDO();
HasOneToOneParentKeyPkJDO hasParentKeyPk = new HasOneToOneParentKeyPkJDO();
HasEncodedStringPkJDO notDependent = new HasEncodedStringPkJDO();
HasOneToOneJDO pojo = new HasOneToOneJDO();
pojo.setFlight(f);
pojo.setHasKeyPK(hasKeyPk);
pojo.setHasParent(hasParent);
hasParent.setParent(pojo);
pojo.setHasParentKeyPK(hasParentKeyPk);
hasParentKeyPk.setParent(pojo);
pojo.setNotDependent(notDependent);
makePersistentInTxn(pojo, startEnd);
assertNotNull(f.getId());
assertNotNull(hasKeyPk.getKey());
assertNotNull(hasParent.getKey());
assertNotNull(hasParentKeyPk.getKey());
assertNotNull(notDependent.getId());
assertNotNull(pojo.getId());
Entity flightEntity = ds.get(KeyFactory.stringToKey(f.getId()));
assertNotNull(flightEntity);
assertEquals("jimmy", flightEntity.getProperty("name"));
assertEquals("bos", flightEntity.getProperty("origin"));
assertEquals("mia", flightEntity.getProperty("dest"));
assertEquals(2L, flightEntity.getProperty("me"));
assertEquals(3L, flightEntity.getProperty("you"));
assertEquals(44L, flightEntity.getProperty("flight_number"));
assertEquals(KeyFactory.stringToKey(f.getId()), flightEntity.getKey());
assertKeyParentEquals(pojo.getId(), flightEntity, f.getId());
Entity hasKeyPkEntity = ds.get(hasKeyPk.getKey());
assertNotNull(hasKeyPkEntity);
assertEquals(hasKeyPk.getKey(), hasKeyPkEntity.getKey());
assertKeyParentEquals(pojo.getId(), hasKeyPkEntity, hasKeyPk.getKey());
Entity hasParentEntity = ds.get(KeyFactory.stringToKey(hasParent.getKey()));
assertNotNull(hasParentEntity);
assertEquals(KeyFactory.stringToKey(hasParent.getKey()), hasParentEntity.getKey());
assertKeyParentEquals(pojo.getId(), hasParentEntity, hasParent.getKey());
Entity hasParentKeyPkEntity = ds.get(hasParentKeyPk.getKey());
assertNotNull(hasParentKeyPkEntity);
assertEquals(hasParentKeyPk.getKey(), hasParentKeyPkEntity.getKey());
assertKeyParentEquals(pojo.getId(), hasParentKeyPkEntity, hasParentKeyPk.getKey());
Entity notDependentEntity = ds.get(KeyFactory.stringToKey(notDependent.getId()));
assertNotNull(notDependentEntity);
Entity pojoEntity = ds.get(KeyFactory.stringToKey(pojo.getId()));
assertNotNull(pojoEntity);
assertEquals(flightEntity.getKey(), pojoEntity.getProperty("flight_id_OID"));
assertEquals(hasKeyPkEntity.getKey(), pojoEntity.getProperty("hasKeyPK_key_OID"));
assertEquals(hasParentEntity.getKey(), pojoEntity.getProperty("hasParent_key_OID"));
assertEquals(hasParentKeyPkEntity.getKey(), pojoEntity.getProperty("hasParentKeyPK_key_OID"));
assertEquals(notDependentEntity.getKey(), pojoEntity.getProperty("notDependent_id_OID"));
assertCountsInDatastore(1, 1);
assertEquals(1, countForClass(notDependent.getClass()));
}