/// <summary> /// Export Activities Group details to QC, can be used for creating new matching QC Test Case or updating an exisitng one /// </summary> /// <param name="activitiesGroup">Activities Group to Export</param> /// <param name="mappedTest">The QC Test Case which mapped to the Activities Group (in case exist) and needs to be updated</param> /// <param name="uploadPath">Upload path in QC Test Plan</param> /// <param name="result">Export error result</param> /// <returns></returns> public static bool ExportActivitiesGroupToQC(ActivitiesGroup activitiesGroup, QCTestCase mappedTest, string uploadPath, ObservableList <ExternalItemFieldBase> testCaseFields, ObservableList <ExternalItemFieldBase> designStepsFields, ObservableList <ExternalItemFieldBase> designStepsParamsFields, ref string result) { try { QCTestCase test = null; if (mappedTest == null) //#Create new test case { test = CreateNewTestCase(activitiesGroup, uploadPath, testCaseFields); int order = 1; foreach (ActivityIdentifiers actIdent in activitiesGroup.ActivitiesIdentifiers) { CreateTestStep(test, actIdent.IdentifiedActivity, designStepsFields, designStepsParamsFields, order++); } } else //##update existing test case { test = UpdateExistingTestCase(mappedTest, activitiesGroup, testCaseFields); foreach (ActivityIdentifiers actIdent in activitiesGroup.ActivitiesIdentifiers) { UpdateTestStep(test, activitiesGroup, actIdent.IdentifiedActivity, designStepsFields, designStepsParamsFields); } } return(true); } catch (Exception ex) { result = "Unexpected error occurred- " + ex.Message; Reporter.ToLog(eLogLevel.ERROR, "Failed to export the Activities Group to QC/ALM", ex); return(false); } }
public override bool ExportActivitiesGroupToALM(ActivitiesGroup activtiesGroup, string uploadPath = null, bool performSaveAfterExport = false) { if (activtiesGroup == null) return false; QCTestCase matchingTC = null; //check if the ActivitiesGroup already mapped to QC Test Case if (String.IsNullOrEmpty(activtiesGroup.ExternalID) == false) { matchingTC = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).GetQCTest(activtiesGroup.ExternalID); if (matchingTC != null) { //ask user if want to continute MessageBoxResult userSelec = Reporter.ToUser(eUserMsgKeys.ActivitiesGroupAlreadyMappedToTC, activtiesGroup.Name, matchingTC.Name); if (userSelec == MessageBoxResult.Cancel) return false; else if (userSelec == MessageBoxResult.No) matchingTC = null; } } if (matchingTC == null && String.IsNullOrEmpty(uploadPath)) { //get the QC Test Plan path to upload the activities group to uploadPath = SelectALMTestPlanPath(); if (String.IsNullOrEmpty(uploadPath)) { //no path to upload to return false; } } //upload the Activities Group Reporter.ToGingerHelper(eGingerHelperMsgKey.ExportItemToALM, null, activtiesGroup.Name); string res = string.Empty; ObservableList<ExternalItemFieldBase> allFields = new ObservableList<ExternalItemFieldBase>(App.UserProfile.Solution.ExternalItemsFields); ALMIntegration.Instance.RefreshALMItemFields(allFields, true, null); ObservableList<ExternalItemFieldBase> testCaseFields = CleanUnrelvantFields(allFields, ResourceType.TEST_CASE); ObservableList<ExternalItemFieldBase> designStepsFields = CleanUnrelvantFields(allFields, ResourceType.DESIGN_STEP); ObservableList<ExternalItemFieldBase> designStepsParamsFields = CleanUnrelvantFields(allFields, ResourceType.DESIGN_STEP_PARAMETERS); bool exportRes = ((QCRestAPICore)ALMIntegration.Instance.AlmCore).ExportActivitiesGroupToALM(activtiesGroup, matchingTC, uploadPath, testCaseFields, designStepsFields, designStepsParamsFields, ref res); Reporter.CloseGingerHelper(); if (exportRes) { if (performSaveAfterExport) { Reporter.ToGingerHelper(eGingerHelperMsgKey.SaveItem, null, activtiesGroup.Name, GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup)); WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(activtiesGroup); Reporter.CloseGingerHelper(); } return true; } else Reporter.ToUser(eUserMsgKeys.ExportItemToALMFailed, GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroup), activtiesGroup.Name, res); return false; }
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 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); }
private static QCTestCase CreateNewTestCase(ActivitiesGroup activitiesGroup, string uploadPath, ObservableList <ExternalItemFieldBase> testCaseFields) { QCTestCase test = new QCTestCase(); test.ElementsField["subtype-id"] = "MANUAL"; test.ElementsField["parent-id"] = QCRestAPIConnect.GetLastTestPlanIdFromPath(uploadPath).ToString(); //set item fields foreach (ExternalItemFieldBase field in testCaseFields) { if (field.ToUpdate || field.Mandatory) { if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA") { test.ElementsField.Add(field.ExternalID, field.SelectedValue); } else { try { test.ElementsField.Add(field.ExternalID, "NA"); } catch { } } } } //post the test test.ElementsField["name"] = activitiesGroup.Name; test.ElementsField["description"] = activitiesGroup.Description; QCItem item = ConvertObjectValuesToQCItem(test, ResourceType.TEST_CASE); ALMResponseData response = QCRestAPIConnect.CreateNewEntity(ResourceType.TEST_CASE, item); test.Id = response.IdCreated; activitiesGroup.ExternalID = test.Id; activitiesGroup.ExternalID2 = test.Id; return(QCRestAPIConnect.GetTestCases(new List <string> { test.Id })[0]); }
private static QCTestCase UpdateExistingTestCase(QCTestCase mappedTest, ActivitiesGroup activitiesGroup, ObservableList <ExternalItemFieldBase> testCaseFields) { QCTestCase test = mappedTest; //set item fields foreach (ExternalItemFieldBase field in testCaseFields) { if (field.ToUpdate || field.Mandatory) { if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA") { if (test.ElementsField.ContainsKey(field.ExternalID)) { test.ElementsField[field.ExternalID] = field.SelectedValue; } } else { try { test.ElementsField.Add(field.ExternalID, "NA"); } catch { } } } } //update the test test.ElementsField["name"] = activitiesGroup.Name; test.ElementsField["description"] = activitiesGroup.Description; QCItem item = ConvertObjectValuesToQCItem(test, ResourceType.TEST_CASE, true); ALMResponseData response = QCRestAPIConnect.UpdateEntity(ResourceType.TEST_CASE, test.Id, item); activitiesGroup.ExternalID = test.Id; activitiesGroup.ExternalID2 = test.Id; return(test); }
private static void UpdateTestStep(QCTestCase test, ActivitiesGroup activitiesGroup, Activity identifiedActivity, ObservableList <ExternalItemFieldBase> designStepsFields, ObservableList <ExternalItemFieldBase> designStepsParamsFields) { QCTestCaseStepsColl testCaseDesignStep = QCRestAPIConnect.GetTestCasesSteps(new List <string> { test.Id }); //delete the un-needed steps foreach (QCTestCaseStep step in testCaseDesignStep) { if (activitiesGroup.ActivitiesIdentifiers.Where(x => x.IdentifiedActivity.ExternalID == step.Id.ToString()).FirstOrDefault() == null) { QCRestAPIConnect.DeleteEntity(ALM_Common.DataContracts.ResourceType.DESIGN_STEP, step.Id); } } //delete the existing parameters QCTestCaseParamsColl testCaseParams = QCRestAPIConnect.GetTestCaseParams(test.Id); if (testCaseParams.Count > 0) { for (int indx = 0; indx < testCaseParams.Count; indx++) { QCRestAPIConnect.DeleteEntity(ALM_Common.DataContracts.ResourceType.DESIGN_STEP_PARAMETERS, testCaseParams[indx].Id); } } foreach (QCTestCaseStep step in testCaseDesignStep) { //set item fields foreach (ExternalItemFieldBase field in designStepsFields) { if (field.ToUpdate || field.Mandatory) { if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA") { if (step.ElementsField.ContainsKey(field.ExternalID)) { step.ElementsField[field.ExternalID] = field.SelectedValue; } } } } step.ElementsField["name"] = identifiedActivity.ActivityName; string descriptionTemplate = "<html><body><div align=\"left\"><font face=\"Arial\"><span style=\"font-size:8pt\"><<&Description&&>><br /><<&Parameters&>><br /><<&Actions&>></span></font></div></body></html>"; string description = descriptionTemplate.Replace("<<&Description&&>>", identifiedActivity.Description); QCTestCaseParamsColl testParams = QCRestAPIConnect.GetTestCaseParams(test.Id); string paramsSigns = string.Empty; if (identifiedActivity.Variables.Count > 0) { paramsSigns = "<br />Parameters:<br />"; foreach (VariableBase var in identifiedActivity.Variables) { paramsSigns += "<<<" + var.Name.ToLower() + ">>><br />"; //try to add the paramter to the test case parameters list try { QCTestCaseParam newParam = new QCTestCaseParam(); //set item fields foreach (ExternalItemFieldBase field in designStepsParamsFields) { if (field.ToUpdate || field.Mandatory) { if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA") { newParam.ElementsField.Add(field.ExternalID, field.SelectedValue); } else { try { newParam.ElementsField.Add(field.ExternalID, "NA"); } catch { } } } } newParam.Name = var.Name.ToLower(); newParam.TestId = test.Id; QCItem itemTestCaseParam = ConvertObjectValuesToQCItem(newParam, ResourceType.TEST_CASE_PARAMETERS); QCRestAPIConnect.CreateNewEntity(ResourceType.TEST_CASE_PARAMETERS, itemTestCaseParam); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}"); } } } description = description.Replace("<<&Parameters&>>", paramsSigns); string actsDesc = string.Empty; if (identifiedActivity.Acts.Count > 0) { actsDesc = "Actions:<br />"; foreach (Act act in identifiedActivity.Acts) { actsDesc += act.Description + "<br />"; } } description = description.Replace("<<&Actions&>>", actsDesc); step.Description = description; step.ElementsField["expected"] = identifiedActivity.Expected; QCItem itemDesignStep = ConvertObjectValuesToQCItem(step, ResourceType.DESIGN_STEP, true); ALMResponseData response = QCRestAPIConnect.UpdateEntity(ResourceType.DESIGN_STEP, step.Id, itemDesignStep); identifiedActivity.ExternalID = step.Id; } }
private static bool CreateTestStep(QCTestCase test, Activity activity, ObservableList <ExternalItemFieldBase> designStepsFields, ObservableList <ExternalItemFieldBase> designStepsParamsFields, int stepOrder) { //create new step QCTestCaseStep step = new QCTestCaseStep(); //set item fields foreach (ExternalItemFieldBase field in designStepsFields) { if (field.ToUpdate || field.Mandatory) { if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA") { step.ElementsField.Add(field.ExternalID, field.SelectedValue); } else { try { step.ElementsField.Add(field.ExternalID, "NA"); } catch { } } } } step.ElementsField["name"] = activity.ActivityName; step.ElementsField["parent-id"] = test.Id; step.ElementsField["step-order"] = stepOrder.ToString(); string descriptionTemplate = "<html><body><div align=\"left\"><font face=\"Arial\"><span style=\"font-size:8pt\"><<&Description&&>><br /><<&Parameters&>><br /><<&Actions&>></span></font></div></body></html>"; string description = descriptionTemplate.Replace("<<&Description&&>>", activity.Description); QCTestCaseParamsColl testParams = QCRestAPIConnect.GetTestCaseParams(test.Id); string paramsSigns = string.Empty; if (activity.Variables.Count > 0) { paramsSigns = "<br />Parameters:<br />"; foreach (VariableBase var in activity.Variables) { paramsSigns += "<<<" + var.Name.ToLower() + ">>><br />"; //try to add the paramter to the test case parameters list try { QCTestCaseParam newParam = new QCTestCaseParam(); //set item fields foreach (ExternalItemFieldBase field in designStepsParamsFields) { if (field.ToUpdate || field.Mandatory) { if (string.IsNullOrEmpty(field.SelectedValue) == false && field.SelectedValue != "NA") { newParam.ElementsField.Add(field.ExternalID, field.SelectedValue); } else { try { newParam.ElementsField.Add(field.ExternalID, "NA"); } catch { } } } } newParam.Name = var.Name.ToLower(); newParam.TestId = test.Id; QCItem itemTestCaseParam = ConvertObjectValuesToQCItem(newParam, ResourceType.TEST_CASE_PARAMETERS); QCRestAPIConnect.CreateNewEntity(ResourceType.TEST_CASE_PARAMETERS, itemTestCaseParam); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}"); } } } description = description.Replace("<<&Parameters&>>", paramsSigns); string actsDesc = string.Empty; if (activity.Acts.Count > 0) { actsDesc = "Actions:<br />"; foreach (Act act in activity.Acts) { actsDesc += act.Description + "<br />"; } } description = description.Replace("<<&Actions&>>", actsDesc); step.Description = description; step.ElementsField["expected"] = activity.Expected; QCItem itemDesignStep = ConvertObjectValuesToQCItem(step, ResourceType.DESIGN_STEP); ALMResponseData response = QCRestAPIConnect.CreateNewEntity(ResourceType.DESIGN_STEP, itemDesignStep); activity.ExternalID = response.IdCreated; if (activity.ExternalID != null) { return(true); } else { return(false); } }
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); } QCTestSet matchingTS = null; Amdocs.Ginger.Common.eUserMsgSelection userSelec; //TO DO MaheshK : check if the businessFlow already mapped to Octane Test Suite if (!String.IsNullOrEmpty(businessFlow.ExternalID)) { matchingTS = ((OctaneCore)ALMIntegration.Instance.AlmCore).GetTestSuiteById(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; 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 folderId = octaneCore.GetLastTestPlanIdFromPath(testPlanUploadPath).ToString(); folderId = octaneCore.CreateApplicationModule(businessFlow.Name, businessFlow.Description, folderId); testPlanUploadPath = folderId; } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to get create folder for Test Plan with Octane REST API", ex); } } else { testPlanUploadPath = octaneCore.GetLastTestPlanIdFromPath(testPlanUploadPath).ToString(); } } else { if (String.IsNullOrEmpty(testPlanUploadPath)) { testPlanUploadPath = matchingTS.ParentId; } } } } testLabUploadPath = testPlanUploadPath; bool performSave = false; //just to check if new TC needs to be created or update has to be done if (matchingTS == null) { matchingTC = null; } else { matchingTC = new QCTestCase(); } //check if all of the business flow activities groups already exported to Octane and export the ones which not foreach (ActivitiesGroup ag in businessFlow.ActivitiesGroups) { ExportActivitiesGroupToALM(ag, testPlanUploadPath, performSave, businessFlow); } //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, "Test Suite"); bool exportRes = ((OctaneCore)ALMIntegration.Instance.AlmCore).ExportBusinessFlow(businessFlow, matchingTS, testLabUploadPath, testSetFieldsFields, null, 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 bool ExportActivitiesGroupToALM(ActivitiesGroup activtiesGroup, QCTestCase matchingTC, string uploadPath, ObservableList <ExternalItemFieldBase> testCaseFields, ObservableList <ExternalItemFieldBase> designStepsFields, ObservableList <ExternalItemFieldBase> designStepsParamsFields, ref string res) { return(ExportToQCRestAPI.ExportActivitiesGroupToQC(activtiesGroup, matchingTC, uploadPath, testCaseFields, designStepsFields, designStepsParamsFields, ref res)); }
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); }
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); }