public ZephyrEntPhaseTreeItem(BaseResponseItem node) : base(node) { this.Folder = node.TryGetItem("name").ToString(); this.TestSetName = node.TryGetItem("name").ToString(); this.TestSetID = node.TryGetItem("id").ToString(); this.TestSetStatuses = new List <string[]>(); }
public TestRepositoryFolderTreeItem(BaseResponseItem node) : base(node) { entityType = EntityFolderType.Phase; if (((JArray)node.TryGetItem("categories")).Count > 0) { CurrentChildrens = new List <ITreeViewItem>(); } }
public ZephyrEntFolderTreeItem(BaseResponseItem node) : base(node) { }
public TestPlanningFolderTreeItem(BaseResponseItem node) : base(node) { }
internal bool ExportExceutionDetailsToALM(BusinessFlow bizFlow, ref string result, ObservableList <ExternalItemFieldBase> runFields, bool exectutedFromAutomateTab, PublishToALMConfig publishToALMConfig) { result = string.Empty; if (bizFlow.ExternalID == "0" || String.IsNullOrEmpty(bizFlow.ExternalID)) { result = GingerDicser.GetTermResValue(eTermResKey.BusinessFlow) + ": " + bizFlow.Name + " is missing ExternalID, cannot locate QC TestSet without External ID"; return(false); } try { //get the BF matching test set List <BaseResponseItem> exportedPhase = zephyrEntRepository.GetPhaseById(Convert.ToInt32(bizFlow.ExternalID2)); BaseResponseItem item = exportedPhase.FirstOrDefault(md => md.id.ToString().Equals(bizFlow.ExternalID)); if (item == null) { BaseResponseItem firstItem = exportedPhase.FirstOrDefault(); foreach (var category in (JArray)firstItem.TryGetItem("categories")) { BaseResponseItem treeNode = category.ToObject <BaseResponseItem>(); if (treeNode.id.ToString().Equals(bizFlow.ExternalID)) { item = treeNode; break; } } } if (item != null) { long scheduleId = 0; //get the Test set TC's List <TestCaseResource> testCaseResources = zephyrEntRepository.GetTestCasesByAssignmentTree(Convert.ToInt32(item.id)); //get phase execution list List <Execution> executions = zephyrEntRepository.GetExecutionsByPhaseId(Convert.ToInt64(bizFlow.ExternalID2)); //get all BF Activities groups ObservableList <ActivitiesGroup> activGroups = bizFlow.ActivitiesGroups; if (activGroups.Count > 0) { foreach (ActivitiesGroup activGroup in activGroups) { if ((publishToALMConfig.FilterStatus == FilterByStatus.OnlyPassed && activGroup.RunStatus == eActivitiesGroupRunStatus.Passed) || (publishToALMConfig.FilterStatus == FilterByStatus.OnlyFailed && activGroup.RunStatus == eActivitiesGroupRunStatus.Failed) || publishToALMConfig.FilterStatus == FilterByStatus.All) { TestCaseResource testCase = null; //go by TC ID = TC Instances ID testCase = testCaseResources.Find(x => x.testcase.testcaseId.ToString() == activGroup.ExternalID); if (testCase != null) { //get activities in group List <Activity> activities = (bizFlow.Activities.Where(x => x.ActivitiesGroupID == activGroup.Name)).Select(a => a).ToList(); string TestCaseName = PathHelper.CleanInValidPathChars(activGroup.Name); if ((publishToALMConfig.VariableForTCRunName == null) || (publishToALMConfig.VariableForTCRunName == string.Empty)) { String timeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss"); publishToALMConfig.VariableForTCRunName = "GingerRun_" + timeStamp; } scheduleId = executions.FindLast(tc => tc.tcrTreeTestcase.testcase.testcaseId.ToString().Equals(activGroup.ExternalID)).id; string notes = publishToALMConfig.VariableForTCRunNameCalculated; dynamic executionResult = zephyrEntRepository.ExecuteTestCase(scheduleId, GetTestStatus(activGroup), zephyrEntRepository.GetCurrentUser()[0].id, notes); if (executionResult == null) { result = "Failed to create run using rest API"; return(false); } // Attach ActivityGroup Report if needed if (publishToALMConfig.ToAttachActivitiesGroupReport) { 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 + "\\" + TestCaseName + "_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 Execution attachmentExecution = zephyrEntRepository.UpdateTestCaseAttachment(scheduleId.ToString(), zipFileName); if (attachmentExecution == null) { result = "Failed to create attachment"; return(false); } System.IO.File.Delete(zipFileName); } } } else { //No matching TC was found for the ActivitiesGroup in QC result = "Matching TC's were not found for all " + GingerDicser.GetTermResValue(eTermResKey.ActivitiesGroups) + " in QC/ALM."; } } if (result != string.Empty) { return(false); } } } else { //No matching Test Set was found for the BF in QC result = "No matching Test Set was found in QC/ALM."; } if (result == string.Empty) { result = "Export performed successfully."; return(true); } else { return(false); } } } catch (Exception ex) { result = "Unexpected error occurred- " + ex.Message; Reporter.ToLog(eLogLevel.ERROR, "Failed to export execution details to QC/ALM", ex); return(false); } return(false); // Remove it at the end }
public ZephyrEntTreeItem(BaseResponseItem node) { this.treeItemData = node; this.Name = node.TryGetItem("name").ToString(); this.Id = node.TryGetItem("id").ToString(); }
private bool ExportBusinessFlowToTestPlanning(BusinessFlow businessFlow, List <BaseResponseItem> matchingTS, string testLabUploadPath, Dictionary <string, string> testSetFieldsFields, Dictionary <string, string> testInstanceFields, ref string res) { Cycle cycle = null; CyclePhase cyclePhase = null; long folderId; long tcrCatalogTreeId; long testerId = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).GetCurrentUser(); bool isUpdate = false; // Update testset if (matchingTS != null && matchingTS.Count > 0) { testLabUploadPath = businessFlow.ExternalID; moduleParentId = businessFlow.ExternalID2; bfEntityType = matchingTS[0].TryGetItem("type").ToString(); if (bfEntityType.Equals(EntityFolderType.Phase.ToString())) { folderCycleId = moduleParentId; } isUpdate = true; } if (String.IsNullOrEmpty(testLabUploadPath)) { cycle = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).CreateNewTestCycle(); cyclePhase = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).CreateNewTestCyclePhase(cycle, businessFlow.Name); folderId = cyclePhase.id; tcrCatalogTreeId = cyclePhase.tcrCatalogTreeId; } else if (bfEntityType.Equals(EntityFolderType.Cycle.ToString()) || bfEntityType.Equals(EntityFolderType.CyclePhase.ToString())) { cycle = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).GetZephyrEntCycleById(Convert.ToInt32(testLabUploadPath)); cyclePhase = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).CreateNewTestCyclePhase(cycle, businessFlow.Name); folderId = cyclePhase.id; tcrCatalogTreeId = cyclePhase.tcrCatalogTreeId; } else if (bfEntityType.Equals(EntityFolderType.Phase.ToString())) { List <BaseResponseItem> phase = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).GetZephyrEntPhaseById(Convert.ToInt32(folderCycleId)); BaseResponseItem item = phase.FirstOrDefault(md => md.id.ToString().Equals(testLabUploadPath)); if (isUpdate) { ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).UpdateTestPlanningFolder(Convert.ToInt64(folderCycleId), Convert.ToInt64(item.TryGetItem("id")), businessFlow); return(true); } dynamic treeNode = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).CreateNewTestPlanningFolder(Convert.ToInt64(folderCycleId), Convert.ToInt64(item.TryGetItem("id")) , businessFlow.Name, String.IsNullOrEmpty(businessFlow.Description) ? businessFlow.Name + " description" : businessFlow.Description); folderId = Convert.ToInt64(folderCycleId); tcrCatalogTreeId = treeNode.id; } else { List <BaseResponseItem> module = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).GetTreeByCretiria(EntityFolderType.Module.ToString(), Convert.ToInt32(ALMCore.DefaultAlmConfig.ALMProjectKey), 180, Convert.ToInt32(moduleParentId)); BaseResponseItem item = module.FirstOrDefault(md => md.id.ToString().Equals(testLabUploadPath)); if (isUpdate) { ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).UpdateTestPlanningFolder(Convert.ToInt64(folderCycleId), Convert.ToInt64(item.TryGetItem("id")), businessFlow); return(true); } dynamic treeNode = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).CreateNewTestPlanningFolder(Convert.ToInt64(folderCycleId), Convert.ToInt64(item.TryGetItem("id")) , businessFlow.Name, String.IsNullOrEmpty(businessFlow.Description) ? businessFlow.Name + " description" : businessFlow.Description); folderId = Convert.ToInt64(folderCycleId); tcrCatalogTreeId = treeNode.id; } ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).AssigningTestCasesToCyclePhase(tcsRepositoryList.Select(z => z.id).ToList(), folderId, tcrCatalogTreeId); List <TestCaseResource> tcsPlanningList = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).GetTestCasesByAssignmentTree((int)tcrCatalogTreeId); List <Execution> assignsList = ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).AssigningTestCasesToTesterForExecution( tcsPlanningList.Select(z => z.tct.id).ToList(), folderId, testerId, tcrCatalogTreeId); ((ZephyrEntCore)ALMIntegration.Instance.AlmCore).ExecuteTestCases(assignsList, testerId, businessFlow.ActivitiesGroups); businessFlow.ExternalID = tcrCatalogTreeId.ToString(); businessFlow.ExternalID2 = folderId.ToString(); return(true); }