private static QCTestCaseStep GetListTSTestVars(QCTestCase testCase) { QCTestCaseStepsColl steps = QCRestAPIConnect.GetTestCaseSteps(testCase.Id); foreach (QCTestCaseStep step in steps) { if (step.ElementsField.ContainsKey("link-test")) { return(step); } } return(null); }
private ObservableList<ExternalItemFieldBase> CleanUnrelvantFields(ObservableList<ExternalItemFieldBase> fields, ResourceType resourceType) { ObservableList<ExternalItemFieldBase> fieldsToReturn = new ObservableList<ExternalItemFieldBase>(); string currentResource = QCRestAPIConnect.ConvertResourceType(resourceType); //Going through the fields to leave only Test Set fields for (int indx = 0; indx < fields.Count; indx++) { if (fields[indx].ItemType == currentResource) { fieldsToReturn.Add(fields[indx]); } } return fieldsToReturn; }
private QCTestCaseStepsColl GetListTSTestSteps(QCTestCase testCase) { QCTestCaseStepsColl testCaseSteps = QCRestAPIConnect.GetTestCaseSteps(testCase.Id); foreach (QCTestCaseStep step in testCaseSteps) { if (step.ElementsField.ContainsKey("link-test")) { QCTestCaseStepsColl linkTestCaseSteps = QCRestAPIConnect.GetTestCasesSteps(new List <string>() { step.ElementsField["link-test"].ToString() }); return(linkTestCaseSteps); } } return(testCaseSteps); }
private string CheckLinkedTSTestName(QCTestCase testCase) { QCTestCaseStepsColl testCasesSteps = QCRestAPIConnect.GetTestCaseSteps(testCase.Id); foreach (QCTestCaseStep step in testCasesSteps) { if (step.ElementsField.ContainsKey("link-test")) { QCTestCase linkedTestCase = QCRestAPIConnect.GetTestCases(new List <string>() { step.ElementsField["link-test"].ToString() })[0]; return(linkedTestCase.Name + ";" + linkedTestCase.Id); } } return(null); }
public override bool ConnectALMProject() { ALMCore.DefaultAlmConfig.ALMProjectName = ALMCore.DefaultAlmConfig.ALMProjectKey; return(QCRestAPIConnect.ConnectQCProject(ALMCore.DefaultAlmConfig.ALMServerURL, ALMCore.DefaultAlmConfig.ALMUserName, ALMCore.DefaultAlmConfig.ALMPassword, ALMCore.DefaultAlmConfig.ALMDomain, ALMCore.DefaultAlmConfig.ALMProjectName)); }
public override bool ConnectALMServer() { return(QCRestAPIConnect.ConnectQCServer(ALMCore.DefaultAlmConfig.ALMServerURL, ALMCore.DefaultAlmConfig.ALMUserName, ALMCore.DefaultAlmConfig.ALMPassword)); }
public override bool ExportBusinessFlowToALM(BusinessFlow businessFlow, bool performSaveAfterExport = false, ALMIntegration.eALMConnectType almConectStyle = ALMIntegration.eALMConnectType.Manual, string testPlanUploadPath = null, string testLabUploadPath = null) { if (businessFlow == null) { return(false); } if (businessFlow.ActivitiesGroups.Count == 0) { Reporter.ToUser(eUserMsgKey.StaticInfoMessage, "The " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + " do not include " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " which supposed to be mapped to ALM Test Cases, please add at least one " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup) + " before doing export."); return(false); } QCRestClient.QCTestSet matchingTS = null; Amdocs.Ginger.Common.eUserMsgSelection userSelec = Amdocs.Ginger.Common.eUserMsgSelection.None; //check if the businessFlow already mapped to QC Test Set if (String.IsNullOrEmpty(businessFlow.ExternalID) == false) { matchingTS = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).GetQCTestSet(businessFlow.ExternalID); if (matchingTS != null) { //ask user if want to continute userSelec = Reporter.ToUser(eUserMsgKey.BusinessFlowAlreadyMappedToTC, businessFlow.Name, matchingTS.Name); if (userSelec == Amdocs.Ginger.Common.eUserMsgSelection.Cancel) { return(false); } else if (userSelec == Amdocs.Ginger.Common.eUserMsgSelection.No) { matchingTS = null; } } } //check if all of the business flow activities groups already exported to QC and export the ones which not foreach (ActivitiesGroup ag in businessFlow.ActivitiesGroups) { // matchingTC = null; //check if the ActivitiesGroup already mapped to QC Test Case if (String.IsNullOrEmpty(ag.ExternalID) == false) { matchingTC = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).GetQCTest(ag.ExternalID); if (matchingTC != null) { //ask user if want to continute Amdocs.Ginger.Common.eUserMsgSelection userSelect = Reporter.ToUser(eUserMsgKey.ActivitiesGroupAlreadyMappedToTC, ag.Name, matchingTC.Name); if (userSelect == Amdocs.Ginger.Common.eUserMsgSelection.Cancel) { return(false); } else if (userSelect == Amdocs.Ginger.Common.eUserMsgSelection.No) { matchingTC = null; } else { if (String.IsNullOrEmpty(testPlanUploadPath)) { //testPlanUploadPath = ""; string parentId = matchingTC.ElementsField["parent-id"].ToString(); //need to test as the function changed in the library QCTestFolder testPlanFolder = QCRestAPIConnect.QcRestClient.GetTestPlanFolderDetails(parentId); string revrsePath = testPlanFolder.Name + "/"; string testPlanRootFolderId = QCRestAPIConnect.QcRestClient.GetTestPlanRootFolder().Id; while (testPlanFolder.Id != testPlanRootFolderId) { testPlanFolder = QCRestAPIConnect.QcRestClient.GetTestPlanFolderDetails(testPlanFolder.ParentId); revrsePath = revrsePath + testPlanFolder.Name + "/"; } revrsePath = revrsePath.Substring(0, revrsePath.Length - 1); string[] str = revrsePath.Split('/'); Array.Reverse(str); testPlanUploadPath = string.Join("\\", str); } } } } //if user selected No and want to create new testplans to selected folder path if (matchingTC == null && String.IsNullOrEmpty(testPlanUploadPath)) { //get the QC Test Plan path to upload the activities group to testPlanUploadPath = SelectALMTestPlanPath(); if (String.IsNullOrEmpty(testPlanUploadPath)) { //no path to upload to return(false); } //create upload path if checked to create separete folder if (QCTestPlanFolderTreeItem.IsCreateBusinessFlowFolder) { try { string newFolderId = QCRestAPIConnect.GetLastTestPlanIdFromPath(testPlanUploadPath).ToString(); QCItem newFolder = new QCItem(); newFolder.Fields.Add("name", businessFlow.Name); newFolder.Fields.Add("parent-id", QCRestAPIConnect.GetLastTestPlanIdFromPath(testPlanUploadPath).ToString()); ALMResponseData responseData = QCRestAPIConnect.CreateNewEntity(ResourceType.TEST_FOLDERS, newFolder); newFolderId = responseData.IdCreated; testPlanUploadPath = testPlanUploadPath + "\\" + businessFlow.Name; } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to get create folder for Test Plan with REST API", ex); } } } ExportActivitiesGroupToALM(ag, testPlanUploadPath, false, businessFlow); } if (matchingTS == null && string.IsNullOrEmpty(testLabUploadPath)) { if (userSelec == Amdocs.Ginger.Common.eUserMsgSelection.No) { Reporter.ToUser(eUserMsgKey.ExportQCNewTestSetSelectDiffFolder); } //get the QC Test Plan path to upload the activities group to testLabUploadPath = SelectALMTestLabPath(); if (String.IsNullOrEmpty(testLabUploadPath)) { //no path to upload to return(false); } } //upload the business flow Reporter.ToStatus(eStatusMsgKey.ExportItemToALM, null, businessFlow.Name); string res = string.Empty; ObservableList <ExternalItemFieldBase> allFields = new ObservableList <ExternalItemFieldBase>(WorkSpace.Instance.Solution.ExternalItemsFields); ALMIntegration.Instance.RefreshALMItemFields(allFields, true, null); ObservableList <ExternalItemFieldBase> testSetFieldsFields = CleanUnrelvantFields(allFields, ResourceType.TEST_SET); ObservableList <ExternalItemFieldBase> testInstanceFields = CleanUnrelvantFields(allFields, ResourceType.TEST_CYCLE); bool exportRes = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).ExportBusinessFlowToALM(businessFlow, matchingTS, testLabUploadPath, testSetFieldsFields, testInstanceFields, ref res); Reporter.HideStatusMessage(); if (exportRes) { if (performSaveAfterExport) { Reporter.ToStatus(eStatusMsgKey.SaveItem, null, businessFlow.Name, GingerDicser.GetTermResValue(eTermResKey.BusinessFlow)); WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(businessFlow); Reporter.HideStatusMessage(); } if (almConectStyle != ALMIntegration.eALMConnectType.Auto) { Reporter.ToUser(eUserMsgKey.ExportItemToALMSucceed); } return(true); } else if (almConectStyle != ALMIntegration.eALMConnectType.Auto) { Reporter.ToUser(eUserMsgKey.ExportItemToALMFailed, GingerDicser.GetTermResValue(eTermResKey.BusinessFlow), businessFlow.Name, res); } return(false); }
public override List <string> GetTestPlanExplorer(string path) { return(QCRestAPIConnect.GetTestPlanExplorer(path)); }
public override Object GetTSRunStatus(Object tsItem) { return(QCRestAPIConnect.GetTSRunStatus(tsItem)); }
private static ActivitiesGroup CheckIfTCAlreadyExistInRepo(BusinessFlow busFlow, QCTestInstance testInstance, QCTestCaseStepsColl tSTestCaseSteps) { ActivitiesGroup tcActivsGroup; ActivitiesGroup repoActivsGroup = null; QCTestCaseStepsColl relevantTestCaseSteps = QCRestAPIConnect.GetTestCaseSteps(testInstance.TestId); QCTestCaseStep relevantStep = null; foreach (QCTestCaseStep testcaseStep in relevantTestCaseSteps) { if (testcaseStep.ElementsField.ContainsKey("link-test")) { relevantStep = testcaseStep; } } if (relevantStep != null) { repoActivsGroup = GingerActivitiesGroupsRepo.Where(x => x.ExternalID == relevantStep.ElementsField["link-test"].ToString()).FirstOrDefault(); } if (repoActivsGroup == null) { repoActivsGroup = GingerActivitiesGroupsRepo.Where(x => x.ExternalID == testInstance.Id).FirstOrDefault(); } if (repoActivsGroup != null) { List <Activity> repoNotExistsStepActivity = GingerActivitiesRepo.Where(z => repoActivsGroup.ActivitiesIdentifiers.Select(y => y.ActivityExternalID).ToList().Contains(z.ExternalID)) .Where(x => !tSTestCaseSteps.Where(item => item.TestId == testInstance.TestId).Select(y => y.Id).ToList().Contains(x.ExternalID)).ToList(); tcActivsGroup = (ActivitiesGroup)repoActivsGroup.CreateInstance(); var ActivitySIdentifiersToRemove = tcActivsGroup.ActivitiesIdentifiers.Where(x => repoNotExistsStepActivity.Select(z => z.ExternalID).ToList().Contains(x.ActivityExternalID)); for (int indx = 0; indx < tcActivsGroup.ActivitiesIdentifiers.Count; indx++) { if ((indx < tcActivsGroup.ActivitiesIdentifiers.Count) && (ActivitySIdentifiersToRemove.Contains(tcActivsGroup.ActivitiesIdentifiers[indx]))) { tcActivsGroup.ActivitiesIdentifiers.Remove(tcActivsGroup.ActivitiesIdentifiers[indx]); indx--; } } tcActivsGroup.ExternalID2 = testInstance.Id; busFlow.AddActivitiesGroup(tcActivsGroup); busFlow.ImportActivitiesGroupActivitiesFromRepository(tcActivsGroup, GingerActivitiesRepo, true, true); busFlow.AttachActivitiesGroupsAndActivities(); } else //TC not exist in Ginger repository so create new one { tcActivsGroup = new ActivitiesGroup(); tcActivsGroup.Name = testInstance.Name; if (relevantStep == null) { tcActivsGroup.ExternalID = testInstance.Id; tcActivsGroup.ExternalID2 = testInstance.Id; } else { tcActivsGroup.ExternalID = relevantStep.ElementsField["link-test"].ToString(); tcActivsGroup.ExternalID2 = testInstance.Id; } busFlow.AddActivitiesGroup(tcActivsGroup); } return(tcActivsGroup); }
public override Dictionary <string, string> GetALMDomainProjects(string ALMDomainName) { ALMCore.DefaultAlmConfig.ALMDomain = ALMDomainName; return(QCRestAPIConnect.GetQCDomainProjects(ALMCore.DefaultAlmConfig.ALMDomain)); }
public override List<string> GetTestLabExplorer(string path) { return QCRestAPIConnect.GetTestLabExplorer(path); }
private QCRunColl GetListTSTestRuns(QCTestCase testCase) { return(QCRestAPIConnect.GetRunsByTestId(testCase.Id)); }
public QC.QCTSTest ImportTSTest(QCTestInstance testInstance) { QC.QCTSTest newTSTest = new QC.QCTSTest(); QCTestCase testCase = QCRestAPIConnect.GetTestCases(new List <string>() { testInstance.TestId })[0]; string linkedTest = CheckLinkedTSTestName(testCase); if (testInstance != null) { //Get the TC general details if (linkedTest != null) { //Linked TC string[] linkTest = linkedTest.Split(';'); newTSTest.TestID = testInstance.Id; newTSTest.TestName = linkTest[0]; newTSTest.LinkedTestID = linkTest[1]; } else { //Regular TC newTSTest.TestID = testInstance.Id; newTSTest.TestName = testInstance.Name ?? testCase.Name; newTSTest.LinkedTestID = testInstance.TestId; } } //Get the TC design steps QCTestCaseStepsColl TSTestSteps = GetListTSTestSteps(testCase); foreach (QCTestCaseStep testcaseStep in TSTestSteps) { QC.QCTSTestStep newtsStep = new QC.QCTSTestStep(); newtsStep.StepID = testcaseStep.Id.ToString(); newtsStep.StepName = testcaseStep.Name; newtsStep.Description = testcaseStep.Description; newtsStep.Expected = testcaseStep.ElementsField["expected"].ToString(); newTSTest.Steps.Add(newtsStep); } //Get the TC parameters and their selected value if (linkedTest != null) { if (linkedTest.Split(';')[0] != testCase.Name) { if (newTSTest.Description == null) { newTSTest.Description = string.Empty; } newTSTest.Description = testCase.Name.ToString() + System.Environment.NewLine + newTSTest.Description; } //Linked TC QCTestCaseStep TSLinkedTestCaseStep = GetListTSTestVars(testCase); if (TSLinkedTestCaseStep != null) { FillRelevantDataForStepParams(newTSTest, TSLinkedTestCaseStep); } } else { ////Regular TC QCTestCaseStepsColl TSLinkedTestCaseSteps = QCRestAPIConnect.GetTestCaseSteps(testCase.Id); foreach (QCTestCaseStep step in TSLinkedTestCaseSteps) { FillRelevantDataForStepParams(newTSTest, step); } } //Get the TC execution history try { QCRunColl TSTestRuns = GetListTSTestRuns(testCase); foreach (QCRun run in TSTestRuns) { QC.QCTSTestRun newtsRun = new QC.QCTSTestRun(); newtsRun.RunID = run.Id; newtsRun.RunName = run.Name; newtsRun.Status = run.Status; newtsRun.ExecutionDate = (run.ElementsField["execution-date"]).ToString(); newtsRun.ExecutionTime = (run.ElementsField["execution-time"]).ToString(); newtsRun.Tester = (run.Owner).ToString(); newTSTest.Runs.Add(newtsRun); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to pull QC test case RUN info", ex); newTSTest.Runs = new List <QC.QCTSTestRun>(); } return(newTSTest); }
public override void DisconnectALMServer() { QCRestAPIConnect.DisconnectQCServer(); }
public override List <string> GetALMDomains() { return(QCRestAPIConnect.GetQCDomains()); }
public override List <string> GetALMDomainProjects(string ALMDomainName) { ALMCore.AlmConfig.ALMDomain = ALMDomainName; return(QCRestAPIConnect.GetQCDomainProjects(ALMCore.AlmConfig.ALMDomain)); }
public override bool DisconnectALMProjectStayLoggedIn() { return(QCRestAPIConnect.DisconnectQCProjectStayLoggedIn()); }
public override IEnumerable <Object> GetTestSetExplorer(string path) { return(QCRestAPIConnect.GetTestSetExplorer(path)); }