public void PageIsOverridden()
    {
        string baseUri                = "http://sonarqube.test.de/";
        string projectKey             = "project-key";
        string metrics                = "ncloc,bugs,vulnerabilities";
        int    page                   = 2;
        SqComponentTreeUriBuilder uri = new SqComponentTreeUriBuilder(baseUri, projectKey, metrics);

        uri.Page(1);
        uri.Page(page);

        string expectedUri = baseUri + "api/measures/component_tree"
                             + "?baseComponentKey=" + projectKey + "&metricKeys="
                             + metrics + "&" + "p=" + page;

        Assert.AreEqual(expectedUri, uri.GetSqUri().ToString());
    }
Example #2
0
        /// <summary>
        /// Requests all project components and their metrics from the sonarqube api
        /// </summary>
        /// <param name="projectKey">SonarQube Project Key</param>
        /// <param name="page">The page of the request, should be 1.
        /// The other calls are recursive in the method.</param>
        private void LoadOnlineProject(string projectKey, int page)
        {
            SqComponentTreeUriBuilder uriBuilder
                = new SqComponentTreeUriBuilder(model.GetBaseUrl(), projectKey,
                                                model.GetAvailableMetricsAsString());

            if (model.GetUsername() != "" && model.GetPassword() != "")
            {
                uriBuilder.UserCredentials(model.GetUsername(), model.GetPassword());
            }

            StartCoroutine(WebInterface.WebRequest <ComponentTree>(
                               uriBuilder.Page(page).GetSqUri(),
                               (res, err) =>
            {
                switch (err)
                {
                case 200:
                    model.BuildProjectTree(res.baseComponent, res.components);

                    int TotalNumOfPages = res.paging.total / res.paging.pageSize + 1;
                    if (page < TotalNumOfPages)
                    {
                        LoadOnlineProject(projectKey, page + 1);
                    }
                    else
                    {
                        if (cityLoadingState != CityLoadingState.LodingError)
                        {
                            cityLoadingState = CityLoadingState.Ready;
                        }
                        ComponentTreeStream.SaveProjectComponent(model.GetTree());
                    }
                    break;

                default:
                    Debug.Log("Addyi ResponseCode: " + err);
                    cityLoadingState = CityLoadingState.LodingError;
                    break;
                }
            }));
        }