Ejemplo n.º 1
0
        public ObservableList <RQMExecutionRecord> GetExecutionRecordsByTestPlan(LoginDTO loginData, XmlReader reader, RQMProject currentRQMProjectMapping, string currentProjPrefix, string currentProjGuid, string testPlanURLPathVersioned)
        {
            ObservableList <RQMExecutionRecord> RQMExecutionRecords = new ObservableList <RQMExecutionRecord>();

            RqmResponseData responseDataExecutionRecords = RQMRep.GetExecutionByTestPlan(loginData, currentProjPrefix, currentProjGuid, testPlanURLPathVersioned);
            XmlDocument     docExecutionRecords          = new XmlDocument();

            docExecutionRecords.LoadXml(responseDataExecutionRecords.responseText.ToString());
            XmlNamespaceManager nsmgrExecutionRecords = new XmlNamespaceManager(reader.NameTable);

            currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrExecutionRecords.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName));
            XmlNode     responseDataNodeExecutionRecords = docExecutionRecords.DocumentElement;
            XmlNodeList executionRecords = responseDataNodeExecutionRecords.SelectNodes(currentRQMProjectMapping.RQMExecutionRecordsMapping.PathXML, nsmgrExecutionRecords);

            foreach (XmlNode executionRecord in executionRecords)
            {
                try
                {
                    string          curentExecutionRecordUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RelatedTestCaseUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString();
                    RqmResponseData responseDataVersionedTC  = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordUri));
                    XmlDocument     docVersionedTC           = new XmlDocument();
                    docVersionedTC.LoadXml(responseDataVersionedTC.responseText.ToString());
                    XmlNode responseDataNodeVersionedTC = docVersionedTC.DocumentElement;

                    RqmResponseData responseDataVersionedTS;
                    try
                    {
                        string curentExecutionRecordScriptUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.ExecutesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString();
                        responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri));
                    }
                    catch
                    {
                        string curentExecutionRecordScriptUri = responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.UsesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString();
                        responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri));
                    }
                    XmlDocument docVersionedTS = new XmlDocument();
                    docVersionedTS.LoadXml(responseDataVersionedTS.responseText.ToString());
                    XmlNode responseDataNodeVersionedTS = docVersionedTS.DocumentElement;

                    if (RQMExecutionRecords.Where(x => x.RQMID == executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString()).ToList().Count == 0)
                    {
                        RQMExecutionRecord rQMExecutionRecord = new RQMExecutionRecord(executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString(),
                                                                                       responseDataNodeVersionedTS.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestScriptXmlPathToID, nsmgrExecutionRecords).InnerText.ToString(),
                                                                                       responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestCaseXmlPathToID, nsmgrExecutionRecords).InnerText.ToString());

                        RQMExecutionRecords.Add(rQMExecutionRecord);
                    }
                }
                catch { }
            }
            return(RQMExecutionRecords);
        }
