Пример #1
0
        public bool ExportExecutionDetailsToRQM(BusinessFlow businessFlow, ref string result, bool exectutedFromAutomateTab = false, PublishToALMConfig publishToALMConfig = null)
        {
            result = string.Empty;
            string bfExportedID = GetExportedIDString(businessFlow.ExternalID, "RQMID");

            if (string.IsNullOrEmpty(bfExportedID) || bfExportedID.Equals("0"))
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + businessFlow.Name + " is missing ExternalID, cannot export RQM TestPlan execution results without Extrnal ID";
                return(false);
            }

            if (businessFlow.ActivitiesGroups.Count == 0)
            {
                result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + businessFlow.Name + " Must have at least one " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup);
                return(false);
            }

            LoginDTO loginData = new LoginDTO()
            {
                User = ALMCore.AlmConfig.ALMUserName, Password = ALMCore.AlmConfig.ALMPassword, Server = ALMCore.AlmConfig.ALMServerURL
            };

            //
            // get data about execution records per current test plan - start
            RQMTestPlan testPlan             = new RQMTestPlan();
            string      importConfigTemplate = System.IO.Path.Combine(RQMCore.ConfigPackageFolderPath, "RQM_Import", "RQM_ImportConfigs_Template.xml");

            if (File.Exists(importConfigTemplate))
            {
                XmlSerializer serializer = new
                                           XmlSerializer(typeof(RQMProjectListConfiguration));
                FileStream fs     = new FileStream(importConfigTemplate, FileMode.Open);
                XmlReader  reader = XmlReader.Create(fs);
                RQMProjectListConfiguration RQMProjectList;
                RQMProjectList = (RQMProjectListConfiguration)serializer.Deserialize(reader);
                fs.Close();

                RQMProject currentRQMProjectMapping;
                if (RQMProjectList.RQMProjects.Count > 0)
                {
                    currentRQMProjectMapping = RQMProjectList.RQMProjects.Where(x => x.Name == ALMCore.AlmConfig.ALMProjectName || x.Name == "DefaultProjectName").FirstOrDefault();
                    if (currentRQMProjectMapping != null)
                    {
                        testPlan = RQMConnect.Instance.GetRQMTestPlanByIdByProject(ALMCore.AlmConfig.ALMServerURL, ALMCore.AlmConfig.ALMUserName, ALMCore.AlmConfig.ALMPassword, ALMCore.AlmConfig.ALMProjectName, GetExportedIDString(businessFlow.ExternalID, "RQMID"));

                        if (testPlan == null)
                        {
                            result = "Recent Testing Plan not exists in connected RQM project.";
                            return(false);
                        }

                        testPlan.RQMExecutionRecords = RQMConnect.Instance.GetExecutionRecordsByTestPlan(loginData, reader, currentRQMProjectMapping, RQMCore.ALMProjectGroupName, RQMCore.ALMProjectGuid, testPlan.URLPathVersioned);
                    }
                }
            }
            // get data about execution records per current test plan - finish

            List <ExecutionResult> exeResultList = new List <ExecutionResult>();

            foreach (ActivitiesGroup activGroup in businessFlow.ActivitiesGroups)
            {
                if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == ActivitiesGroup.eActivitiesGroupRunStatus.Passed) ||
                    (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == ActivitiesGroup.eActivitiesGroupRunStatus.Failed) ||
                    publishToALMConfig.FilterStatus == FilterByStatus.All)
                {
                    ExecutionResult exeResult = GetExeResultforAg(businessFlow, bfExportedID, activGroup, ref result, testPlan);
                    if (exeResult != null)
                    {
                        exeResultList.Add(exeResult);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            ResultInfo resultInfo = new ResultInfo();

            //
            // Updating of Execution Record Results (test plan level)
            try
            {
                resultInfo = RQMConnect.Instance.RQMRep.ExportExecutionResult(loginData, exeResultList, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName);
            }
            catch
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to Update Execution Record Results");
            }

            //
            // Creating Test Suite Log (per test suite)
            try
            {
                foreach (RQMTestSuite rQMTestSuite in testPlan.TestSuites)
                {
                    if ((rQMTestSuite.ACL_TestSuite_Copy != null) && (rQMTestSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.ACL_TestSuiteLog_Copy != null))
                    {
                        resultInfo = RQMConnect.Instance.RQMRep.CreateTestSuiteLog(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, rQMTestSuite.ACL_TestSuite_Copy, rQMTestSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.ACL_TestSuiteLog_Copy);
                    }
                }
            }
            catch
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to Update Execution Record Results");
            }

            //
            // Attaching of Activity Groups Reports
            try
            {
                // Attach ActivityGroup Report if needed
                if ((publishToALMConfig.ToAttachActivitiesGroupReport) || (exectutedFromAutomateTab))
                {
                    foreach (ActivitiesGroup activGroup in businessFlow.ActivitiesGroups)
                    {
                        try
                        {
                            ACL_Data_Contract.Activity   currentActivity  = GetTestCaseFromActivityGroup(activGroup);
                            ACL_Data_Contract.Attachment reportAttachment = new ACL_Data_Contract.Attachment();
                            string activityGroupName = PathHelper.CleanInValidPathChars(activGroup.Name);
                            if ((activGroup.TempReportFolder != null) && (activGroup.TempReportFolder != string.Empty) &&
                                (System.IO.Directory.Exists(activGroup.TempReportFolder)))
                            {
                                //Creating the Zip file - start
                                string targetZipPath = System.IO.Directory.GetParent(activGroup.TempReportFolder).ToString();
                                string zipFileName   = targetZipPath + "\\" + activityGroupName.ToString().Replace(" ", "_") + "_GingerHTMLReport.zip";
                                if (!System.IO.File.Exists(zipFileName))
                                {
                                    ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                }
                                else
                                {
                                    System.IO.File.Delete(zipFileName);
                                    ZipFile.CreateFromDirectory(activGroup.TempReportFolder, zipFileName);
                                }
                                System.IO.Directory.Delete(activGroup.TempReportFolder, true);
                                //Creating the Zip file - finish

                                //Attaching Zip file - start
                                reportAttachment.ClientFileName = activityGroupName.ToString().Replace(" ", "_") + "_GingerHTMLReport.zip";
                                reportAttachment.ServerLocation = targetZipPath + @"\" + reportAttachment.ClientFileName;
                                reportAttachment.CreatedBy      = Environment.UserName;
                                currentActivity.EntityId        = Convert.ToInt32(GetExportedIDString(activGroup.ExternalID.ToString(), "RQMID"));
                                currentActivity.ExportedID      = (long)currentActivity.EntityId;
                                currentActivity.ActivityData.AttachmentsColl = new Attachments();
                                currentActivity.ActivityData.AttachmentsColl.Add(reportAttachment);

                                string exportJarFilePath = Assembly.GetExecutingAssembly().Location.Replace(@"GingerCore.dll", "") + @"ALM\\RQM\\JAVA";
                                resultInfo = RQMConnect.Instance.RQMRep.UploadAttachmetToRQMAndGetIds(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, currentActivity, exportJarFilePath);

                                resultInfo = RQMConnect.Instance.RQMRep.UpdateTestCaseWithNewAttachmentID(loginData, RQMCore.ALMProjectGuid, ALMCore.AlmConfig.ALMProjectName, RQMCore.ALMProjectGroupName, currentActivity);

                                //Attaching Zip file - finish
                                System.IO.File.Delete(zipFileName);
                            }
                        }
                        catch
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Failed to attach report Per ActivityGroup - " + activGroup.Name);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                resultInfo.ErrorCode = 1;
                result = e.ToString();
            }

            if (resultInfo.ErrorCode == 0)
            {
                result = "Export execution details to RQM performed successfully.";
                return(true);
            }
            else
            {
                result = resultInfo.ErrorDesc;
            }

            Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to RQM/ALM");
            return(false);
        }
Пример #2
0
        public RQMTestPlan GetRQMTestPlanFullData(string RQMServerUrl, string RQMUserName, string RQMPassword, string RQMProject, RQMTestPlan testPlan)
        {
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            string importConfigTemplate = System.IO.Path.Combine(RQMCore.ConfigPackageFolderPath, "RQM_Import", "RQM_ImportConfigs_Template.xml");

            if (File.Exists(importConfigTemplate))
            {
                XmlSerializer serializer = new
                                           XmlSerializer(typeof(RQMProjectListConfiguration));

                FileStream fs     = new FileStream(importConfigTemplate, FileMode.Open);
                XmlReader  reader = XmlReader.Create(fs);
                RQMProjectListConfiguration RQMProjectList;
                RQMProjectList = (RQMProjectListConfiguration)serializer.Deserialize(reader);
                fs.Close();

                RQMProject currentRQMProjectMapping;
                if (RQMProjectList.RQMProjects.Count > 0)
                {
                    currentRQMProjectMapping = RQMProjectList.RQMProjects.Where(x => x.Name == RQMProject || x.Name == "DefaultProjectName").FirstOrDefault();
                    if (currentRQMProjectMapping != null)
                    {
                        //
                        // building a list of TestCases
                        LoginDTO loginData = new LoginDTO()
                        {
                            User = RQMUserName, Password = RQMPassword, Server = RQMServerUrl
                        };
                        IProjectData rqmProjectsData = RQMRep.GetVisibleProjects(loginData);
                        rqmProjectsDataList = rqmProjectsData.IProjectDefinitions;
                        IProjectDefinitions currentProj = rqmProjectsDataList.Where(x => x.ProjectName == RQMProject).FirstOrDefault();

                        RqmResponseData responseData = RQMRep.GetRqmResponse(loginData, new Uri(testPlan.URLPath));
                        XmlDocument     docTP        = new XmlDocument();
                        docTP.LoadXml(responseData.responseText.ToString());
                        XmlNamespaceManager nsmgrTP = new XmlNamespaceManager(reader.NameTable);
                        currentRQMProjectMapping.RQMTestPlanMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTP.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName));
                        XmlNode responseDataNode = docTP.DocumentElement;

                        testPlan.Description = responseDataNode.SelectSingleNode(currentRQMProjectMapping.RQMTestPlanMapping.Description, nsmgrTP).InnerText.ToString();

                        // Building execution Results Dictionary - start
                        // - execution records that are seating on Test Plan
                        testPlan.RQMExecutionRecords = GetExecutionRecordsByTestPlan(loginData, reader, currentRQMProjectMapping, currentProj.Prefix, currentProj.Guid, testPlan.URLPathVersioned);

                        // building test cases lists of TestSuits (not on TestPlan)
                        // test suites should be created already by function GetRQMTestPlanByIdByProject()
                        // this is only enhancement that will add to them test cases and some values like description and so on
                        XmlNodeList testSuites = responseDataNode.SelectNodes(currentRQMProjectMapping.RQMTestPlanMapping.PathXMLToTestSuitesLists, nsmgrTP);
                        foreach (XmlNode testSuite in testSuites)
                        {
                            RqmResponseData responseDataTestSuite = RQMRep.GetRqmResponse(loginData, new Uri(testSuite.Attributes[0].InnerText.ToString()));
                            XmlDocument     docTestSuite          = new XmlDocument();
                            docTestSuite.LoadXml(responseDataTestSuite.responseText.ToString());
                            XmlNamespaceManager nsmgrTS = new XmlNamespaceManager(reader.NameTable);
                            currentRQMProjectMapping.RQMTestSuiteMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTS.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName));
                            XmlNode responseDataNodeTestSuite = docTestSuite.DocumentElement;

                            ObservableList <RQMTestCase> currentSuiteTestCases = BuildRQMTestCaseList(responseDataNodeTestSuite.SelectNodes(currentRQMProjectMapping.RQMTestSuiteMapping.PathXML, nsmgrTS), nsmgrTS, loginData, currentRQMProjectMapping, reader,
                                                                                                      responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.Name, nsmgrTS).InnerText.ToString(),
                                                                                                      responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.RQMID, nsmgrTS).InnerText.ToString());

                            RQMTestSuite currentTestSuite = testPlan.TestSuites.Where(z => z.RQMID == responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.RQMID, nsmgrTS).InnerText.ToString()).FirstOrDefault();

                            currentTestSuite.Name         = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.Name, nsmgrTS).InnerText.ToString();
                            currentTestSuite.CreatedBy    = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.RQMID, nsmgrTS).InnerText.ToString();
                            currentTestSuite.Description  = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.Description, nsmgrTS).InnerText.ToString();
                            currentTestSuite.CreationDate = DateTime.Parse(responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteMapping.CreationDate, nsmgrTS).InnerText.ToString()).ToLocalTime();
                            currentTestSuite.TestCases    = currentSuiteTestCases;

                            // adding current's test suite list of tests cases to overall (test plan's) list of test cases - to be presented at ginger together
                            currentSuiteTestCases.Where(y => !testPlan.TestCases.Select(x => x.RQMID).ToList().Contains(y.RQMID)).ToList().ForEach(z => testPlan.TestCases.Add(z));
                        }

                        //
                        // building test cases list directly on the TestPlan
                        ObservableList <RQMTestCase> testPlansTestCases = BuildRQMTestCaseList(responseDataNode.SelectNodes(currentRQMProjectMapping.RQMTestPlanMapping.PathXML, nsmgrTP),
                                                                                               nsmgrTP, loginData, currentRQMProjectMapping, reader, string.Empty, string.Empty);
                        // testPlan.TestCases = testPlansTestCases;
                        // temp? to review!
                        testPlansTestCases.Where(y => !testPlan.TestCases.Select(x => x.RQMID).ToList().Contains(y.RQMID)).ToList().ForEach(z => testPlan.TestCases.Add(z));
                    }
                }
            }
            else
            {
                Reporter.ToLog(eLogLevel.ERROR, "Error while trying to import selected RQM test plan, RQM_ImportConfigs_Template.xml wasn't found at: " + importConfigTemplate);
            }

            Mouse.OverrideCursor = null;
            return(testPlan);
        }
