use of com.zimbra.client.ZMailbox.ZImportStatus in project zm-mailbox by Zimbra.
the class TestUtil method importDataSource.
/**
* Imports data from the given data source and updates state on both the local and remote mailboxes.
*/
public static void importDataSource(ZDataSource dataSource, ZMailbox localMbox, ZMailbox remoteMbox, boolean expectedSuccess) throws Exception {
List<ZDataSource> dataSources = new ArrayList<ZDataSource>();
dataSources.add(dataSource);
localMbox.importData(dataSources);
String type = dataSource.getType().toString();
// Wait for import to complete
ZImportStatus status;
while (true) {
Thread.sleep(500);
status = null;
for (ZImportStatus iter : localMbox.getImportStatus()) {
if (iter.getId().equals(dataSource.getId())) {
status = iter;
}
}
assertNotNull("No import status returned for data source " + dataSource.getName(), status);
assertEquals("Unexpected data source type", type, status.getType());
if (!status.isRunning()) {
break;
}
}
assertEquals("importDataSource status success value", expectedSuccess, status.getSuccess());
if (!expectedSuccess) {
assertNotNull("importDataSource status error value", status.getError());
}
// Get any state changes from the server
localMbox.noOp();
if (remoteMbox != null) {
remoteMbox.noOp();
}
}
Aggregations