Ejemplo n.º 2
0
        private ExecutionResult GetExeResultforAg(BusinessFlow businessFlow, string bfExportedID, ActivitiesGroup activGroup, ref string result, RQMTestPlan testPlan)
        {
            try
            {
                LoginDTO loginData = new LoginDTO()
                {
                    User = ALMCore.AlmConfig.ALMUserName, Password = ALMCore.AlmConfig.ALMPassword, Server = ALMCore.AlmConfig.ALMServerURL
                };

                if (string.IsNullOrEmpty(activGroup.ExternalID))
                {
                    result = "At " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + businessFlow.Name + " " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup) + ", is missing ExternalID, cannot export RQM TestPlan execution results without External ID";
                    return(null);
                }

                ExecutionResult exeResult = new ExecutionResult {
                    TestPlanExportID = bfExportedID
                };

                List <Activity> relevantActivities = new List <Activity>();
                relevantActivities      = businessFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.FileName).ToList();
                exeResult.ExecutionStep = new List <ExecutionStep>();

                string txExportID = GetExportedIDString(activGroup.ExternalID, "RQMID");
                string tsExportID = GetExportedIDString(activGroup.ExternalID, "RQMScriptID");
                string erExportID = GetExportedIDString(activGroup.ExternalID, "RQMRecordID");
                if ((activGroup.TestSuiteId != null) && (activGroup.TestSuiteId != string.Empty))
                {
                    // check if test suite execution record is exists per current Test Suite ID
                    // if not exists to create it and than procced to work on just created
                    RQMTestSuite testSuite = testPlan.TestSuites.Where(z => z.RQMID == activGroup.TestSuiteId).FirstOrDefault();
                    if ((testSuite != null) && (testSuite.RQMID != null) && (testSuite.URLPathVersioned != null) &&
                        (testSuite.RQMID != string.Empty) && (testSuite.URLPathVersioned != string.Empty))
                    {
                        try
                        {
                            ResultInfo resultInfo;
                            // check if execution record of testSuite exist. If not - to create it
                            if ((testSuite.TestSuiteExecutionRecord == null) || (testSuite.TestSuiteExecutionRecord.RQMID == null) || (testSuite.TestSuiteExecutionRecord.URLPathVersioned == string.Empty))
                            {
                                testSuite.ACL_TestSuite_Copy = new TestSuite();
                                testSuite.ACL_TestSuite_Copy.TestSuiteName     = testSuite.Name;
                                testSuite.ACL_TestSuite_Copy.TestSuiteExportID = testSuite.RQMID;
                                resultInfo = RQMConnect.Instance.RQMRep.CreateTestSuiteExecutionRecord(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, testSuite.ACL_TestSuite_Copy, bfExportedID, businessFlow.Name.ToString());

                                if (resultInfo.IsSuccess)
                                {
                                    if (testSuite.TestSuiteExecutionRecord == null)
                                    {
                                        testSuite.TestSuiteExecutionRecord = new RQMTestSuiteExecutionRecord();
                                    }
                                    testSuite.TestSuiteExecutionRecord.RQMID            = testSuite.ACL_TestSuite_Copy.TestSuiteExecutionRecordExportID;
                                    testSuite.TestSuiteExecutionRecord.URLPathVersioned = testSuite.ACL_TestSuite_Copy.TestSuiteExecutionRecordExportUri;
                                }
                            }
                            else
                            {
                                testSuite.ACL_TestSuite_Copy = new TestSuite();
                                testSuite.ACL_TestSuite_Copy.TestSuiteName     = testSuite.Name;
                                testSuite.ACL_TestSuite_Copy.TestSuiteExportID = testSuite.RQMID;
                                testSuite.ACL_TestSuite_Copy.TestSuiteExecutionRecordExportID  = testSuite.TestSuiteExecutionRecord.RQMID;
                                testSuite.ACL_TestSuite_Copy.TestSuiteExecutionRecordExportUri = testSuite.TestSuiteExecutionRecord.URLPathVersioned;
                            }

                            // after creating of execution record at RQM and as object at Ginger (or checking that it's exists)
                            // need to create testsuiteLOG on it and add test caseexecution records on it Ginger (the objects at RQM will be created after loop)
                            ACL_Data_Contract.Activity currentActivity = GetTestCaseFromActivityGroup(activGroup);
                            resultInfo = RQMConnect.Instance.RQMRep.CreateExecutionRecordPerActivityWithInTestSuite(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, currentActivity, bfExportedID, businessFlow.Name, testSuite.Name.ToString());
                            if (resultInfo.IsSuccess)
                            {
                                if ((testSuite.TestSuiteExecutionRecord.TestSuiteResults == null) || (testSuite.TestSuiteExecutionRecord.TestSuiteResults.Count == 0) || (testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult == null))
                                {
                                    testSuite.TestSuiteExecutionRecord.TestSuiteResults       = new ObservableList <RQMTestSuiteResults>();
                                    testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult = new RQMTestSuiteResults();
                                    testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.RQMExecutionRecords = new ObservableList <RQMExecutionRecord>();
                                    testSuite.TestSuiteExecutionRecord.TestSuiteResults.Add(testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult);
                                }

                                RQMExecutionRecord executionRecord = new RQMExecutionRecord(currentActivity.ExportedTcExecutionRecId.ToString(), currentActivity.ExportedTestScriptId.ToString(), currentActivity.ExportedID.ToString());
                                testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.RQMExecutionRecords.Add(executionRecord);
                                testSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.ACL_TestSuiteLog_Copy.TestSuiteLogExecutionRecords.Add(exeResult);
                                exeResult.ExpectedResultName = currentActivity.EntityName;
                                erExportID = executionRecord.RQMID;
                                currentActivity.ExportedID = long.Parse(executionRecord.RQMID);

                                string atsID = GetExportedIDString(activGroup.ExternalID, "AtsID");
                                if (atsID == "0")
                                {
                                    atsID = string.Empty;
                                }
                                activGroup.ExternalID = "RQMID=" + txExportID + "|RQMScriptID=" + tsExportID + "|RQMRecordID=" + erExportID + "|AtsID=" + atsID;
                            }
                        }
                        catch { }
                    }
                    else
                    {
                    }
                }
                else if (string.IsNullOrEmpty(erExportID) || erExportID.Equals("0") || !testPlan.RQMExecutionRecords.Select(z => z.RQMID).ToList().Contains(erExportID))
                {
                    ResultInfo resultInfo;
                    ACL_Data_Contract.Activity currentActivity = GetTestCaseFromActivityGroup(activGroup);
                    try
                    {
                        // check if executionRecordID exist in RQM but still was not updated in business flow XML
                        RQMExecutionRecord currentExecutionRecord = testPlan.RQMExecutionRecords.Where(y => y.RelatedTestCaseRqmID == txExportID && y.RelatedTestScriptRqmID == tsExportID).ToList().FirstOrDefault();
                        if (currentExecutionRecord != null)
                        {
                            erExportID = currentExecutionRecord.RQMID;
                        }
                        else
                        {
                            // if executionRecord not updated and not exists - so create one in RQM and update BussinesFlow object (this may be not saved due not existed "autosave" functionality)
                            resultInfo = RQMConnect.Instance.RQMRep.CreateExecutionRecordPerActivity(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, currentActivity, bfExportedID, businessFlow.Name);
                            if (!currentActivity.ExportedTcExecutionRecId.Equals("0"))
                            {
                                string atsID = GetExportedIDString(activGroup.ExternalID, "AtsID");
                                if (atsID == "0")
                                {
                                    atsID = string.Empty;
                                }
                                erExportID            = currentActivity.ExportedTcExecutionRecId.ToString();
                                activGroup.ExternalID = "RQMID=" + txExportID + "|RQMScriptID=" + tsExportID + "|RQMRecordID=" + erExportID + "|AtsID=" + atsID;
                                ;
                            }
                        }
                    }
                    catch
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to create Execution Record Per Activity - " + currentActivity.EntityName);
                    }
                }
                if (string.IsNullOrEmpty(txExportID) || string.IsNullOrEmpty(tsExportID) || string.IsNullOrEmpty(erExportID) || txExportID.Equals("0") || tsExportID.Equals("0") || erExportID.Equals("0"))
                {
                    result = "At " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + businessFlow.Name + " " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup) + ", is missing ExternalID, cannot export RQM TestPlan execution results without Extrnal ID";
                    return(null);
                }
                exeResult.TestCaseExportID        = txExportID;
                exeResult.TestScriptExportID      = tsExportID;
                exeResult.ExecutionRecordExportID = erExportID;

                int i = 1;
                foreach (Activity act in relevantActivities)
                {
                    ExecutionStep exeStep = new ExecutionStep
                    {
                        StepExpResults = act.Expected,
                        StepOrderId    = i,
                        EntityDesc     = act.ActivityName,
                    };
                    i++;

                    switch (act.Status)
                    {
                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed:
                        exeStep.StepStatus = ACL_Data_Contract.ExecutoinStatus.Failed;
                        string     errors     = string.Empty;
                        List <Act> failedActs = act.Acts.Where(x => x.Status == Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed).ToList();
                        foreach (Act action in failedActs)
                        {
                            errors += action.Error + Environment.NewLine;
                        }
                        exeStep.StepActualResult = errors;
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.Passed;
                        exeStep.StepActualResult = "Passed as expected";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.NA:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.NA;
                        exeStep.StepActualResult = "NA";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.In_Progress;
                        exeStep.StepActualResult = "Was not executed";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Running:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.In_Progress;
                        exeStep.StepActualResult = "Not Completed";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.Outscoped;
                        exeStep.StepActualResult = "Skipped";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Blocked:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.Blocked;
                        exeStep.StepActualResult = "Blocked";
                        break;

                    case Amdocs.Ginger.CoreNET.Execution.eRunStatus.Stopped:
                        exeStep.StepStatus       = ACL_Data_Contract.ExecutoinStatus.Inconclusive;
                        exeStep.StepActualResult = "Stopped";
                        break;
                    }
                    exeResult.ExecutionStep.Add(exeStep);
                }
                return(exeResult);
            }
            catch (Exception ex)
            {
                result = "Unexpected error occurred- " + ex.Message;
                Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to RQM/ALM", ex);
                return(null);
            }
        }
