CmisTestResult f;
int numOfDocuments = 20;
// create a test folder
Folder testFolder = createTestFolder(session);
try {
Map<String, Document> documents = new HashMap<String, Document>();
// create documents
for (int i = 0; i < numOfDocuments; i++) {
Document newDocument = createDocument(session, testFolder, "doc" + i, CONTENT);
documents.put(newDocument.getId(), newDocument);
}
// simple children test
addResult(checkChildren(session, testFolder, "Test folder children check"));
// check if all documents are there
ItemIterable<CmisObject> children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC);
List<String> childrenIds = new ArrayList<String>();
for (CmisObject child : children) {
if (child != null) {
childrenIds.add(child.getId());
Document document = documents.get(child.getId());
f = createResult(FAILURE, "Document and test folder child don't match! Id: " + child.getId());
addResult(assertShallowEquals(document, child, null, f));
}
}
f = createResult(FAILURE, "Number of created folders does not match the number of existing folders!");
addResult(assertEquals(numOfDocuments, childrenIds.size(), null, f));
for (Document document : documents.values()) {
if (!childrenIds.contains(document.getId())) {
addResult(createResult(FAILURE, "Created document not found in test folder children! Id: "
+ document.getId()));
}
}
// check paging
int pageSize = 5;
CmisObject lastObject = null;
int count = 0;
ItemIterable<CmisObject> page1 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME).getPage(
pageSize);
for (CmisObject child : page1) {
count++;
lastObject = child;
}
f = createResult(FAILURE, "Returned number of children doesn't match the page size!");
addResult(assertEquals(pageSize, count, null, f));
count = 0;
ItemIterable<CmisObject> page2 = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME)
.skipTo(pageSize - 1).getPage(pageSize);
for (CmisObject child : page2) {
count++;
if (count == 1) {