Example #1
0
        /// <summary>
        /// Get testcase by project and id
        /// </summary>
        /// <param name="project"></param>
        /// <param name="webId"></param>
        /// <returns></returns>
        public RQMTestCase GetTestCase(RQMProject project, string webId)
        {
            string requestUrl = string.Format("{0}/{1}/resources/{2}/testcase/urn:com.ibm.rqm:testcase:{3}", Url, RQMRESTfulUrl, project.Alias, webId);
            HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
            request.Method = "GET";
            request.CookieContainer = cookieContainer;

            string result = string.Empty;

            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                result = new StreamReader(response.GetResponseStream()).ReadToEnd();
            }

            XElement root = XElement.Parse(result);

            return new RQMTestCase(root);
        }
Example #2
0
 /// <summary>
 /// Get all test cases under specific project
 /// </summary>
 /// <param name="project"></param>
 /// <returns></returns>
 public IList<RQMTestCase> GetTestCasesByProject(RQMProject project)
 {
     return GetTestCasesByProject(project.Alias);
 }
Example #3
0
        /// <summary>
        /// Get the rankings of one project
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public IList<RQMRanking> GetRankingsOfProject(RQMProject project)
        {
            List<RQMRanking> rankings = new List<RQMRanking>();

            IList<RQMCategory> categories = GetCategoriesByProject(project);
            IList<RQMCategoryType> categoryTypes = GetCategoryTypesByProject(project);

            RQMCategoryType rankingType = categoryTypes.Where(t => t.Title == "Ranking" && t.Scope == "TestCase").FirstOrDefault();

            if (null != rankingType)
            {
                foreach (RQMCategory category in categories)
                {
                    if (category.CategoryType == rankingType.Id)
                    {
                        RQMRanking ranking = new RQMRanking();
                        ranking.Id = category.Id;
                        ranking.Title = category.Title;
                        rankings.Add(ranking);
                    }
                }
            }

            return rankings;
        }
Example #4
0
        /// <summary>
        /// Get the releases of one project
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public IList<RQMRelease> GetReleasesOfProject(RQMProject project)
        {
            List<RQMRelease> releases = new List<RQMRelease>();

            IList<RQMCategory> categories = GetCategoriesByProject(project);
            IList<RQMCategoryType> categoryTypes = GetCategoryTypesByProject(project);

            RQMCategoryType rankingType = categoryTypes.Where(t => t.Title == "Release" && t.Scope == "TestCase").FirstOrDefault();

            if (null != rankingType)
            {
                foreach (RQMCategory category in categories)
                {
                    if (category.CategoryType == rankingType.Id)
                    {
                        RQMRelease release = new RQMRelease();
                        release.Id = category.Id;
                        release.Title = category.Title;
                        releases.Add(release);
                    }
                }
            }

            return releases;
        }
Example #5
0
 /// <summary>
 /// Get the features' hierarchy, here we have an assumption that there're only two level for feature in RQM
 /// </summary>
 /// <param name="project"></param>
 /// <returns></returns>
 public IList<RQMFeature> GetFeaturesOfProject(RQMProject project)
 {
     List<RQMFeature> features = new List<RQMFeature>();
     IList<RQMCategoryType> categoriyTypes = GetCategoryTypesByProject(project);
     RQMCategoryType featuresType = categoriyTypes.Where(ct => ct.Title == "Features" && ct.Scope == "TestCase").FirstOrDefault();
     if (null != featuresType)
     {
         foreach (KeyValuePair<string, List<string>> keyValuePair in featuresType.ValueSets)
         {
             RQMFeature feature = new RQMFeature();
             RQMCategory featureCategory = GetCategoryByLink(keyValuePair.Key);
             feature.Id = featureCategory.Id;
             feature.Title = featureCategory.Title;
             feature.SubFeatures = new List<RQMFeature>();
             foreach (string link in keyValuePair.Value)
             {
                 RQMCategory subFeatureCategory = GetCategoryByLink(link);
                 RQMFeature subFeature = new RQMFeature();
                 subFeature.Id = subFeatureCategory.Id;
                 subFeature.Title = subFeatureCategory.Title;
                 feature.SubFeatures.Add(subFeature);
             }
             features.Add(feature);
         }
     }
     return features;
 }
Example #6
0
        /// <summary>
        /// Get all the modules of one project
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public IList<RQMModule> GetModulesOfProject(RQMProject project)
        {
            List<RQMModule> modules = new List<RQMModule>();

            IList<RQMCategory> categories = GetCategoriesByProject(project);
            IList<RQMCategoryType> categoryTypes = GetCategoryTypesByProject(project);

            RQMCategoryType modulesType = categoryTypes.Where(t => t.Title == "Module" && t.Scope == "TestCase").FirstOrDefault();

            if (null != modulesType)
            {
                foreach (RQMCategory category in categories)
                {
                    if (category.CategoryType == modulesType.Id)
                    {
                        RQMModule module = new RQMModule();
                        module.Id = category.Id;
                        module.Title = category.Title;
                        modules.Add(module);
                    }
                }
            }
            return modules;
        }
Example #7
0
        /// <summary>
        /// Get all execution work item of specific project
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public IList<RQMExecutionWorkItem> GetExecutionWorkItemByProject(RQMProject project)
        {
            string requestUrl = string.Format("{0}/{1}/resources/{2}/executionworkitem?abbreviate=false", Url, RQMRESTfulUrl, project.Alias);
            HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
            request.Method = "GET";
            request.CookieContainer = cookieContainer;

            string result = string.Empty;

            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                result = new StreamReader(response.GetResponseStream()).ReadToEnd();
            }

            XElement root = XElement.Parse(result);

            IList<RQMExecutionWorkItem> testCases = new List<RQMExecutionWorkItem>();

            foreach (var xml in root.Elements(RQMServer.XN + "entry"))
            {
                testCases.Add(new RQMExecutionWorkItem(xml.Element(RQMServer.XN + "content").Element(RQMServer.XN2 + "executionworkitem")));
            }

            return testCases;
        }
