// Repeat request until 3 files are found.
FileVersion[] files = null;
for (int i = 0; i < 20; i++) {
LsFolderRequest request = new LsFolderRequest();
LsOperationOptions lsOperationOption = new LsOperationOptions();
request.setId(i);
request.setRoot(clientA.getConfig().getLocalDir().getAbsolutePath());
request.setOptions(lsOperationOption);
eventBus.post(request);
Response response = waitForResponse(i);
assertTrue(response instanceof LsFolderResponse);
LsFolderResponse treeResponse = (LsFolderResponse) response;
files = treeResponse.getResult().getFileTree().values().toArray(new FileVersion[]{});
if (files.length == 2) {
break;
}
if (i == 19) {
assertEquals(2, files.length);
}
else {
Thread.sleep(1000);
}
}
if (files[0].getName().equals("folder")) {
files = new FileVersion[]{files[1], files[0]};
}
assertEquals(clientA.getLocalFile("file-1").getName(), files[0].getName());
assertEquals(clientA.getLocalFile("file-1").length(), (long) files[0].getSize());
assertEquals(clientA.getLocalFile("folder").getName(), files[1].getName());
assertTrue(clientA.getLocalFile("folder").isDirectory());
assertEquals(files[1].getType(), FileVersion.FileType.FOLDER);
// Create GetFileHistoryRequest for the first returned file
GetFileHistoryFolderRequest request = new GetFileHistoryFolderRequest();
request.setId(21);
request.setRoot(clientA.getConfig().getLocalDir().getAbsolutePath());
request.setFileHistoryId(files[0].getFileHistoryId().toString());
eventBus.post(request);
Response response = waitForResponse(21);
assertTrue(response instanceof GetFileHistoryFolderResponse);