TestModelDecorator rRoot;
TestModelDecorator rChild1;
TestModelDecorator rChild2;
TestModelDecorator rChild11;
TestModelDecorator rChild12;
SubModelDecorator leaf;
SubModelDecorator rLeaf;
root = getTestModelDecorator();
child1 = getTestModelDecorator();
child2 = getTestModelDecorator();
child11 = getTestModelDecorator();
child12 = getTestModelDecorator();
leaf = getSubModelDecorator();
List<Object> rootChildren = new ArrayList<>();
rootChildren.add(child1.getModel());
rootChildren.add(child2.getModel());
List<Object> child1Children = new ArrayList<>();
child1Children.add(child11.getModel());
child1Children.add(child12.getModel());
root.setEdbId("root");
root.setName("root");
child1.setEdbId("child1");
child1.setName("child1");
child2.setEdbId("child2");
child2.setName("child2");
child11.setEdbId("child11");
child11.setName("child11");
child12.setEdbId("child12");
child12.setName("child12");
leaf.setEdbId("leaf");
leaf.setName("leaf");
child11.setSubModel(leaf.getModel());
child1.setChildren(child1Children);
root.setChildren(rootChildren);
// test
EKBCommit commit = getTestEKBCommit().addInsert(root.getModel());
persist.commit(commit);
rRoot = new TestModelDecorator(query.getModel(getTestModel(), getModelOid("root")));
// assert
assertThat(rRoot.getEdbId(), is("root"));
assertThat(rRoot.getChildren(), notNullValue());
List<?> resultChildren = rRoot.getChildren();
assertThat(resultChildren.size(), is(2));
rChild1 = new TestModelDecorator(resultChildren.get(0));
rChild2 = new TestModelDecorator(resultChildren.get(1));
assertThat(rChild1.getEdbId(), is("child1"));
assertThat(rChild1.getChildren(), notNullValue());
assertThat(rChild2.getEdbId(), is("child2"));
List<Object> rChild1Children = rChild1.getChildren();
assertThat(rChild1Children.size(), is(2));
rChild11 = new TestModelDecorator(rChild1Children.get(0));
rChild12 = new TestModelDecorator(rChild1Children.get(1));
assertThat(rChild11.getEdbId(), is("child11"));
assertThat(rChild12.getEdbId(), is("child12"));
rLeaf = new SubModelDecorator(rChild11.getSubModel());
assertThat(rLeaf.getEdbId(), is("leaf"));
}