Search in sources :

Example 1 with GetShareNotificationsRequest

use of com.zimbra.soap.mail.message.GetShareNotificationsRequest in project zm-mailbox by Zimbra.

the class TestShareNotifications method waitForShareNotifications.

static List<ShareNotificationInfo> waitForShareNotifications(ZMailbox mbox, int numExpected, int timeout_millis) throws ServiceException {
    int orig_timeout_millis = timeout_millis;
    List<ShareNotificationInfo> shares = Lists.newArrayListWithExpectedSize(0);
    while (timeout_millis > 0) {
        GetShareNotificationsRequest getShareNotificationReq = new GetShareNotificationsRequest();
        GetShareNotificationsResponse sharesResp = mbox.invokeJaxb(getShareNotificationReq);
        assertNotNull("GetShareNotificationsResponse is null", sharesResp);
        shares = sharesResp.getShares();
        if (shares.size() == numExpected) {
            return shares;
        }
        if (shares.size() > numExpected) {
            Assert.fail("Unexpected number of share notifications (" + shares.size() + ")");
        }
        try {
            if (timeout_millis > 100) {
                Thread.sleep(100);
                timeout_millis = timeout_millis - 100;
            } else {
                Thread.sleep(timeout_millis);
                timeout_millis = 0;
            }
        } catch (InterruptedException e) {
            ZimbraLog.test.debug("sleep got interrupted", e);
        }
    }
    if (numExpected > 0) {
        Assert.fail(String.format("Waited for %d share notifications for %d millis. Found %d share notifications", numExpected, orig_timeout_millis, shares.size()));
    }
    return shares;
}
Also used : GetShareNotificationsRequest(com.zimbra.soap.mail.message.GetShareNotificationsRequest) ShareNotificationInfo(com.zimbra.soap.mail.type.ShareNotificationInfo) GetShareNotificationsResponse(com.zimbra.soap.mail.message.GetShareNotificationsResponse)

Aggregations

GetShareNotificationsRequest (com.zimbra.soap.mail.message.GetShareNotificationsRequest)1 GetShareNotificationsResponse (com.zimbra.soap.mail.message.GetShareNotificationsResponse)1 ShareNotificationInfo (com.zimbra.soap.mail.type.ShareNotificationInfo)1