Esempio n. 1
0
        public QC.QCTestSet ImportTestSetData(QC.QCTestSet testSet)
        {
            List <BaseResponseItem> selectedTcs = GetZephyrEntTcsByTreeId(Convert.ToInt32(testSet.TestSetID));
            var token = (JToken)selectedTcs[0].TryGetItem("results");

            foreach (var testInstance in token)
            {
                testSet.Tests.Add(ImportTSTest(((JToken)testInstance).SelectToken("testcase")));
            }
            return(testSet);
        }
Esempio n. 2
0
 public BusinessFlow ConvertQCTestSetToBF(QC.QCTestSet testSet)
 {
     return(ImportFromQCRest.ConvertQCTestSetToBF(testSet));
 }
Esempio n. 3
0
 public QC.QCTestSet ImportTestSetData(QC.QCTestSet testSet)
 {
     return(ImportFromQCRest.ImportTestSetData(testSet));
 }
Esempio n. 4
0
        public override bool ImportSelectedTests(string importDestinationPath, IEnumerable <Object> selectedTestSets)
        {
            if (selectedTestSets != null && selectedTestSets.Count() > 0)
            {
                ObservableList <QCTestSetTreeItem> testSetsItemsToImport = new ObservableList <QCTestSetTreeItem>();
                foreach (QCTestSetTreeItem testSetItem in selectedTestSets)
                {
                    //check if some of the Test Set was already imported
                    if (testSetItem.AlreadyImported == true)
                    {
                        Amdocs.Ginger.Common.eUserMsgSelection userSelection = Reporter.ToUser(eUserMsgKey.TestSetExists, testSetItem.TestSetName);
                        if (userSelection == Amdocs.Ginger.Common.eUserMsgSelection.Yes)
                        {
                            //Delete the mapped BF
                            File.Delete(testSetItem.MappedBusinessFlow.FileName);
                            testSetsItemsToImport.Add(testSetItem);
                        }
                    }
                    else
                    {
                        testSetsItemsToImport.Add(testSetItem);
                    }
                }

                if (testSetsItemsToImport.Count == 0)
                {
                    return(false);                                  //noting to import
                }
                //Refresh Ginger repository and allow GingerQC to use it
                ALMIntegration.Instance.AlmCore.GingerActivitiesGroupsRepo = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ActivitiesGroup>();
                ALMIntegration.Instance.AlmCore.GingerActivitiesRepo       = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();

                foreach (QCTestSetTreeItem testSetItemtoImport in testSetsItemsToImport)
                {
                    try
                    {
                        //import test set data
                        Reporter.ToStatus(eStatusMsgKey.ALMTestSetImport, null, testSetItemtoImport.TestSetName);
                        GingerCore.ALM.QC.QCTestSet TS = new GingerCore.ALM.QC.QCTestSet();
                        TS.TestSetID   = testSetItemtoImport.TestSetID;
                        TS.TestSetName = testSetItemtoImport.TestSetName;
                        TS.TestSetPath = testSetItemtoImport.Path;
                        TS             = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).ImportTestSetData(TS);

                        //convert test set into BF
                        BusinessFlow tsBusFlow = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).ConvertQCTestSetToBF(TS);

                        if (WorkSpace.Instance.Solution.MainApplication != null)
                        {
                            //add the applications mapped to the Activities
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication) == false)
                                {
                                    if (tsBusFlow.TargetApplications.Where(x => x.Name == activ.TargetApplication).FirstOrDefault() == null)
                                    {
                                        ApplicationPlatform appAgent = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault();
                                        if (appAgent != null)
                                        {
                                            tsBusFlow.TargetApplications.Add(new TargetApplication()
                                            {
                                                AppName = appAgent.AppName
                                            });
                                        }
                                    }
                                }
                            }
                            //handle non mapped Activities
                            if (tsBusFlow.TargetApplications.Count == 0)
                            {
                                tsBusFlow.TargetApplications.Add(new TargetApplication()
                                {
                                    AppName = WorkSpace.Instance.Solution.MainApplication
                                });
                            }
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    activ.TargetApplication = tsBusFlow.MainApplication;
                                }
                            }
                        }
                        else
                        {
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                activ.TargetApplication = null; // no app configured on solution level
                            }
                        }

                        AddTestSetFlowToFolder(tsBusFlow, importDestinationPath);

                        Reporter.HideStatusMessage();
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToUser(eUserMsgKey.ErrorInTestsetImport, testSetItemtoImport.TestSetName, ex.Message);
                        Reporter.ToLog(eLogLevel.ERROR, "Error importing from QC", ex);
                    }
                }

                Reporter.ToUser(eUserMsgKey.TestSetsImportedSuccessfully);

                Reporter.ToLog(eLogLevel.DEBUG, "Imported from QC successfully");
                return(true);
            }
            Reporter.ToLog(eLogLevel.ERROR, "Error importing from QC");
            return(false);
        }