Пример #3
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);
            }
        }
Пример #4
0
        public RQMTestPlan GetRQMTestPlanByIdByProject(string RQMServerUrl, string RQMUserName, string RQMPassword, string RQMProject, string RQMTestPlanId)
        {
            RQMTestPlan testPlanRes = null;

            string importConfigTemplate = System.IO.Path.Combine(RQMCore.ConfigPackageFolderPath, "RQM_Import", "RQM_ImportConfigs_Template.xml");

            if (File.Exists(importConfigTemplate))
            {
                XmlSerializer serializer = new
                                           XmlSerializer(typeof(RQMProjectListConfiguration));

                FileStream fs     = new FileStream(importConfigTemplate, FileMode.Open);
                XmlReader  reader = XmlReader.Create(fs);
                RQMProjectListConfiguration RQMProjectList;
                RQMProjectList = (RQMProjectListConfiguration)serializer.Deserialize(reader);
                fs.Close();
                RQMProject currentRQMProjectMapping;
                if (RQMProjectList.RQMProjects.Count > 0)
                {
                    currentRQMProjectMapping = RQMProjectList.RQMProjects.Where(x => x.Name == RQMProject || x.Name == "DefaultProjectName").FirstOrDefault();
                    if (currentRQMProjectMapping != null)
                    {
                        //
                        //
                        LoginDTO loginData = new LoginDTO()
                        {
                            User = RQMUserName, Password = RQMPassword, Server = RQMServerUrl
                        };
                        IProjectData rqmProjectsData = RQMRep.GetVisibleProjects(loginData);
                        rqmProjectsDataList = rqmProjectsData.IProjectDefinitions;
                        IProjectDefinitions currentProj  = rqmProjectsDataList.Where(x => x.ProjectName == RQMProject).FirstOrDefault();
                        RqmResponseData     responseData = RQMRep.GetTestPlanByIdByProject(loginData, currentProj.Prefix, currentProj.Guid, RQMTestPlanId);
                        try //skip result incase of error, defect #5164
                        {
                            XmlDocument doc = new XmlDocument();
                            doc.LoadXml(responseData.responseText.ToString());
                            XmlNamespaceManager nsmgr = new XmlNamespaceManager(reader.NameTable);
                            currentRQMProjectMapping.RQMTestPlansListMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgr.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName));
                            XmlNode responseDataNode = doc.DocumentElement;

                            XmlNodeList testPlans = responseDataNode.SelectNodes(currentRQMProjectMapping.RQMTestPlansListMapping.XMLPathToTestPlansList, nsmgr);
                            foreach (XmlNode testPlan in testPlans)
                            {
                                testPlanRes = new RQMTestPlan(testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.Name, nsmgr).InnerText.ToString(),
                                                              testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.URLPath, nsmgr).Attributes[0].InnerText.ToString(),
                                                              testPlan.Attributes[0].InnerText.ToString(),
                                                              testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.RQMID, nsmgr).InnerText.ToString(),
                                                              testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.CreatedBy, nsmgr).Attributes[0].InnerText.Split('/').Last().ToString(),
                                                              DateTime.Parse(testPlan.SelectSingleNode(currentRQMProjectMapping.RQMTestPlansListMapping.CreationDate, nsmgr).InnerText.ToString()).ToLocalTime());

                                XmlNodeList testSuitesURInodes = testPlan.SelectNodes(currentRQMProjectMapping.RQMTestPlansListMapping.ContainedTestSuitesList, nsmgr);
                                foreach (XmlNode testSuitesURInode in testSuitesURInodes)
                                {
                                    RQMTestSuite rQMTestSuite = new RQMTestSuite(testSuitesURInode.Attributes[0].InnerText.ToString());

                                    try
                                    {
                                        // TestSuite data from RQM
                                        RqmResponseData responseDataTestSuite = RQMRep.GetRqmResponse(loginData, new Uri(testSuitesURInode.Attributes[0].InnerText.ToString()));
                                        XmlDocument     docTestSuite          = new XmlDocument();
                                        docTestSuite.LoadXml(responseDataTestSuite.responseText.ToString());
                                        XmlNamespaceManager nsmgrTestSuite = new XmlNamespaceManager(reader.NameTable);
                                        currentRQMProjectMapping.RQMTestSuiteAsItemMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTestSuite.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName));
                                        XmlNode responseDataNodeTestSuite = docTestSuite.DocumentElement;
                                        rQMTestSuite.RQMID = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteAsItemMapping.RQMID, nsmgrTestSuite).InnerText.ToString();
                                        rQMTestSuite.Name  = responseDataNodeTestSuite.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteAsItemMapping.Name, nsmgrTestSuite).InnerText.ToString();
                                        // TestSuite data from RQM
                                        RqmResponseData responseDataTestSuiteExecutionRecords = RQMRep.GetTestSuiteExecutionRecordsByTestSuite(loginData, currentProj.Prefix, currentProj.Guid, testSuitesURInode.Attributes[0].InnerText.ToString());
                                        XmlDocument     docTestSuiteExecutionRecords          = new XmlDocument();
                                        docTestSuiteExecutionRecords.LoadXml(responseDataTestSuiteExecutionRecords.responseText.ToString());
                                        XmlNamespaceManager nsmgrTestSuiteExecutionRecords = new XmlNamespaceManager(reader.NameTable);
                                        currentRQMProjectMapping.RQMTestSuiteExecutionRecordMapping.RQMNameSpaces.RQMNameSpaceList.ForEach(y => nsmgrTestSuiteExecutionRecords.AddNamespace(y.RQMNameSpacePrefix, y.RQMNameSpaceName));
                                        XmlNode responseDataNodeExecutionRecords = docTestSuiteExecutionRecords.DocumentElement;
                                        try
                                        {
                                            rQMTestSuite.TestSuiteExecutionRecord.CurrentTestSuiteResult.URLPathVersioned = responseDataNodeExecutionRecords.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteExecutionRecordMapping.CurrentTestSuiteResult, nsmgrTestSuiteExecutionRecords).Attributes[0].InnerText.ToString();
                                        }
                                        catch { }
                                        try
                                        {
                                            rQMTestSuite.TestSuiteExecutionRecord.URLPathVersioned = responseDataNodeExecutionRecords.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteExecutionRecordMapping.XMLTestSuiteExecutionRecord, nsmgrTestSuiteExecutionRecords).Attributes[0].InnerText.ToString();
                                            rQMTestSuite.TestSuiteExecutionRecord.RQMID            = responseDataNodeExecutionRecords.SelectSingleNode(currentRQMProjectMapping.RQMTestSuiteExecutionRecordMapping.RQMID, nsmgrTestSuiteExecutionRecords).InnerText.ToString();
                                        }
                                        catch { }
                                    }
                                    catch { }
                                    testPlanRes.TestSuites.Add(rQMTestSuite);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Error while trying to retrieve TestPlan id:" + RQMTestPlanId);
                            Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                        }
                    }
                }
            }
            return(testPlanRes);
        }