Example #8
0
        /// <summary>
        /// Get all the category types of the project
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public IList<RQMCategoryType> GetCategoryTypesByProject(RQMProject project)
        {
            IList<RQMCategoryType> categoryTypes = new List<RQMCategoryType>();

            string requestUrl = string.Format("{0}/{1}/resources/{2}/categoryType?abbreviate=false", Url, RQMRESTfulUrl, project.Alias);

            do
            {
                HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
                request.Method = "GET";
                request.CookieContainer = cookieContainer;

                string result = string.Empty;

                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    result = new StreamReader(response.GetResponseStream()).ReadToEnd();
                }

                XElement root = XElement.Parse(result);

                foreach (var xml in root.Elements(RQMServer.XN + "entry"))
                {
                    categoryTypes.Add(new RQMCategoryType(xml.Element(RQMServer.XN + "content").Element(RQMServer.XN2 + "categoryType")));
                }

                var nextLink = (root.Elements(RQMServer.XN + "link").Where(l => l.Attribute("rel").Value == "next")).SingleOrDefault();

                requestUrl = nextLink == null ? string.Empty : nextLink.Attribute("href").Value;

            } while (!string.IsNullOrWhiteSpace(requestUrl));

            return categoryTypes;
        }
Example #9
0
        public List<string> GetAllTestCaseRankings()
        {
            try
            {
                ATFEnvironment.Log.logger.Info("RQM Login");

                RQMServer.UserAuthentication(Username, Password);

                ATFEnvironment.Log.logger.Info("RQM Get Rankins Start");

                RQMProject project = new RQMProject();

                project.Alias = ProjectAlias;

                List<string> rankings = new List<string>();

                foreach (RQMRanking rank in RQMServer.GetRankingsOfProject(project))
                {
                    rankings.Add(rank.Title);
                }

                ATFEnvironment.Log.logger.Info("RQM Get Rankins Finished");

                return rankings;
            }
            catch (Exception ex)
            {
                ATFEnvironment.Log.logger.Error("Failed to get all the rankings from RQM server.", ex);
                return new List<string>();
            }
        }
Example #10
0
 private void CreateOrUpdateModuleLevelSuite(TestSuite projectSuite, RQMProject project)
 {
     IList<RQMModule> modules = RQMServer.GetModulesOfProject(project);
     IList<TestSuite> moduleSuites = TestSuite.GetAllSubSuites(projectSuite);
     //disable all the module level suites firstly
     projectSuite.DisableSubTestSuites();
     //iterate all the modules in RQM server, enable the existing one and add new ones
     foreach (RQMModule m in modules)
     {
         TestSuite moduleSuite = moduleSuites.Where(s => s.Name == m.Title).FirstOrDefault();
         if (null == moduleSuite)
         {
             //add module suite
             TestSuite temp = new TestSuite
             {
                 Name = m.Title,
                 ProviderId = Provider.ProviderId,
                 IsActive = true,
                 Description = string.Format("Title=Module {0} in RQM, Type={1}", m.Title, SuiteType.Static.ToString()),
                 TestCases = null,
                 SubSuites = null,
                 CreateBy = 0,
                 ModityBy = 0,
             };
             moduleSuite = TestSuite.CreateSuite(temp);
             projectSuite.AddSubTestSuite(moduleSuite.SuiteId);
             CreateOrUpdateFeatureLevelSuite(moduleSuite, project);
         }
         else
         {
             moduleSuite.IsActive = true;
             moduleSuite.ProviderId = Provider.ProviderId;
             moduleSuite.Update();
             CreateOrUpdateFeatureLevelSuite(moduleSuite, project);
         }
     }
 }
Example #11
0
        private void CreateOrUpdateFeatureLevelSuite(TestSuite moduleSuite, RQMProject project)
        {
            IList<RQMFeature> modules = RQMServer.GetFeaturesOfProject(project);
            IList<TestSuite> featureSuites = TestSuite.GetAllSubSuites(moduleSuite);
            moduleSuite.DisableSubTestSuites();
            RQMFeature module = modules.Where(m => m.Title == moduleSuite.Name).FirstOrDefault();
            if (null != module)
            {
                IList<RQMFeature> features = module.SubFeatures;
                foreach (RQMFeature feature in features)
                {
                    TestSuite featureSuite = featureSuites.Where(s => s.Name == feature.Title).FirstOrDefault();
                    if (null == featureSuite)
                    {
                        TestSuite temp = new TestSuite
                        {
                            Name = feature.Title,
                            ProviderId = Provider.ProviderId,
                            IsActive = true,
                            TestCases = null,
                            SubSuites = null,
                            Description = string.Format("Title=Feature {0} in RQM, Type={1}", feature.Title, SuiteType.Static.ToString()),
                            CreateBy = 0,
                            ModityBy = 0,
                        };
                        featureSuite = TestSuite.CreateSuite(temp);
                        moduleSuite.AddSubTestSuite(featureSuite.SuiteId);
                    }
                    else
                    {
                        featureSuite.IsActive = true;
                        featureSuite.ProviderId = Provider.ProviderId;
                        featureSuite.Update();
                    }
                }
            }
            else
            {

            }
        }