use of com.zimbra.soap.mail.message.GetShareNotificationsResponse 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;
}
Aggregations