/// <summary> /// Start workflow task for specified document item and record the task id in order to cleanup the task in test suite clean up process. /// </summary> /// <param name="uploadedFileUrl">A parameter represents a URL of document item where the task starts.</param> /// <param name="isClaim">A parameter represents a Boolean value indicate whether the task is started for Claim usage.</param> /// <returns>A return value represents the id of the task started by this method.</returns> protected string StartATaskWithNewFile(string uploadedFileUrl, bool isClaim) { if (string.IsNullOrEmpty(uploadedFileUrl)) { throw new ArgumentException("Should specify valid value to indicate the URL of a uploaded file", "uploadedFileUrl"); } GetToDosForItemResponseGetToDosForItemResult todosInfo = null; try { XmlElement startWorkFlowData = null; if (isClaim) { startWorkFlowData = this.GetStartWorkflowParameterForClaim(this.Site); } else { string assignToUserValue = Common.GetConfigurationPropertyValue("MSWWSPTestAccount", this.Site); startWorkFlowData = this.GetStartWorkflowParameter(this.Site, assignToUserValue); } Guid currentWorkflowAsscociationId = new Guid(WorkflowAssociationId); ProtocolAdapter.StartWorkflow(uploadedFileUrl, currentWorkflowAsscociationId, startWorkFlowData); todosInfo = ProtocolAdapter.GetToDosForItem(uploadedFileUrl); } catch (SoapException soapEx) { throw new Exception("There are errors generated during start workflow task and GetToDos process.", soapEx); } // Get the task id from the response. there have only one task data in the response, because test suite only start one for new upload file. string taskId = this.GetZrowAttributeValueFromGetToDosForItemResponse(todosInfo, 0, "ows_ID"); if (string.IsNullOrEmpty(taskId)) { this.Site.Assert.Fail("Could Not get the id of started task from the document item[{0}]", uploadedFileUrl); } StartedTaskIdsRecorder.Add(taskId); return(taskId); }
public void MSWWSP_S01_TC01_StartWorkflow_Success() { // Upload a file. string uploadFileUrl = this.UploadFileToSut(DocLibraryName); this.VerifyTaskDataOfNewUploadFile(uploadFileUrl); // Start work flow string assigntoUserName = CurrentProtocolPerformAccountName; XmlElement starworkflowParameter = this.GetStartWorkflowParameter(this.Site, assigntoUserName); Guid targetWorkflowAssociationGuid = new Guid(WorkflowAssociationId); ProtocolAdapter.StartWorkflow(uploadFileUrl, targetWorkflowAssociationGuid, starworkflowParameter); try { ProtocolAdapter.StartWorkflow(uploadFileUrl, targetWorkflowAssociationGuid, starworkflowParameter); } catch (SoapException) { //Verify requirement: MS-WWSP_R327001 Site.CaptureRequirement( 327001, @"[In StartWorkflow] The protocol server MUST NOT start multiple workflow instances of the same item and same workflow association using this operation."); } GetToDosForItemResponseGetToDosForItemResult todosAfterStartTask = ProtocolAdapter.GetToDosForItem(uploadFileUrl); if (null == todosAfterStartTask || null == todosAfterStartTask.ToDoData || null == todosAfterStartTask.ToDoData.xml || null == todosAfterStartTask.ToDoData.xml.data || null == todosAfterStartTask.ToDoData.xml.data.Any) { this.Site.Assert.Fail("The response of GetToDosForItem operation should contain valid data."); } // Record the started tasks string taskId = this.GetZrowAttributeValueFromGetToDosForItemResponse(todosAfterStartTask, 0, "ows_ID"); StartedTaskIdsRecorder.Add(taskId); this.Site.Assert.AreEqual(1, todosAfterStartTask.ToDoData.xml.data.Any.Length, "The response of GetToDosForItem operation for new file should contain only one task data."); assigntoUserName = assigntoUserName.ToLower(); // Get the assign to value from actual response, "ows_AssignedTo" means get required field "AssignedTo" of task list. string actualAssignToValue = Common.GetZrowAttributeValue(todosAfterStartTask.ToDoData.xml.data.Any, 0, "ows_AssignedTo"); this.Site.Assert.IsFalse(string.IsNullOrEmpty(actualAssignToValue), "The response of GetToDosForItem should contain valid value for [AssignedTo] field."); bool isassignToExpectedValue = actualAssignToValue.IndexOf(assigntoUserName, StringComparison.OrdinalIgnoreCase) >= 0; Site.Log.Add( LogEntryKind.Debug, "The actual value: assigntoUserName[{0}], actualAssignToValue[{1}] for requirement #R412, #R324, #R327, #R330, #R339", assigntoUserName, actualAssignToValue); // If start a new workflow instance and assign to expected user, capture #R412, R324, R327, R330, R339 this.Site.CaptureRequirementIfIsTrue( isassignToExpectedValue, 412, @"[In Message Processing Events and Sequencing Rules] StartWorkflow instantiates a new workflow for an existing document and a workflow association."); this.Site.CaptureRequirementIfIsTrue( isassignToExpectedValue, 324, @"[In StartWorkflow] This operation[StartWorkflow] starts a new workflow, generating a workflow from a workflow association."); this.Site.CaptureRequirementIfIsTrue( isassignToExpectedValue, 327, @"[In StartWorkflow] The protocol client sends a StartWorkflowSoapIn request message, and the protocol server responds with a StartWorkflowSoapOut response message."); this.Site.CaptureRequirementIfIsTrue( isassignToExpectedValue, 330, @"[In Messages] StartWorkflowSoapOut specifies the response to a request to start a new workflow."); this.Site.CaptureRequirementIfIsTrue( isassignToExpectedValue, 339, @"[In Elements] StartWorkflowResponse contains the response to a request to start a new workflow."); }