@Test
public void embeddedListToMap() {

    ODocument doc = new ODocument();
    doc.field(DocumentUtil.ORIENTDB_PRIMARY_KEY, "client-assigned-id");
    doc.field("firstname", "John");
    doc.field("lastname", "Doe");
    doc.field("city", new ODocument().field("name","Paris").field("country", "France"));
    List<ODocument> addresses = new ArrayList<ODocument>();
    addresses.add(new ODocument().field("type", "home").field("street", "Main st.").field("city", "San Franciso") );
    addresses.add(new ODocument().field("type", "business").field("street", "Wall st.").field("city", "New York") );
    doc.field("addresses",  addresses, OType.EMBEDDED); 
    
    Map result = DocumentUtil.toMap(doc);
    
    assertThat(result).includes(
            entry(DocumentUtil.TAG_ID, "client-assigned-id"), //"-1:-1"), // ID when doc not yet stored
            entry(DocumentUtil.TAG_REV, "0"), // Doc version starts at 0
            entry("firstname", "John"), 
            entry("lastname", "Doe"));
    Object addrResult = result.get("addresses");
    assertNotNull(addrResult, "addresses map entry null");
    assertThat(addrResult).isInstanceOf(List.class);
    List addr = (List)addrResult;
    assertThat(addr)
            .hasSize(2);
    assertThat(addr.get(0)).isInstanceOf(Map.class);
    Map firstEntry = (Map) addr.get(0); 
    assertThat(firstEntry).includes(
            entry("type", "home"),
            entry("street", "Main st."),
            entry("city", "San Franciso"));
    Map secondEntry = (Map) addr.get(1); 
    assertThat(secondEntry).includes(
            entry("type", "business"),
            entry("street", "Wall st."),
            entry("city", "New York")); 
}