@Test
public void testEDBObjectToRecursiveModelWithCompositionConversion_shouldWork() throws Exception {

    // prepare
    EDBObject root = new EDBObject("root");
    root.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
    root.putEDBObjectEntry(EDBConstants.MODEL_OID, "root");
    root.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
    root.putEDBObjectEntry("id", "root");
    root.putEDBObjectEntry("children.0", "child1");
    root.putEDBObjectEntry("children.1", "child2");
    EDBObject child1 = new EDBObject("child1");
    child1.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
    child1.putEDBObjectEntry(EDBConstants.MODEL_OID, "child1");
    child1.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
    child1.putEDBObjectEntry("id", "child1");
    child1.putEDBObjectEntry("children.0", "child3");
    child1.putEDBObjectEntry("children.1", "child4");
    EDBObject child2 = new EDBObject("child2");
    child2.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
    child2.putEDBObjectEntry(EDBConstants.MODEL_OID, "child2");
    child2.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
    child2.putEDBObjectEntry("id", "child2");
    EDBObject child3 = new EDBObject("child3");
    child3.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
    child3.putEDBObjectEntry(EDBConstants.MODEL_OID, "child3");
    child3.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
    child3.putEDBObjectEntry("id", "child3");
    EDBObject child4 = new EDBObject("child4");
    child4.putEDBObjectEntry(EDBConstants.MODEL_TYPE, RecursiveModel.class.getName());
    child4.putEDBObjectEntry(EDBConstants.MODEL_OID, "child4");
    child4.putEDBObjectEntry(EDBConstants.MODEL_VERSION, Integer.valueOf(1));
    child4.putEDBObjectEntry("id", "child4");
    when(mockedService.getObject("child1")).thenReturn(child1);
    when(mockedService.getObject("child2")).thenReturn(child2);
    when(mockedService.getObject("child3")).thenReturn(child3);
    when(mockedService.getObject("child4")).thenReturn(child4);
    // test
    RecursiveModel mRoot = converter.convertEDBObjectToModel(RecursiveModel.class, root);
    // assert
    RecursiveModel mChild1;
    RecursiveModel mChild2;
    RecursiveModel mChild3;
    RecursiveModel mChild4;
    List<RecursiveModel> rootChildren;
    List<RecursiveModel> child1Children;
    assertThat(mRoot.getId(), is("root"));
    rootChildren = mRoot.getChildren();
    assertThat(rootChildren, notNullValue());
    assertThat(rootChildren.size(), is(2));
    mChild1 = rootChildren.get(0);
    mChild2 = rootChildren.get(1);
    assertThat(mChild1.getId(), is("child1"));
    assertThat(mChild2.getId(), is("child2"));
    child1Children = mChild1.getChildren();
    assertThat(child1Children, notNullValue());
    assertThat(child1Children.size(), is(2));
    mChild3 = child1Children.get(0);
    mChild4 = child1Children.get(1);
    assertThat(mChild3.getId(), is("child3"));
    assertThat(mChild4.getId(), is("child4"));
}