concrete.setBase2Str("base 2");
concrete.setConcrete2Str("concrete");
Concrete3 concrete3 = new Concrete3();
concrete3.setStr("str3");
concrete.setConcrete3(concrete3);
Concrete4 concrete4a = new Concrete4();
concrete4a.setStr("str4a");
Concrete4 concrete4b = new Concrete4();
concrete4b.setStr("str4b");
concrete.setConcrete4(Utils.newArrayList(concrete4a, concrete4b));
beginTxn();
pm.makePersistent(concrete);
commitTxn();
Entity concreteEntity = ds.get(KeyFactory.createKey(kindForObject(concrete), concrete.getId()));
Entity concrete3Entity = ds.get(concrete3.getId());
Entity concrete4aEntity = ds.get(concrete4a.getId());
Entity concrete4bEntity = ds.get(concrete4b.getId());
assertEquals(5, concreteEntity.getProperties().size());
assertEquals("base 1", concreteEntity.getProperty("base1Str"));
assertEquals("base 2", concreteEntity.getProperty("base2Str"));
assertEquals("concrete", concreteEntity.getProperty("concrete2Str"));
assertEquals(concrete3Entity.getKey(), concreteEntity.getProperty("concrete3_id_OID"));
assertEquals(Utils.newArrayList(concrete4aEntity.getKey(), concrete4bEntity.getKey()),
concreteEntity.getProperty("concrete4"));
assertEquals(1, concrete3Entity.getProperties().size());
assertEquals("str3", concrete3Entity.getProperty("str"));
if (getStorageVersion(pm).ordinal() < StorageVersion.READ_OWNED_CHILD_KEYS_FROM_PARENTS.ordinal()) {
assertEquals(2, concrete4aEntity.getProperties().size());
assertEquals("str4a", concrete4aEntity.getProperty("str"));
assertEquals(0L, concrete4aEntity.getProperty("concrete4_INTEGER_IDX"));
assertEquals(2, concrete4bEntity.getProperties().size());
assertEquals("str4b", concrete4bEntity.getProperty("str"));
assertEquals(1L, concrete4bEntity.getProperty("concrete4_INTEGER_IDX"));
} else {
// List index not present with latest storage version
assertEquals(1, concrete4aEntity.getProperties().size());
assertEquals("str4a", concrete4aEntity.getProperty("str"));
assertEquals(1, concrete4bEntity.getProperties().size());
assertEquals("str4b", concrete4bEntity.getProperty("str"));
}
beginTxn();
concrete = pm.getObjectById(concrete.getClass(), concrete.getId());
assertEquals("base 1", concrete.getBase1Str());
assertEquals("base 2", concrete.getBase2Str());
assertEquals("concrete", concrete.getConcrete2Str());
assertEquals(concrete3.getId(), concrete.getConcrete3().getId());
assertEquals(concrete3.getStr(), concrete.getConcrete3().getStr());
assertEquals(2, concrete.getConcrete4().size());
assertEquals(concrete4a.getId(), concrete.getConcrete4().get(0).getId());
assertEquals(concrete4a.getStr(), concrete.getConcrete4().get(0).getStr());
assertEquals(concrete4b.getId(), concrete.getConcrete4().get(1).getId());
assertEquals(concrete4b.getStr(), concrete.getConcrete4().get(1).getStr());
Key concrete4bKey = concrete4b.getId();
concrete.setBase1Str("not base 1");
concrete.setBase2Str("not base 2");
concrete.setConcrete2Str("not concrete");