Search in sources :

Example 1 with GrantGranteeType

use of com.zimbra.soap.type.GrantGranteeType in project zm-mailbox by Zimbra.

the class GetFolderTest method unmarshallGetFolderResponseContainingGrant.

/**
     * Motivated by Bug 55153 failure in ZGrant.java line 134:
     *      mGranteeType = GranteeType.fromString(grant.getGranteeType().toString());
     */
@Test
public void unmarshallGetFolderResponseContainingGrant() throws Exception {
    GetFolderResponse result = (GetFolderResponse) unmarshaller.unmarshal(getClass().getResourceAsStream("GetFolderResponseWithGrant.xml"));
    Folder top = result.getFolder();
    boolean foundGrant = false;
    for (Folder child : top.getSubfolders()) {
        Acl acl = child.getAcl();
        if (acl != null) {
            List<Grant> myGrants = acl.getGrants();
            if (myGrants.size() > 0) {
                foundGrant = true;
                Grant first = myGrants.get(0);
                GrantGranteeType mGranteeType = GrantGranteeType.fromString(first.getGranteeType().toString());
                Assert.assertEquals(GrantGranteeType.usr, mGranteeType);
            }
        }
    }
    Assert.assertTrue("Should have processed a valid <grant>", foundGrant);
    result = (GetFolderResponse) unmarshaller.unmarshal(getClass().getResourceAsStream("GetFolderResponseWithBadGrant.xml"));
    top = result.getFolder();
    foundGrant = false;
    for (Folder child : top.getSubfolders()) {
        Acl acl = child.getAcl();
        if (acl != null) {
            List<Grant> myGrants = acl.getGrants();
            if (myGrants.size() > 0) {
                foundGrant = true;
                Grant first = myGrants.get(0);
                GrantGranteeType mGranteeType = first.getGranteeType();
                Assert.assertNull("There was no 'gt' attribute", mGranteeType);
            }
        }
    }
    Assert.assertTrue("Should have processed a bad <grant>", foundGrant);
}
Also used : Grant(com.zimbra.soap.mail.type.Grant) GetFolderResponse(com.zimbra.soap.mail.message.GetFolderResponse) GrantGranteeType(com.zimbra.soap.type.GrantGranteeType) Acl(com.zimbra.soap.mail.type.Acl) Folder(com.zimbra.soap.mail.type.Folder) SearchFolder(com.zimbra.soap.mail.type.SearchFolder) Test(org.junit.Test)

Aggregations

GetFolderResponse (com.zimbra.soap.mail.message.GetFolderResponse)1 Acl (com.zimbra.soap.mail.type.Acl)1 Folder (com.zimbra.soap.mail.type.Folder)1 Grant (com.zimbra.soap.mail.type.Grant)1 SearchFolder (com.zimbra.soap.mail.type.SearchFolder)1 GrantGranteeType (com.zimbra.soap.type.GrantGranteeType)1 Test (org.junit.Test)1