Ejemplo n.º 3
0
        public ObservableList <RQMExecutionRecord> GetTestSuiteCurrentResult(LoginDTO loginData, XmlReader reader, RQMProject currentRQMProjectMapping, string currentProjPrefix, string currentProjGuid, string currentTestSuiteResultUri)
        {
            if ((currentTestSuiteResultUri == null) || (currentTestSuiteResultUri == string.Empty))
            {
                return(null);
            }

            ObservableList <RQMExecutionRecord> RQMExecutionRecords = new ObservableList <RQMExecutionRecord>();

            RqmResponseData responseDataCurrentTestSuiteResult = RQMRep.GetRqmResponse(loginData, new Uri(currentTestSuiteResultUri));
            XmlDocument     docTestSuiteResult = new XmlDocument();

            docTestSuiteResult.LoadXml(responseDataCurrentTestSuiteResult.responseText.ToString());
            XmlNamespaceManager nsmgrTestSuiteResult = new XmlNamespaceManager(reader.NameTable);

            currentRQMProjectMapping.RQMTestSuiteResultsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTestSuiteResult.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName));
            XmlNode     responseTestSuiteResult = docTestSuiteResult.DocumentElement;
            XmlNodeList executionRecordsURIs    = responseTestSuiteResult.SelectNodes(currentRQMProjectMapping.RQMTestSuiteResultsMapping.XMLPathToResultsExecutionRecordsList, nsmgrTestSuiteResult);

            XmlNamespaceManager nsmgrExecutionRecords = new XmlNamespaceManager(reader.NameTable);

            currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrExecutionRecords.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName));

            foreach (XmlNode executionRecordURI in executionRecordsURIs)
            {
                try
                {
                    RqmResponseData responseDataExecutionRecord = RQMRep.GetRqmResponse(loginData, new Uri(executionRecordURI.Attributes[0].InnerText.ToString()));
                    XmlDocument     docExecutionRecords         = new XmlDocument();
                    docExecutionRecords.LoadXml(responseDataExecutionRecord.responseText.ToString());
                    XmlNode responseDataNodeExecutionRecord = docExecutionRecords.DocumentElement;
                    XmlNode executionRecord = responseDataNodeExecutionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.XMLPathOfSingleSelectionCase, nsmgrExecutionRecords);

                    string          curentExecutionRecordVersionedTCUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RelatedTestCaseUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString();
                    RqmResponseData responseDataVersionedTC             = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordVersionedTCUri));
                    XmlDocument     docVersionedTC = new XmlDocument();
                    docVersionedTC.LoadXml(responseDataVersionedTC.responseText.ToString());
                    XmlNode responseDataNodeVersionedTC = docVersionedTC.DocumentElement;

                    RqmResponseData responseDataVersionedTS;
                    try
                    {
                        string curentExecutionRecordScriptUri = executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.ExecutesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString();
                        responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri));
                    }
                    catch
                    {
                        string curentExecutionRecordScriptUri = responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.UsesTestScriptUri, nsmgrExecutionRecords).Attributes[0].InnerText.ToString();
                        responseDataVersionedTS = RQMRep.GetRqmResponse(loginData, new Uri(curentExecutionRecordScriptUri));
                    }
                    XmlDocument docVersionedTS = new XmlDocument();
                    docVersionedTS.LoadXml(responseDataVersionedTS.responseText.ToString());
                    XmlNode responseDataNodeVersionedTS = docVersionedTS.DocumentElement;

                    if (RQMExecutionRecords.Where(x => x.RQMID == executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString()).ToList().Count == 0)
                    {
                        RQMExecutionRecord rQMExecutionRecord = new RQMExecutionRecord(executionRecord.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.RQMID, nsmgrExecutionRecords).InnerText.ToString(),
                                                                                       responseDataNodeVersionedTS.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestScriptXmlPathToID, nsmgrExecutionRecords).InnerText.ToString(),
                                                                                       responseDataNodeVersionedTC.SelectSingleNode(currentRQMProjectMapping.RQMExecutionRecordsMapping.VersioinedTestCaseXmlPathToID, nsmgrExecutionRecords).InnerText.ToString());

                        RQMExecutionRecords.Add(rQMExecutionRecord);
                    }
                }
                catch { }
            }

            return(RQMExecutionRecords);
        }