@Override
public void run(Session session) {
CmisTestResult f;
// create a test folder
Folder testFolder = createTestFolder(session);
int numOfFolders = 100;
Map<String, Folder> folders = new HashMap<String, Folder>();
String[] propertiesToCheck = new String[] { PropertyIds.OBJECT_ID, PropertyIds.BASE_TYPE_ID,
PropertyIds.OBJECT_TYPE_ID };
// create folders
for (int i = 0; i < numOfFolders; i++) {
Folder newFolder = createFolder(testFolder, "folder" + i);
addResult(checkObject(newFolder, propertiesToCheck,
"New folder object spec compliance. Id: " + newFolder.getId()));
folders.put(newFolder.getId(), newFolder);
}
// simple children test
addResult(checkChildren(session, testFolder, "Test folder children check"));
// check if all folders are there
ItemIterable<CmisObject> children = testFolder.getChildren();
List<String> childrenIds = new ArrayList<String>();
for (CmisObject child : children) {
if (child != null) {
childrenIds.add(child.getId());
Folder folder = folders.get(child.getId());
f = createResult(FAILURE, "Folder and test folder child don't match! Id: " + child.getId());
addResult(assertShallowEquals(folder, child, null, f));
}
}
f = createResult(FAILURE, "Number of created folders does not match the number of existing folders!");
addResult(assertEquals(numOfFolders, childrenIds.size(), null, f));
for (Folder folder : folders.values()) {
if (!childrenIds.contains(folder.getId())) {
addResult(createResult(FAILURE,
"Created folder not found in test folder children! Id: " + folder.getId()));
}
}
// delete all folders
for (Folder folder : folders.values()) {
// empty folders should be deleteable like this
folder.delete(true);
f = createResult(FAILURE, "Folder should not exist anymore but it is still there! Id: " + folder.getId());
addResult(assertIsFalse(exists(folder), null, f));
}
// delete the test folder
deleteTestFolder();