AggregateChildModel adam1 = new AggregateChildModel("adam1");
AggregateChildModel adam2 = new AggregateChildModel("adam2");
AggregateChildModel eve = new AggregateChildModel("eve");
AggregateChildModel bob = new AggregateChildModel("bob");
AggregateParentModel god = new AggregateParentModel("god");
god.child.set(adam1);
god.children.asList().addAll(adam2, eve, bob);
god.insert();
assertNotNull(god.id);
assertNotNull(god.child.get().id);
AggregateParentModel god1 =
Model.getByKey(AggregateParentModel.class, god.id);
assertNotNull(god1);
assertEquals(adam1, god1.child.get());
List<AggregateChildModel> children = god1.children.asQuery().fetch();
assertEquals(adam2, children.get(0));
assertEquals(eve, children.get(1));
assertEquals(bob, children.get(2));
// get aggregated one2one
AggregateChildModel adamAfter2 = AggregateChildModel.all().aggregated(god, "child").get();
assertEquals(adam1, adamAfter2);
// get aggregated one2many
children = AggregateChildModel.all().aggregated(god, "children").fetch();
assertEquals(adam2, children.get(0));
assertEquals(eve, children.get(1));
assertEquals(bob, children.get(2));
AggregateParentModel god2 = AggregateParentModel.all().filter("name", "god").get();
assertEquals(adam1, god2.child.get());
children = god2.children.asList();
assertEquals(adam2, children.get(0));
assertEquals(eve, children.get(1));
assertEquals(bob, children.get(2));