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();
em.persist(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"));
assertEquals(Utils.newArrayList(concrete4aEntity.getKey(), concrete4bEntity.getKey()),
concreteEntity.getProperty("concrete4"));
assertEquals(1, concrete3Entity.getProperties().size());
assertEquals("str3", concrete3Entity.getProperty("str"));
assertEquals(1, concrete4aEntity.getProperties().size());
assertEquals("str4a", concrete4aEntity.getProperty("str"));
assertEquals(1, concrete4bEntity.getProperties().size());
assertEquals("str4b", concrete4bEntity.getProperty("str"));
beginTxn();
concrete = em.find(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());
concrete.setBase1Str("not base 1");
concrete.setBase2Str("not base 2");
concrete.setConcrete2Str("not concrete");
concrete.getConcrete3().setStr("blam3");
concrete.getConcrete4().get(0).setStr("blam4");
commitTxn();
concreteEntity = ds.get(KeyFactory.createKey(kindForObject(concrete), concrete.getId()));
concrete3Entity = ds.get(concrete3.getId());
concrete4aEntity = ds.get(concrete4a.getId());
assertEquals(5, concreteEntity.getProperties().size());
assertEquals("not base 1", concreteEntity.getProperty("base1Str"));
assertEquals("not base 2", concreteEntity.getProperty("base2Str"));
assertEquals("not concrete", concreteEntity.getProperty("concrete2Str"));
assertEquals(concrete3Entity.getKey(), concreteEntity.getProperty("concrete3_id"));
assertEquals(Utils.newArrayList(concrete4aEntity.getKey(), concrete4bEntity.getKey()),
concreteEntity.getProperty("concrete4"));
assertEquals(1, concrete3Entity.getProperties().size());
assertEquals("blam3", concrete3Entity.getProperty("str"));
assertEquals(1, concrete4aEntity.getProperties().size());
assertEquals("blam4", concrete4aEntity.getProperty("str"));
try {
ds.get(concrete4b.getId());
} catch (EntityNotFoundException enfe) {
// good
}
beginTxn();