use of com.zimbra.soap.mail.type.Grant 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);
}
Aggregations