public void testAggregateMostSimpleManual() {
AggregateParentManualModel god = new AggregateParentManualModel("god");
god.insert();
assertNotNull(god.id);
AggregateChildManualModel adam1 = new AggregateChildManualModel(123L, "adam1");
adam1.aggregate(god, "child");
adam1.insert();
AggregateChildManualModel adam2 = new AggregateChildManualModel(0L, "adam2");
adam2.aggregate(god, "children");
adam2.insert();
AggregateChildManualModel eve = new AggregateChildManualModel(1L, "eve");
eve.aggregate(god, "children");
eve.insert();
AggregateChildManualModel bob = new AggregateChildManualModel(2L, "bob");
bob.aggregate(god, "children");
bob.insert();
AggregateChildManualModel adam1After = AggregateChildManualModel.all().aggregated(god, "child").get();
assertEquals(adam1, adam1After);
List<AggregateChildManualModel> children = AggregateChildManualModel.all().aggregated(god, "children").fetch();
assertEquals(adam2, children.get(0));
assertEquals(eve, children.get(1));
assertEquals(bob, children.get(2));
AggregateChildManualModel adam1After2 = AggregateChildManualModel.all().aggregated(god, "child").filter("id", 123L).get();
assertEquals(adam1, adam1After2);
AggregateChildManualModel eveAfter = AggregateChildManualModel.all().aggregated(god, "children").filter("id", 1L).get();
assertEquals(eve, eveAfter);
eveAfter.name+="_UPD";
eveAfter.update();
AggregateChildManualModel eveAfter2 = AggregateChildManualModel.all().aggregated(god, "children").filter("id", 1L).get();
assertEquals(eveAfter, eveAfter2);
eveAfter2.name+="_UPD2";
eveAfter2.save();
AggregateChildManualModel eveAfter3 = AggregateChildManualModel.all().aggregated(god, "children").filter("id", 1L).get();
assertEquals(eveAfter2, eveAfter3);
}