public void testAddingObjectToInvalidFolder() { if (!isCapabilityMultifilingEnabled()) { Assert.Skip("Multi-filing capability is not supported! Test will be skipped..."); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), null); try { cmisExtensionType extensions = new cmisExtensionType(); multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.ObjectId, INVALID_OBJECT_ID, false, ref extensions); deleteObjectAndLogIfFailed(document, "Document Object was created but it can't be deleted. Error cause message: "); Assert.Fail("Document Object was added to Inexistent Folder Object"); } catch (Exception e) { deleteAndAssertObject(document, true); if (e is FaultException <cmisFaultType> ) { HashSet <enumServiceException> exceptions = new HashSet <enumServiceException>(); exceptions.Add(enumServiceException.invalidArgument); exceptions.Add(enumServiceException.objectNotFound); assertException((FaultException <cmisFaultType>)e, exceptions); } else { throw e; } } }
public void testChildrenRecevingIncludeRenditions() { if (!isRenditionsEnabled()) { Assert.Skip("Renditions are not supported"); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), null); List <RenditionData> testRenditions = getTestRenditions(document.ObjectId); if (testRenditions == null) { Assert.Skip("No renditions found for document type"); } FileableObject rootFolder = createAndAssertFolder(getAndAssertRootFolder()); ObjectsHierarchy hierarchy = createAndAssertFilesHierarchy(rootFolder, 1, MINIMAL_CHILDREN, MAXIMUM_CHILDREN, enumTypesOfFileableObjects.any); foreach (RenditionData renditionData in testRenditions) { getAndAssertChildren(hierarchy, ANY_PROPERTY_FILTER, 0, MAX_REQUESTED_COUNT, renditionData); } deleteAndAssertHierarchy(hierarchy, enumUnfileObject.delete, true); deleteAndAssertObject(document, true); }
private string createAndAssertObject(bool folder) { string rootFolderId = getAndAssertRootFolder(); FileableObject createdObject = (folder) ? (createAndAssertFolder(rootFolderId)) : (createAndAssertObject(rootFolderId, null)); return(createdObject.ObjectId); }
public void testCheckInAgainstContentStreamAcceptation() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject documentCreator = new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertRootFolder(), getAndAssertDocumentTypeId(), null, enumVersioningState.checkedout, true); string checkedOutDocumentId = createAndAssertObject(documentCreator, false).ObjectId; cmisContentStreamType content = FileableObject.createCmisDocumentContent("test.txt", FileableObject.getContentEtry()); if (!isContentStreamAllowed()) { checkInAndAssertWithExpectedException(getAndAssertRepositoryId(), checkedOutDocumentId, null, null, content, CHECKIN_COMMENT, enumServiceException.streamNotSupported, "Not Allowed Content Stream"); } else { if (!isPwcUpdatable() && isContentStreamRequired()) { HashSet <enumServiceException> expectedExceptions = new HashSet <enumServiceException>(); expectedExceptions.Add(enumServiceException.storage); expectedExceptions.Add(enumServiceException.constraint); checkInAndAssertWithExpectedException(getAndAssertRepositoryId(), checkedOutDocumentId, null, null, null, CHECKIN_COMMENT, expectedExceptions, "Document with Required Content Stream when PWC Updatable capability not supported and Content Stream parameter was not introduced"); } else { checkedOutDocumentId = checkInAndAssert(checkedOutDocumentId, false); } } cancelCheckoutAndDeleteDocumentWithAssertion(checkedOutDocumentId); }
public void testCheckInContentAgainstPwcUpdatableCapability() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } if (!isPwcUpdatable()) { Assert.Skip("PWC is Not Updatable"); } if (!isContentStreamAllowed()) { Assert.Skip("Content Stream is Not Allowed for Document Type"); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.checkedout, false); cmisContentStreamType changedContent = FileableObject.createCmisDocumentContent("Modified.txt", FileableObject.getContentEtry()); string objectId = document.ObjectId; string changeToken = null;// TODO cmisExtensionType extensions = new cmisExtensionType(); objectServiceClient.setContentStream(getAndAssertRepositoryId(), ref objectId, true, ref changeToken, changedContent, ref extensions); document.setId(objectId); document.setId(checkInAndAssert(objectId, true)); cancelCheckoutAndDeleteDocumentWithAssertion(document.ObjectId); }
public void testAddingObjectWithAllVersions() { if (!isCapabilityMultifilingEnabled()) { Assert.Skip("Multi-Filing capability is not supported"); } if (!isVersioningAllowed()) { Assert.Skip("Versioning is not supported for " + getAndAssertDocumentTypeId() + " Document Type"); } MultifiledObject document = createAndAssertMultifilledDocument(getAndAssertRootFolder(), 5); string versionedMultiFilledDocument = createAndAssertVersionedDocument(document.DocumentObject.ObjectId, 5, true); FileableObject folder = createAndAssertFolder(getAndAssertRootFolder()); cmisExtensionType extensions = new cmisExtensionType(); multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.DocumentObject.ObjectId, folder.ObjectId, true, ref extensions); cmisObjectInFolderListType children = getAndAssertChildren(folder.ObjectId, "*", null, 10L, 0L, null); if (!isVersionSpecificFiling()) { logger.log("Children were received. Version Specific Filing is not supported. 5 Versions were created for document"); Assert.AreEqual(1, children.objects.Length, "Amount of Children more than 1"); } else { logger.log("Children were received. Version Specific Filing is supported. 5 Versions were created for document"); Assert.IsTrue((6 == children.objects.Length), "Amount of Children is not equal to 6"); } deleteAndAssertObject(versionedMultiFilledDocument, true); deleteAndAssertObject(folder, false); foreach (CmisObject parent in document.Parents) { deleteAndAssertObject(parent, false); } }
public void testQueryPWCSearchable() { if (enumCapabilityQuery.none.Equals(getQueryAllowed()) || enumCapabilityQuery.fulltextonly.Equals(getQueryAllowed())) { throw new SkippedException("Metadata query isn't supported"); } if (!isVersioningAllowed() || !isPWCSearchable()) { Assert.Skip("Versioning isn't supported or PWCSearchable is not supported"); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.checkedout, false); string query = "SELECT * FROM " + getAndAssertDocumentQueryName() + " WHERE " + OBJECT_IDENTIFIER_PROPERTY + "='" + document.ObjectId + "'"; cmisObjectType[] response = executeAndAssertQuery(query, PAGE_SIZE, 0, false, false, enumIncludeRelationships.none); Assert.IsNotNull(response, "response is null"); Assert.IsTrue((response.Length >= 1), "Expected PWC was not found"); bool found = false; foreach (cmisObjectType cmisObject in response) { string objectId = (string)searchAndAssertPropertyByName(cmisObject.properties.Items, OBJECT_IDENTIFIER_PROPERTY, false); if (document.ObjectId.Equals(objectId)) { found = true; } } Assert.IsTrue(found, "WorkingCopy was not found in query results"); cmisExtensionType extension = new cmisExtensionType(); versioningServiceClient.cancelCheckOut(getAndAssertRepositoryId(), document.ObjectId, ref extension); }
public void testGetContentChangesForUpdate() { if (getCapabilityChanges().Equals(enumCapabilityChanges.none)) { throw new SkippedException("Content Changes Capability is not supported"); } //TODO: Change document creation to default versioning state after versioning problem will be fixed FileableObject currentObject = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.none); string changeLogToken = getAndAssertRepositoryInfo().latestChangeLogToken; logger.log("[ObjectService->updateProperties]"); string changeToken = ""; string objectId = currentObject.ObjectId; currentObject.addProperty(NAME_PROPERTY, FileableObject.generateObjectName(false, DateTime.Now.Ticks.ToString())); object property = currentObject.removeProperty(TYPE_ID_PROPERTY); cmisExtensionType extension = new cmisExtensionType(); objectServiceClient.updateProperties(getAndAssertRepositoryId(), ref objectId, ref changeToken, currentObject.getObjectProperties(false), ref extension); cmisObjectListType response = receiveAndAssertContentChanges(ref changeLogToken, null); assertContentChanges(response, objectId, enumTypeOfChanges.updated); deleteAndAssertObject(objectId); }
public void getAndAssertChildren(string filter, int skipCount, int maxItems) { FileableObject rootFolder = createAndAssertFolder(getAndAssertRootFolder()); ObjectsHierarchy hierarchy = createAndAssertFilesHierarchy(rootFolder, 1, MINIMAL_CHILDREN, MAXIMUM_CHILDREN, enumTypesOfFileableObjects.any); getAndAssertChildren(hierarchy, filter, skipCount, maxItems, null); deleteAndAssertHierarchy(hierarchy, enumUnfileObject.delete, true); }
private FileableObject[] prepareTestData(int count) { FileableObject[] result = new FileableObject[count]; for (int i = 0; i < count; ++i) { result[i] = createAndAssertObject(getAndAssertRootFolder(), null); } return(result); }
private void assertFolderParentReceiving() { FileableObject rootFolder = createAndAssertFolder(getAndAssertRootFolder()); ObjectsHierarchy hierarchy = createAndAssertFilesHierarchy(rootFolder, 1, 1, 1, enumTypesOfFileableObjects.folders); string[] createdObjectsIds = hierarchy.toIdsArray(); assertFolderParents(createdObjectsIds[createdObjectsIds.Length - 1], new string[] { rootFolder.ObjectId }, false); deleteAndAssertHierarchy(hierarchy, enumUnfileObject.delete, true); }
private void getAndAssertDescedansts(enumTypesOfFileableObjects type, int depth, string filter, enumVersioningState versioningState) { FileableObject rootFolder = createAndAssertFolder(getAndAssertRootFolder()); TreeNode <string> objectsTree = createObjectsTree(rootFolder.ObjectId, versioningState, type, FOLDERS_DEPTH, MINIMAL_CHILDREN, MAXIMUM_CHILDREN, depth); getAndAssertDescedansts(rootFolder, objectsTree, type, depth, filter, versioningState, null); objectServiceClient.deleteTree(getAndAssertRepositoryId(), rootFolder.ObjectId, true, enumUnfileObject.delete, true, null); }
public void testReceivingPropertiesOfFolderObject() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject folder = createAndAssertFolder(getAndAssertRootFolder()); assertLatestVersionPropertiesReceivingWithExcpectedException(getAndAssertRepositoryId(), folder.ObjectId, ANY_PROPERTY_FILTER, false, enumServiceException.invalidArgument, "Folder Object Id"); deleteAndAssertObject(folder, false); }
public void testDocumentCheckoutingAndCheckoutCanceling() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), null, false); cancelCheckOutAndAssert(checkOutAndAssert(document.ObjectId, document.ObjectTypeId, document.ContentStream.stream)); deleteAndAssertObject(document, true); }
public void testAllVersionsReceivingFromFolderObject() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject folder = createAndAssertFolder(getAndAssertRootFolder()); assertAllVersionsReceivingWithExpectedException(getAndAssertRepositoryId(), folder.ObjectId, ANY_PROPERTY_FILTER, false, null, "Folder Object Id"); deleteAndAssertObject(folder, false); }
public void testFilteringOfLatestVersionPropertiesReceiving() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } string filter = OBJECT_IDENTIFIER_PROPERTY + "," + TYPE_ID_PROPERTY + "," + NAME_PROPERTY; FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.major, false); getAndAssertLatestVersionProperties(document.ObjectId, filter, true); deleteAndAssertObject(document, true); }
private void assertObjectParentsReceiving() { FileableObject rootFolder = createAndAssertFolder(getAndAssertRootFolder()); ObjectsHierarchy hierarchy = createAndAssertFilesHierarchy(rootFolder, 1, 2, 3, enumTypesOfFileableObjects.documents); string[] createdObjectsIds = hierarchy.toIdsArray(); foreach (string objectId in createdObjectsIds) { assertDocumentParents(objectId, new string[] { rootFolder.ObjectId }); } deleteAndAssertHierarchy(hierarchy, enumUnfileObject.delete, true); }
public void testLatestVersionPropertiesReceivingWithAndWithoutMajorVersion() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.minor, false); assertLatestVersionPropertiesReceivingWithExcpectedException(getAndAssertRepositoryId(), document.ObjectId, ANY_PROPERTY_FILTER, true, enumServiceException.objectNotFound, "Major parameter equal to 'true' and without Major Version in Verions Series"); document.setId(createAndAssertVersionedDocument(document.ObjectId, 3, true)); getAndAssertLatestVersionProperties(document.ObjectId, ANY_PROPERTY_FILTER, true); deleteAndAssertObject(document.ObjectId); }
public void testInvalidRepositoryIdUsing() { if (!isCapabilityMultifilingEnabled()) { Assert.Skip("Multi-filling is not supported. Test will be skipped..."); } string rootFolderId = getAndAssertRootFolder(); MultifiledObject document = createAndAssertMultifilledDocument(rootFolderId, 2); FileableObject folder = createAndAssertFolder(rootFolderId); logger.log("Invalid Repository Id using for Add Object To Folder service"); cmisExtensionType extensions = new cmisExtensionType(); try { multifilingServiceClient.addObjectToFolder(INVALID_REPOSITORY_ID, document.DocumentObject.ObjectId, folder.ObjectId, false, ref extensions); deleteMultiFilledDocumentAndLogIfFailed(document, "Multi-filled Document was created but it can't be deleted. Error cause message: "); deleteObjectAndLogIfFailed(folder, "Folder was created but it can't be deleted. Error cause message: "); Assert.Fail("Document Object was moved ignoring Invalid Repository Id"); } catch (Exception e) { deleteAndAssertObject(folder, true); if (e is FaultException <cmisFaultType> ) { assertException((FaultException <cmisFaultType>)e, enumServiceException.invalidArgument); } else { throw e; } } logger.log("Invalid Repository Id using for Remove Object From Folder service"); try { multifilingServiceClient.removeObjectFromFolder(INVALID_REPOSITORY_ID, document.DocumentObject.ObjectId, document.Parents[0].ObjectId, ref extensions); deleteMultiFilledDocumentAndLogIfFailed(document, "Document was created but it can't be deleted. Error cause message: "); Assert.Fail("Document Object was moved ignoring Invalid Repository Id"); } catch (Exception e) { if (e is FaultException <cmisFaultType> ) { assertException((FaultException <cmisFaultType>)e, enumServiceException.invalidArgument); } else { throw e; } } }
public void testNotCheckedOutDocumentCheckOutCancelling() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), null, false); HashSet <enumServiceException> expectedExceptions = new HashSet <enumServiceException>(); expectedExceptions.Add(enumServiceException.versioning); expectedExceptions.Add(enumServiceException.updateConflict); cancelCheckoutAndAssertWithExpectedException(getAndAssertRepositoryId(), document.ObjectId, expectedExceptions, "Not Checked Out Object Id"); deleteAndAssertObject(document, true); }
public void testAddingObjectToFolderConstraintsObservance() { if (!isCapabilityMultifilingEnabled()) { Assert.Skip("Multi-filing capability is not supported! Test will be skipped..."); } string folderTypeWithAllowedList = searchForFolderTypeWithAllowingList(getAndAssertRootFolder()); FileableObject folder = (null == folderTypeWithAllowedList) ? (null) : (createAndAssertObject(true, getAndAssertRootFolder(), folderTypeWithAllowedList)); if (!isValueNotSet(folder)) { string[] allowedTypeIds = (string[])searchAndAssertPropertyByName(getAndAssertObjectProperties(folder.ObjectId, folder, true).Items, ALLOWED_CHILDREN_TYPE_IDS, true); cmisTypeContainer[] typeDefs = getAndAssertTypeDescendants(getAndAssertBaseDocumentTypeId(), -1, true); string notAllowedDocumentTypeId = enumerateAndAssertTypesForAction(typeDefs, new SearchForNotAllowedDocumentTypeIdAction(allowedTypeIds), true); if (!isValueNotSet(notAllowedDocumentTypeId)) { FileableObject document = createAndAssertObject(false, getAndAssertRootFolder(), notAllowedDocumentTypeId); try { cmisExtensionType extensions = new cmisExtensionType(); multifilingServiceClient.addObjectToFolder(getAndAssertRepositoryId(), document.ObjectId, folder.ObjectId, false, ref extensions); deleteObjectAndLogIfFailed(document, ("Document with Restricted by " + folderTypeWithAllowedList + " Folder Object Type Id was created but it can't be deleted. Error cause message: ")); deleteObjectAndLogIfFailed(folder, ("Folder Object with " + folderTypeWithAllowedList + " Type Id was created but it can't be deleted. Error cause message: ")); Assert.Fail("Object was added to Folder that is not Allow Children Objects with " + notAllowedDocumentTypeId + " Type Id"); } catch (Exception e) { try { deleteAndAssertObject(document, true); } catch (Exception e1) { deleteAndAssertObject(folder, true); throw e1; } if (e is FaultException <cmisFaultType> ) { assertException((FaultException <cmisFaultType>)e, enumServiceException.constraint); } else { throw e; } } } deleteAndAssertObject(folder, true); } }
public void testCheckoutingOfCheckedOutDocument() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.major, false); string documentId = document.ObjectId; string checkedoutDocumentId = checkOutAndAssert(documentId, document.ObjectTypeId, document.ContentStream.stream); HashSet <enumServiceException> expectedExceptions = new HashSet <enumServiceException>(); expectedExceptions.Add(enumServiceException.storage); expectedExceptions.Add(enumServiceException.versioning); checkoutAndAssertWithExpectedException(getAndAssertRepositoryId(), checkedoutDocumentId, true, expectedExceptions, "Already Checked Out Document Id"); }
public void testCheckIn() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject documentCreator = new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertRootFolder(), getAndAssertDocumentTypeId(), null, enumVersioningState.checkedout, true); string documentId = createAndAssertObject(documentCreator, false).ObjectId; documentId = checkInAndAssert(documentId, false); documentId = checkOutAndAssert(documentId, documentCreator.ObjectTypeId, checkinContentEntry); documentCreator.setId(documentId); documentId = checkInAndAssert(documentId, true); deleteAndAssertObject(documentId); }
public void testNotCheckedOutObjectCheckining() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), null, false); cmisContentStreamType content = null; if (!isPwcUpdatable() && isContentStreamRequired()) { content = FileableObject.createCmisDocumentContent("test.txt", FileableObject.getContentEtry()); } checkInAndAssertWithExpectedException(getAndAssertRepositoryId(), document.ObjectId, null, null, null, CHECKIN_COMMENT, null, "Not Checked Out Document Id"); deleteAndAssertObject(document, true); }
public void testDocumentCheckoutingForNotAllowedVersioning() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } string notVersionalbeTypeId = enumerateAndAssertTypesForAction(getAndAssertTypeDescendants(getAndAssertBaseDocumentTypeId(), -1, false), new NotVersionableDocumentTypeSearcher(), true); if (isValueNotSet(notVersionalbeTypeId)) { Assert.Skip("Not Versionable Document Type was not found"); } FileableObject document = createAndAssertObject(false, getAndAssertRootFolder(), notVersionalbeTypeId, false); checkoutAndAssertWithExpectedException(getAndAssertRepositoryId(), document.ObjectId, true, enumServiceException.constraint, "Not Allowed Versioning capability"); deleteAndAssertObject(document, true); }
public void testContentCopiedCheckOutResult() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject document = new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertDocumentTypeId(), getAndAssertRootFolder()); document.WithoutContentStream = true; document = createAndAssertObject(document, false); cancelCheckOutAndAssert(checkOutAndAssert(document.ObjectId, document.ObjectTypeId, FileableObject.getContentEtry())); deleteAndAssertObject(document, true); document.WithoutContentStream = false; document = (FileableObject)document.createObject(true, true, document.ObjectParentId, document.ObjectTypeId); cancelCheckOutAndAssert(checkOutAndAssert(document.ObjectId, document.ObjectTypeId, document.ContentStream.stream)); deleteAndAssertObject(document, true); }
public void testInvalidObjectCheckining() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } cmisContentStreamType content = null; if (!isPwcUpdatable() && isContentStreamRequired()) { content = FileableObject.createCmisDocumentContent("test.txt", FileableObject.getContentEtry()); } HashSet <enumServiceException> expectedExceptions = new HashSet <enumServiceException>(); expectedExceptions.Add(enumServiceException.invalidArgument); expectedExceptions.Add(enumServiceException.objectNotFound); checkInAndAssertWithExpectedException(getAndAssertRepositoryId(), INVALID_OBJECT_ID, null, null, content, null, expectedExceptions, "Invalid Object Id"); }
public void testQueryFullText() { if (enumCapabilityQuery.none.Equals(getQueryAllowed()) || enumCapabilityQuery.metadataonly.Equals(getQueryAllowed())) { Assert.Skip("Full-Text query isn't supported"); } string name = FileableObject.generateObjectName(false, "TextSearch"); string content = getRandomLiteralString(7) + " " + getRandomLiteralString(5); cmisContentStreamType contentStremType = FileableObject.createCmisDocumentContent(name, Encoding.GetEncoding(FileableObject.DEFAULT_ENCODING).GetBytes(content)); FileableObject documentCreator = new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertDocumentTypeId(), getAndAssertRootFolder()); documentCreator.ContentStream = contentStremType; createAndAssertObject(documentCreator); string query = "SELECT * FROM " + getAndAssertDocumentQueryName() + " WHERE CONTAINS('" + content + "')"; executeAndAssertQuery(query, PAGE_SIZE, 0, false, false, enumIncludeRelationships.none); deleteAndAssertObject(documentCreator.ObjectId); }
public void testInvalidRepositoryIdUsing() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject document = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.major, false); string documentId = document.ObjectId; checkoutAndAssertWithExpectedException(INVALID_REPOSITORY_ID, documentId, true, enumServiceException.invalidArgument, "Invalid Repository Id"); FileableObject checkedOutDocument = createAndAssertObject(getAndAssertRootFolder(), enumVersioningState.checkedout, false); cancelCheckoutAndAssertWithExpectedException(INVALID_REPOSITORY_ID, checkedOutDocument.ObjectId, enumServiceException.invalidArgument, "Invalid Repository Id"); cancelCheckoutAndDeleteDocumentWithAssertion(checkedOutDocument.ObjectId); checkInAndAssertWithExpectedException(INVALID_REPOSITORY_ID, checkedOutDocument.ObjectId, false, null, null, CHECKIN_COMMENT, enumServiceException.invalidArgument, "Invalid Repository Id"); assertLatestVersionPropertiesReceivingWithExcpectedException(INVALID_REPOSITORY_ID, documentId, ANY_PROPERTY_FILTER, false, enumServiceException.invalidArgument, "Invalid Repository Id"); assertAllVersionsReceivingWithExpectedException(INVALID_REPOSITORY_ID, documentId, ANY_PROPERTY_FILTER, false, enumServiceException.invalidArgument, "Invalid Repository Id"); deleteAndAssertObject(document, true); }
// TODO: policies // TODO: addACEs // TODO: removeACEs public void testLatestVersionPropertiesReceiving() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject documentCreator = new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertRootFolder(), getAndAssertDocumentTypeId(), null, enumVersioningState.major, true); string documentId = createAndAssertObject(documentCreator, false).ObjectId; documentId = createAndAssertVersionedDocument(documentId, 6, true); cmisPropertiesType initialMajorVersionProperties = getAndAssertLatestVersionProperties(documentId, ANY_PROPERTY_FILTER, true); documentId = createAndAssertVersionedDocument(documentId, 7, false); getAndAssertLatestVersionProperties(documentId, ANY_PROPERTY_FILTER, true); cmisPropertiesType secondMajorVersionProperties = getAndAssertLatestVersionProperties(documentId, ANY_PROPERTY_FILTER, true); assertValuesEquality(NAME_PROPERTY, searchAndAssertPropertyByName(initialMajorVersionProperties.Items, NAME_PROPERTY, false), searchAndAssertPropertyByName(secondMajorVersionProperties.Items, NAME_PROPERTY, false)); assertValuesEquality(MAJOR_VERSION_PROPERTY, searchAndAssertPropertyByName(initialMajorVersionProperties.Items, MAJOR_VERSION_PROPERTY, false), searchAndAssertPropertyByName(secondMajorVersionProperties.Items, MAJOR_VERSION_PROPERTY, false)); deleteAndAssertObject(documentId, true); }
public override void initialize(string testName) { if (arePoliciesAllowed()) { string typeId = getAndAssertPolicyControllableTypeId(); if (null != typeId) { cmisExtensionType extension = new cmisExtensionType(); cmisPropertiesType properties = FileableObject.addPropertyToObject(null, NAME_PROPERTY, FileableObject.generateObjectName(true, "Policy")); FileableObject.addPropertyToObject(properties, TYPE_ID_PROPERTY, getAndAssertPolicyTypeId()); policyId = objectServiceClient.createPolicy(getAndAssertRepositoryId(), properties, getAndAssertRootFolder(), null, null, null, ref extension); } if (null != typeId) { cmisTypeDefinitionType typeDefinition = getAndAssertTypeDefinition(typeId); policyControllableObject = createAndAssertObject(typeDefinition is cmisTypeFolderDefinitionType, getAndAssertRootFolder(), typeId); } else { policyControllableObject = createAndAssertObject(getAndAssertRootFolder(), null); } } }
protected static void assertProperties(FileableObject expectedProperties, cmisPropertiesType properties) { cmisObjectType cmisObject = new cmisObjectType(); cmisObject.properties = properties; assertObject(expectedProperties, cmisObject, false, enumIncludeRelationships.none); }
public void tryAddObject(FileableObject newObject) { bool allowed = !isValueNotSet(newObject) && ((enumTypesOfFileableObjects.any == allowedObjects) || (newObject.IsFolder && (enumTypesOfFileableObjects.folders == allowedObjects)) || (!newObject.IsFolder && (enumTypesOfFileableObjects.documents == allowedObjects))); if (allowed) { objects.Add(newObject); objectsIds.Add(newObject.ObjectId); if (newObject.IsFolder) { folderIds.Add(newObject.ObjectId); } else { documentIds.Add(newObject.ObjectId); } } }
public RelationshipObject(string objectParentId, string objectTypeId, FileableObject sourceObject, FileableObject targetObject) : base(enumTypesOfFileableObjects.relationships, objectParentId, objectTypeId) { this.sourceObject = sourceObject; this.targetObject = targetObject; }
protected static FileableObject createAndAssertObject(FileableObject creator, bool validate) { creator = (FileableObject)creator.createObject(true); try { if (validate) { getAndAssertObjectProperties(creator.ObjectId, creator, true); } } catch (Exception e) { if (isValueNotSet(creator.ObjectId)) { Assert.Fail("Object was not created. Error cause message: " + e.Message); } else { Assert.Fail("Newly created Object with Id='" + creator.ObjectId + "' has invalid Properties set. Error cause message: " + e.Message); } } return creator; }
public CmisObject createObject(FileableObject sourceObject, FileableObject targetObject) { this.sourceObject = sourceObject; this.targetObject = targetObject; return createObject(false, false, ObjectParentId, ObjectTypeId); }
protected static void assertObject(FileableObject expectedProperties, cmisObjectType actualObject, bool includeAllowableActions, enumIncludeRelationships relationshipsType) { Assert.IsFalse(isValueNotSet(actualObject), "Returned Object is undefined"); Assert.IsFalse(isValueNotSet(actualObject.properties), "Properties of returned Object are undefined"); Assert.IsFalse(isValueNotSet(actualObject.properties.Items), "Properties of returned Object are empty"); object propertyValue = searchAndAssertPropertyByName(actualObject.properties.Items, NAME_PROPERTY, false); Assert.AreEqual(expectedProperties.ObjectName, propertyValue, ("Object Name Property value differs to Property value returned with Get Properties Response. Expected: " + expectedProperties.ObjectName + ", actual: " + propertyValue)); propertyValue = searchAndAssertPropertyByName(actualObject.properties.Items, TYPE_ID_PROPERTY, false); Assert.AreEqual(expectedProperties.ObjectTypeId, propertyValue, ("Object Type Id Property value differs to Property value returned with Get Properties Response. Expected: " + expectedProperties.ObjectName + ", actual: " + propertyValue)); propertyValue = searchAndAssertPropertyByName(actualObject.properties.Items, OBJECT_IDENTIFIER_PROPERTY, false); Assert.AreEqual(expectedProperties.ObjectId, propertyValue, ("Expected Object Id='" + expectedProperties.ObjectId + "' is not equal to actual Object Id='" + propertyValue + "'")); //TODO: uncomment when problem will be found //assertActualVersioningState(actualObject.properties, expectedProperties.InitialVersion); if (includeAllowableActions) { Assert.IsNotNull(actualObject.allowableActions, "Allowable Actions was not returned in Get Object Properties response"); Assert.IsTrue(!isValueNotSet(actualObject.allowableActions.canGetProperties) && actualObject.allowableActions.canGetProperties, ("Properties of Object with id='" + expectedProperties.ObjectId + "' Reading is not allowed but Properties were returned")); logger.log("Allowable actions were checked successfully"); } else { Assert.IsTrue(isValueNotSet(actualObject.allowableActions), "Allowable Actions were not requested but were returned in response of Get Properties"); } assertRelationships(expectedProperties.ObjectId, actualObject.relationship, relationshipsType); logger.log("Relationships for " + relationshipsType + " direction were checked successfully"); }
private void removeTestData(FileableObject[] ids) { foreach (FileableObject id in ids) { deleteAndAssertObject(id.ObjectId); } }
public ObjectsHierarchy(FileableObject rootFolder, enumTypesOfFileableObjects allowedObjects) { this.allowedObjects = allowedObjects; hierarchyRootFolder = rootFolder; }
protected string createAndAssertVersionedDocument(string existentDocument, int versionsAmount, bool finishWithMajor) { string versionedDocumentId = existentDocument; byte[] contentEntry = null; bool createNew = isValueNotSet(existentDocument); FileableObject documentCreator = null; string name = null; if (createNew) { logger.log("Creating versioned Document object with " + versionsAmount + " versions"); documentCreator = new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertRootFolder(), getAndAssertDocumentTypeId(), null, null, false); versionedDocumentId = createAndAssertObject(documentCreator).ObjectId; contentEntry = documentCreator.ContentStream.stream; name = documentCreator.ObjectName; } else { logger.log("Creating " + versionsAmount + " versions for existent document. Document id = " + existentDocument); cmisPropertiesType properties = getAndAssertObjectProperties(existentDocument, null, false); name = (string)searchAndAssertPropertyByName(properties.Items, NAME_PROPERTY, false); if (isContentStreamAllowed()) { cmisContentStreamType contentStream = receiveAndAssertContentStream(existentDocument, null); contentEntry = (!isValueNotSet(contentStream)) ? (contentStream.stream) : (null); } documentCreator = new FileableObject(enumTypesOfFileableObjects.documents, (string)searchAndAssertPropertyByName(properties.Items, TYPE_ID_PROPERTY, false), null, properties, null, false); documentCreator.setId(existentDocument); } for (int i = 0; i < versionsAmount; i++) { versionedDocumentId = checkOutAndAssert(versionedDocumentId, documentCreator.ObjectTypeId, contentEntry); documentCreator.setId(versionedDocumentId); versionedDocumentId = checkInAndAssert(versionedDocumentId, (finishWithMajor && ((versionsAmount - 1) == i))); contentEntry = checkinContentEntry; } if (createNew) { logger.log("New versioned document was successfully created. Versioned document id = " + versionedDocumentId); } else { logger.log(versionsAmount + " verstions was/were successfully created for Document. Source document id = " + existentDocument + ". Versioned document id = " + versionedDocumentId); } return versionedDocumentId; }
public MultifiledObject createAndAssertMultifilledDocument(string primaryParentId, int parentsAmount) { FileableObject document = createAndAssertObject(new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertDocumentTypeId(), primaryParentId)); FileableObject[] parents = new FileableObject[parentsAmount]; logger.log("Adding parents for document, documentId='" + document.ObjectId + "'"); string repositoryId = getAndAssertRepositoryId(); for (int i = 0; i < parentsAmount; i++) { parents[i] = createAndAssertObject(new FileableObject(enumTypesOfFileableObjects.folders, getAndAssertFolderTypeId(), primaryParentId)); logger.log("[MultiFilingService->addObjectToFolder]"); logger.log("Adding Parent for Document, documentId='" + document.ObjectId + "',parentId='" + parents[i].ObjectId + "'"); try { cmisExtensionType extension = new cmisExtensionType(); multifilingServiceClient.addObjectToFolder(repositoryId, document.ObjectId, parents[i].ObjectId, false, ref extension); } catch (System.Exception e) { Assert.Fail("Adding Parent for Document with Id=" + document.ObjectId + " was failed. Error: " + e.Message); } logger.log(""); } logger.log("Parents were successfully added"); return new MultifiledObject(document, parents); }
public void testCheckInAgainstContentStreamAcceptation() { if (!isVersioningAllowed()) { Assert.Skip(VERSIONING_NOT_SUPPORTTED_MESSAGE); } FileableObject documentCreator = new FileableObject(enumTypesOfFileableObjects.documents, getAndAssertRootFolder(), getAndAssertDocumentTypeId(), null, enumVersioningState.checkedout, true); string checkedOutDocumentId = createAndAssertObject(documentCreator, false).ObjectId; cmisContentStreamType content = FileableObject.createCmisDocumentContent("test.txt", FileableObject.getContentEtry()); if (!isContentStreamAllowed()) { checkInAndAssertWithExpectedException(getAndAssertRepositoryId(), checkedOutDocumentId, null, null, content, CHECKIN_COMMENT, enumServiceException.streamNotSupported, "Not Allowed Content Stream"); } else { if (!isPwcUpdatable() && isContentStreamRequired()) { HashSet<enumServiceException> expectedExceptions = new HashSet<enumServiceException>(); expectedExceptions.Add(enumServiceException.storage); expectedExceptions.Add(enumServiceException.constraint); checkInAndAssertWithExpectedException(getAndAssertRepositoryId(), checkedOutDocumentId, null, null, null, CHECKIN_COMMENT, expectedExceptions, "Document with Required Content Stream when PWC Updatable capability not supported and Content Stream parameter was not introduced"); } else { checkedOutDocumentId = checkInAndAssert(checkedOutDocumentId, false); } } cancelCheckoutAndDeleteDocumentWithAssertion(checkedOutDocumentId); }
public static cmisPropertiesType getAndAssertObjectProperties(string objectId, string filter, FileableObject expectedProperties, bool assertResults) { logger.log("[ObjectService->getProperties]"); logger.log("Getting properties for object, objectId='" + objectId); cmisPropertiesType result = objectServiceClient.getProperties(getAndAssertRepositoryId(), objectId, filter, null); if (assertResults) { assertProperties(expectedProperties, result); } if (!isValueNotSet(result) && !isValueNotSet(result.Items)) { logger.log("Properties were received. Properties amount=" + result.Items.Length); } else { logger.log("Properties are empty"); } logger.log(""); return result; }
private FileableObject[] prepareTestData(int count) { FileableObject[] result = new FileableObject[count]; for (int i = 0; i < count; ++i) { result[i] = createAndAssertObject(getAndAssertRootFolder(), null); } return result; }
public static cmisPropertiesType getAndAssertObjectProperties(string objectId, FileableObject expectedProperties, bool assertResults) { return getAndAssertObjectProperties(objectId, ANY_PROPERTY_FILTER, expectedProperties, assertResults); }
public ObjectsHierarchy createAndAssertFilesHierarchy(FileableObject rootFolder, int depth, int minimalChildrenAmount, int maximumChildrenAmount, enumTypesOfFileableObjects allowedObjects) { if ((depth <= 0) || (maximumChildrenAmount <= 0) || (minimalChildrenAmount > maximumChildrenAmount)) { logger.log("Invalid linear parameter(s) for Hierarchy were specified. Expected: depth > 0; maximumChildrenAmount > 0; minimalChildrenAmount <= maximumChildrenAmount. Hierarchy can't be created"); return null; } logger.log("Creating objects hierarchy. Depth=" + depth + ", Root Folder Id='" + rootFolder.ObjectId + "', Allowed Objects Type='" + allowedObjects + "'"); ObjectsHierarchy hierarchy = new ObjectsHierarchy(rootFolder, allowedObjects); List<FileableObject> folders = new List<FileableObject>(); folders.Add(rootFolder); Random randomCounter = new Random(); for (int i = 0; i < depth; i++) { List<FileableObject> nextLayerFolders = new List<FileableObject>(); int requiredFolderContainerNumber = randomCounter.Next(folders.Count); int currentObjectNumber = 0; foreach (FileableObject currentLevelFolder in folders) { int maximum = calculateMaximumChildrenAmount(randomCounter, minimalChildrenAmount, maximumChildrenAmount); int foldersMaximum = randomCounter.Next(Convert.ToInt32(Math.Round(Math.Sqrt(maximum))) + 1); foldersMaximum = ((0 >= foldersMaximum) && (i < (depth - 1)) && (currentObjectNumber++ == requiredFolderContainerNumber)) ? (1) : (foldersMaximum); for (int j = 0; j < maximum; j++) { bool folder = (enumTypesOfFileableObjects.folders == allowedObjects) || ((enumTypesOfFileableObjects.any == allowedObjects) && (j < foldersMaximum)); string objectTypeId = (folder) ? (getAndAssertFolderTypeId()) : (getAndAssertDocumentTypeId()); FileableObject currentObject = createAndAssertObject(folder, currentLevelFolder.ObjectId, objectTypeId); hierarchy.tryAddObject(currentObject); if (folder) { nextLayerFolders.Add(currentObject); } } } folders = nextLayerFolders; } logger.log(hierarchy.getObjectsAmount() + " Object(s) were included to Hierarchy successfully"); logger.log(""); return hierarchy; }
public MultifiledObject(FileableObject documentObject, FileableObject[] parents) { this.documentObject = documentObject; this.parents = parents; }
public void assertCheckedOutDocument(string documentId, string objectTypeId, byte[] expectedContent, bool copied) { Assert.IsNotNull(documentId, "PWC Id is undefined"); if (!isValueNotSet(expectedContent)) { cmisContentStreamType contentStream = receiveAndAssertContentStream(documentId, expectedContent, true, null); if (isValueNotSet(contentStream)) { Assert.IsFalse(copied, (CHECKOUT_RESULT_AND_CONTENT_STATE_MESSAGE + "Content marked as Copied but actually it was not setted to PWC Object")); } else { Assert.IsTrue(copied, (CHECKOUT_RESULT_AND_CONTENT_STATE_MESSAGE + "Content marked as Not Copied but actually it was setted to PWC Object")); } } FileableObject expectedObject = new FileableObject(enumTypesOfFileableObjects.documents, objectTypeId, (string)null); expectedObject.InitialVersion = enumVersioningState.checkedout; cmisPropertiesType properties = getAndAssertObjectProperties(documentId, expectedObject, false); object property = searchAndAssertPropertyByName(properties.Items, CHECKED_OUT_PROPERTY, false); Assert.IsTrue(!isValueNotSet(property) && (bool)property, "Checked Out Document has Checked Out Property that equal to 'false'"); }
protected static FileableObject createAndAssertObject(FileableObject creator) { return createAndAssertObject(creator, true); }
public void deleteAndAssertFolder(FileableObject folderObject, bool notEmptyBehaviour) { deleteAndAssertFolder(folderObject.ObjectId, notEmptyBehaviour); }