protected Folder createFolder(Session session, Folder parent, String name, String objectTypeId) {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
Folder result = null;
try {
// create the folder
result = parent.createFolder(properties, null, null, null, SELECT_ALL_NO_CACHE_OC);
} catch (CmisBaseException e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Folder could not be created! Exception: " + e.getMessage(),
e, true));
}
try {
// check the new folder
String[] propertiesToCheck = new String[result.getType().getPropertyDefinitions().size()];
int i = 0;
for (String propId : result.getType().getPropertyDefinitions().keySet()) {
propertiesToCheck[i++] = propId;
}
addResult(checkObject(session, result, propertiesToCheck, "New folder object spec compliance"));
// check object parents
List<Folder> objectParents = result.getParents();
CmisTestResult f = createResult(FAILURE, "Newly created folder has no or more than one parent! Id: "
+ result.getId(), true);
addResult(assertEquals(1, objectParents.size(), null, f));
f = createResult(FAILURE, "First object parent of the newly created folder does not match parent! Id: "
+ result.getId(), true);
assertShallowEquals(parent, objectParents.get(0), null, f);
// check folder parent
Folder folderParent = result.getFolderParent();
f = createResult(FAILURE, "Newly created folder has no folder parent! Id: " + result.getId(), true);
addResult(assertNotNull(folderParent, null, f));
f = createResult(FAILURE,
"Folder parent of the newly created folder does not match parent! Id: " + result.getId(), true);