private String generateJiraComment()

in ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java [871:1013]


    private String generateJiraComment(List<ShortSuiteUi> suites, List<ShortSuiteNewTestsUi> newTestsStatuses, String webUrl, String buildTypeId,
        ITeamcityIgnited tcIgnited, int blockers, String branchName, String baseBranch) {
        BuildTypeRefCompacted bt = tcIgnited.getBuildTypeRef(buildTypeId);

        String suiteNameUsedForVisa = (bt != null ? bt.name(compactor) : buildTypeId);

        StringBuilder res = new StringBuilder();

        String baseBranchDisp = (Strings.isNullOrEmpty(baseBranch) || ITeamcity.DEFAULT.equals(baseBranch))
            ? "master" :  baseBranch ;
        for (ShortSuiteUi suite : suites) {
            res.append("{color:#d04437}");

            res.append(jiraEscText(suite.name)).append("{color}");

            int totalBlockerTests = suite.testFailures().size();
            res.append(" [[tests ").append(totalBlockerTests);

            if (suite.result != null && !suite.result.isEmpty())
                res.append(' ').append(suite.result);

            res.append('|').append(suite.webToBuild).append("]]\\n");

            int cnt = 0;

            for (ShortTestFailureUi failure : suite.testFailures()) {
                res.append("* ");

                if (failure.suiteName != null && failure.testName != null)
                    res.append(jiraEscText(failure.suiteName)).append(": ").append(jiraEscText(failure.testName));
                else
                    res.append(jiraEscText(failure.name));

                res.append(" - ").append(jiraEscText(failure.blockerComment));

                res.append("\\n");

                cnt++;
                if (cnt > 10) {
                    res.append("... and ").append(totalBlockerTests - cnt).append(" tests blockers\\n");

                    break;
                }
            }

            res.append("\\n");
        }

        StringBuilder newTests = new StringBuilder();

        int newTestsCount = 0;

        int failedNewTestsCount = 0;

        for (ShortSuiteNewTestsUi suite : newTestsStatuses) {
            newTests.append("{color:#00008b}");

            newTests.append(jiraEscText(suite.name)).append("{color}");

            int totalNewTests = suite.tests.size();
            newTests.append(" [[tests ").append(totalNewTests);

            int cnt = 0;

            newTestsCount += suite.tests().size();

            newTests.append('|').append(suite.webToBuild).append("]]\\n");

            for (ShortTestUi test : suite.tests()) {
                String testColor;
                if (test.status)
                    testColor = "#013220";
                else {
                    testColor = "#8b0000";
                    failedNewTestsCount++;
                }

                newTests.append("* ");

                newTests.append(String.format("{color:%s}", testColor));

                if (test.suiteName != null && test.testName != null)
                    newTests.append(jiraEscText(test.suiteName)).append(": ").append(jiraEscText(test.testName));
                else
                    newTests.append(jiraEscText(test.name));

                newTests.append(" - ").append(jiraEscText(test.status ? "PASSED" : "FAILED"));

                newTests.append("{color}");

                newTests.append("\\n");

                cnt++;
                if (cnt > 10) {
                    newTests.append("... and ").append(totalNewTests - cnt).append(" new tests\\n");

                    break;
                }
            }

            newTests.append("\\n");
        }

        String suiteNameForComment = jiraEscText(suiteNameUsedForVisa);

        String branchNameForComment = jiraEscText("Branch: [" + branchName + "] ");

        String baseBranchForComment = jiraEscText("Base: [" + baseBranchDisp + "] ");
        String branchVsBaseComment = branchNameForComment + baseBranchForComment;

        if (res.length() > 0) {
            String hdrPanel = "{panel:title=" + branchVsBaseComment + ": Possible Blockers (" + blockers + ")|" +
                "borderStyle=dashed|borderColor=#ccc|titleBGColor=#F7D6C1}\\n";

            res.insert(0, hdrPanel)
                .append("{panel}");
        }
        else {
            res.append("{panel:title=").append(branchVsBaseComment).append(": No blockers found!|")
                .append("borderStyle=dashed|borderColor=#ccc|titleBGColor=#D6F7C1}{panel}");
        }

        if (newTests.length() > 0) {
            String bgColor;
            if (failedNewTestsCount > 0)
                bgColor = "#F7D6C1";
            else
                bgColor = "#D6F7C1";
            String hdrPanel = "{panel:title=" + branchVsBaseComment + ": New Tests (" + newTestsCount + ")|" +
                "borderStyle=dashed|borderColor=#ccc|titleBGColor=" + bgColor + "}\\n";

            newTests.insert(0, hdrPanel)
                .append("{panel}");
        }
        else {
            newTests.append("{panel:title=").append(branchVsBaseComment).append(": No new tests found!|")
                .append("borderStyle=dashed|borderColor=#ccc|titleBGColor=#F7D6C1}{panel}");
        }

        res.append("\\n").append(newTests).append("\\n").append("[TeamCity *").append(suiteNameForComment).append("* Results|").append(webUrl).append(']');

        return xmlEscapeText(res.toString());
    }