@Test
public void testPrivilegesToJson() {

    List<PrivilegeDefinition> arrDefs =
            JsonCnd.getPrivilegesFromJson(arr("jcr:read", "jcr:write").get(), getMapping());
    assertEquals("arr defs are", arr("jcr:read", "jcr:write").get(),
            JsonCnd.privilegesToJson(arrDefs, getMapping()));
    List<PrivilegeDefinition> objDefs = JsonCnd.getPrivilegesFromJson(obj()
            .key("jcr:canDo", obj())
            .key("jcr:willDo", obj()
                    .key(JsonCnd.PRIVILEGE_KEY_ABSTRACT, false))
            .key("jcr:wouldDoBut", obj()
                    .key(JsonCnd.PRIVILEGE_KEY_ABSTRACT, true))
            .key("jcr:wontDo", null)
            .key("jcr:none", obj()
                    .key(JsonCnd.PRIVILEGE_KEY_CONTAINS, arr()))
            .key("jcr:rw", obj()
                    .key(JsonCnd.PRIVILEGE_KEY_CONTAINS,
                            arr("jcr:read", "jcr:write", "jcr:addChildNodes"))
                    .key(JsonCnd.PRIVILEGE_KEY_ABSTRACT, false))
            .key("jcr:mightRw", obj()
                    .key(JsonCnd.PRIVILEGE_KEY_CONTAINS,
                            arr("jcr:read", "jcr:write", "jcr:removeNode"))
                    .key(JsonCnd.PRIVILEGE_KEY_ABSTRACT, true))
            .get(), getMapping());
    JsonObject expectJson = obj()
            .key("jcr:canDo", obj())
            .key("jcr:mightRw", obj()
                    .key(JsonCnd.PRIVILEGE_KEY_ABSTRACT, true)
                    .key(JsonCnd.PRIVILEGE_KEY_CONTAINS,
                            arr("jcr:read", "jcr:write", "jcr:removeNode")))
            .key("jcr:none", obj())
            .key("jcr:rw", obj()
                    .key(JsonCnd.PRIVILEGE_KEY_CONTAINS,
                            arr("jcr:read", "jcr:write", "jcr:addChildNodes")))
            .key("jcr:willDo", obj())
            .key("jcr:wouldDoBut", obj()
                    .key(JsonCnd.PRIVILEGE_KEY_ABSTRACT, true))
            .get();
    assertEquals("obj defs are", expectJson, JsonCnd.privilegesToJson(objDefs, getMapping()));
}