Esempio n. 5
0
 public BusinessFlow ConvertQCTestSetToBF(QC.QCTestSet tS)
 {
     return(zephyrEntImportManager.ConvertQCTestSetToBF(tS));
 }
Esempio n. 6
0
        public override bool ImportSelectedTests(string importDestinationPath, IEnumerable <Object> selectedTestSets)
        {
            if (selectedTestSets != null && selectedTestSets.Count() > 0)
            {
                ObservableList <QCTestSetTreeItem> testSetsItemsToImport = new ObservableList <QCTestSetTreeItem>();
                bool bfsWereDeleted = false;
                foreach (QCTestSetTreeItem testSetItem in selectedTestSets)
                {
                    //check if some of the Test Set was already imported
                    if (testSetItem.AlreadyImported == true)
                    {
                        MessageBoxResult userSelection = Reporter.ToUser(eUserMsgKeys.TestSetExists, testSetItem.TestSetName);
                        if (userSelection == MessageBoxResult.Yes)
                        {
                            //Delete the mapped BF
                            File.Delete(testSetItem.MappedBusinessFlow.FileName);
                            bfsWereDeleted = true;
                            testSetsItemsToImport.Add(testSetItem);
                        }
                    }
                    else
                    {
                        testSetsItemsToImport.Add(testSetItem);
                    }
                }
                if (bfsWereDeleted)
                {
                    App.MainWindow.RefreshSolutionPage();
                }

                if (testSetsItemsToImport.Count == 0)
                {
                    return(false);                                  //noting to import
                }
                //Refresh Ginger repository and allow GingerQC to use it
                ALMIntegration.Instance.AlmCore.GingerActivitiesGroupsRepo = App.LocalRepository.GetSolutionRepoActivitiesGroups(false);
                ALMIntegration.Instance.AlmCore.GingerActivitiesGroupsRepo = App.LocalRepository.GetSolutionRepoActivitiesGroups(false);
                ALMIntegration.Instance.AlmCore.GingerActivitiesRepo       = App.LocalRepository.GetSolutionRepoActivities(false);

                foreach (QCTestSetTreeItem testSetItemtoImport in testSetsItemsToImport)
                {
                    try
                    {
                        //import test set data
                        Reporter.ToGingerHelper(eGingerHelperMsgKey.ALMTestSetImport, null, testSetItemtoImport.TestSetName);
                        GingerCore.ALM.QC.QCTestSet TS = new GingerCore.ALM.QC.QCTestSet();
                        TS.TestSetID   = testSetItemtoImport.TestSetID;
                        TS.TestSetName = testSetItemtoImport.TestSetName;
                        TS.TestSetPath = testSetItemtoImport.Path;
                        TS             = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).ImportTestSetData(TS);

                        //convert test set into BF
                        BusinessFlow tsBusFlow = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).ConvertQCTestSetToBF(TS);

                        if (App.UserProfile.Solution.MainApplication != null)
                        {
                            //add the applications mapped to the Activities
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication) == false)
                                {
                                    if (tsBusFlow.TargetApplications.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault() == null)
                                    {
                                        ApplicationPlatform appAgent = App.UserProfile.Solution.ApplicationPlatforms.Where(x => x.AppName == activ.TargetApplication).FirstOrDefault();
                                        if (appAgent != null)
                                        {
                                            tsBusFlow.TargetApplications.Add(new TargetApplication()
                                            {
                                                AppName = appAgent.AppName
                                            });
                                        }
                                    }
                                }
                            }
                            //handle non mapped Activities
                            if (tsBusFlow.TargetApplications.Count == 0)
                            {
                                tsBusFlow.TargetApplications.Add(new TargetApplication()
                                {
                                    AppName = App.UserProfile.Solution.MainApplication
                                });
                            }
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                if (string.IsNullOrEmpty(activ.TargetApplication))
                                {
                                    activ.TargetApplication = tsBusFlow.MainApplication;
                                }
                            }
                        }
                        else
                        {
                            foreach (Activity activ in tsBusFlow.Activities)
                            {
                                activ.TargetApplication = null; // no app configured on solution level
                            }
                        }

                        //save bf
                        tsBusFlow.FileName = LocalRepository.GetRepoItemFileName(tsBusFlow, importDestinationPath);
                        tsBusFlow.SaveToFile(tsBusFlow.FileName);
                        //add to cach
                        App.LocalRepository.AddItemToCache(tsBusFlow);
                        Reporter.CloseGingerHelper();
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToUser(eUserMsgKeys.ErrorInTestsetImport, testSetItemtoImport.TestSetName, ex.Message);
                        Reporter.ToLog(eLogLevel.ERROR, "Error importing from QC", ex);
                    }
                }

                //Refresh the solution tree
                App.MainWindow.RefreshSolutionPage();

                Reporter.ToUser(eUserMsgKeys.TestSetsImportedSuccessfully);

                Reporter.ToLog(eLogLevel.INFO, "Imported from QC successfully");
                return(true);
            }
            Reporter.ToLog(eLogLevel.ERROR, "Error importing from QC");
            return(false);
        }