diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2018-03-20 15:24:01 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-03-29 20:20:47 +0200 |
commit | 1a555c731d31473398dcef019ca30212393cbb3f (patch) | |
tree | b799814f6c862e8422b82535e21155cfda56c484 | |
parent | 1b0d202bc0741274469e50f8bf77b17d951952a3 (diff) | |
download | sonarqube-1a555c731d31473398dcef019ca30212393cbb3f.tar.gz sonarqube-1a555c731d31473398dcef019ca30212393cbb3f.zip |
SONAR-10486 Generate project badges also on SonarQube
17 files changed, 212 insertions, 47 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsModule.java index ec7be189267..0a351bf2164 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/ProjectBadgesWsModule.java @@ -19,24 +19,12 @@ */ package org.sonar.server.badge.ws; -import org.sonar.api.config.Configuration; import org.sonar.core.platform.Module; -import static org.sonar.process.ProcessProperties.Property.SONARCLOUD_ENABLED; - public class ProjectBadgesWsModule extends Module { - private final Configuration config; - - public ProjectBadgesWsModule(Configuration config) { - this.config = config; - } - @Override protected void configureModule() { - if (!config.getBoolean(SONARCLOUD_ENABLED.getKey()).orElse(false)) { - return; - } add( ProjectBadgesWs.class, QualityGateAction.class, diff --git a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/SvgGenerator.java b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/SvgGenerator.java index 146127df938..0da1c8fa654 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/badge/ws/SvgGenerator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/badge/ws/SvgGenerator.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.util.Map; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.text.StrSubstitutor; +import org.sonar.api.config.Configuration; import org.sonar.api.measures.Metric; import org.sonar.api.server.ServerSide; @@ -35,10 +36,14 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.sonar.api.measures.Metric.Level.ERROR; import static org.sonar.api.measures.Metric.Level.OK; import static org.sonar.api.measures.Metric.Level.WARN; +import static org.sonar.process.ProcessProperties.Property.SONARCLOUD_ENABLED; @ServerSide public class SvgGenerator { + private static final String TEMPLATES_SONARCLOUD = "templates/sonarcloud"; + private static final String TEMPLATES_SONARQUBE = "templates/sonarqube"; + private static final FontRenderContext FONT_RENDER_CONTEXT = new FontRenderContext(new AffineTransform(), true, true); private static final Font FONT = new Font("Verdana", Font.PLAIN, 11); @@ -58,13 +63,15 @@ public class SvgGenerator { private final String badgeTemplate; private final Map<Metric.Level, String> qualityGateTemplates; - public SvgGenerator() { - this.errorTemplate = readTemplate("error.svg"); - this.badgeTemplate = readTemplate("badge.svg"); + public SvgGenerator(Configuration config) { + boolean isOnSonarCloud = config.getBoolean(SONARCLOUD_ENABLED.getKey()).orElse(false); + String templatePath = isOnSonarCloud ? TEMPLATES_SONARCLOUD : TEMPLATES_SONARQUBE; + this.errorTemplate = readTemplate("templates/error.svg"); + this.badgeTemplate = readTemplate(templatePath + "/badge.svg"); this.qualityGateTemplates = ImmutableMap.of( - OK, readTemplate("quality_gate_passed.svg"), - WARN, readTemplate("quality_gate_warn.svg"), - ERROR, readTemplate("quality_gate_failed.svg")); + OK, readTemplate(templatePath + "/quality_gate_passed.svg"), + WARN, readTemplate(templatePath + "/quality_gate_warn.svg"), + ERROR, readTemplate(templatePath + "/quality_gate_failed.svg")); } public String generateBadge(String label, String value, Color backgroundValueColor) { @@ -103,7 +110,7 @@ public class SvgGenerator { private String readTemplate(String template) { try { - return IOUtils.toString(getClass().getResource("templates/" + template), UTF_8); + return IOUtils.toString(getClass().getResource(template), UTF_8); } catch (IOException e) { throw new IllegalStateException(String.format("Can't read svg template '%s'", template), e); } diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/badge.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarcloud/badge.svg index 5a295899265..5a295899265 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/badge.svg +++ b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarcloud/badge.svg diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/quality_gate_failed.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarcloud/quality_gate_failed.svg index 38a288fda43..38a288fda43 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/quality_gate_failed.svg +++ b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarcloud/quality_gate_failed.svg diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/quality_gate_passed.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarcloud/quality_gate_passed.svg index eae908e800c..eae908e800c 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/quality_gate_passed.svg +++ b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarcloud/quality_gate_passed.svg diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/quality_gate_warn.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarcloud/quality_gate_warn.svg index 420cda6dc34..420cda6dc34 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/quality_gate_warn.svg +++ b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarcloud/quality_gate_warn.svg diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/badge.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/badge.svg new file mode 100644 index 00000000000..a25766b1e9e --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/badge.svg @@ -0,0 +1,22 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="20" width="${totalWidth}"> + <linearGradient id="b" x2="0" y2="100%"> + <stop offset="0" stop-color="#bbb" stop-opacity=".1"/> + <stop offset="1" stop-opacity=".1"/> + </linearGradient> + <clipPath id="a"> + <rect width="${totalWidth}" height="20" rx="3" fill="#fff"/> + </clipPath> + <g clip-path="url(#a)"> + <rect fill="#555" height="20" width="${labelWidth}"/> + <rect fill="${color}" height="20" width="${valueWidth}" x="${labelWidth}"/> + <rect fill="url(#b)" height="20" width="${totalWidth}"/> + </g> + <g fill="#fff" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11" text-anchor="left"> + <text x="${iconWidthPlusMargin}" y="15" fill="#010101" fill-opacity=".3">${label}</text> + <text x="${iconWidthPlusMargin}" y="14">${label}</text> + <text x="${labelWidthPlusMargin}" y="15" fill="#010101" fill-opacity=".3">${value}</text> + <text x="${labelWidthPlusMargin}" y="14">${value}</text> + </g> + <path fill="#010101" fill-opacity=".3" d="M19.58682 9.81722A3.78893 3.78893 0 0 0 17.78048 8.603v-.04378a3.77165 3.77165 0 1 0-7.5433 0v.05069a3.77165 3.77165 0 1 0 3.78317 6.28186 3.7705 3.7705 0 0 0 5.56416-5.0688zm-2.91802 5.21164a2.8247 2.8247 0 0 1-2.8224-2.82124.47463.47463 0 0 0-.94925 0 3.7486 3.7486 0 0 0 .53223 1.9296 2.8201 2.8201 0 1 1-1.08058-4.57805h.01152a1.3202 1.3202 0 0 1 .30758.14745.4747.4747 0 0 0 .61748-.72115 2.1266 2.1266 0 0 0-.61402-.32371 3.75898 3.75898 0 0 0-1.29946-.2304h-.182a2.82125 2.82125 0 1 1 4.45478 2.4192.47462.47462 0 1 0 .55066.773 3.78317 3.78317 0 0 0 1.44806-2.0736 2.8224 2.8224 0 0 1-.97574 5.46969z"/> + <path fill="#f3702a" d="M19.58682 9.09722A3.78893 3.78893 0 0 0 17.78048 7.883v-.04378a3.77165 3.77165 0 1 0-7.5433 0v.05069a3.77165 3.77165 0 1 0 3.78317 6.28186 3.7705 3.7705 0 0 0 5.56416-5.0688zm-2.91802 5.21164a2.8247 2.8247 0 0 1-2.8224-2.82124.47463.47463 0 0 0-.94925 0 3.7486 3.7486 0 0 0 .53223 1.9296 2.8201 2.8201 0 1 1-1.08058-4.57805h.01152a1.3202 1.3202 0 0 1 .30758.14745.4747.4747 0 0 0 .61748-.72115 2.1266 2.1266 0 0 0-.61402-.32371 3.75898 3.75898 0 0 0-1.29946-.2304h-.182a2.82125 2.82125 0 1 1 4.45478 2.4192.47462.47462 0 1 0 .55066.773 3.78317 3.78317 0 0 0 1.44806-2.0736 2.8224 2.8224 0 0 1-.97574 5.46969z"/> +</svg>
\ No newline at end of file diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_failed.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_failed.svg new file mode 100644 index 00000000000..a83f9c79d62 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_failed.svg @@ -0,0 +1,13 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 350 262.5" width="128px" height="96px"> + <path fill="#fff" d="M328.4 259.5H21.3c-10.6 0-19.5-8.7-19.5-19.5V22c0-10.6 8.7-19.5 19.5-19.5h307.1c10.6 0 19.5 8.7 19.5 19.5v218c0 10.8-8.9 19.5-19.5 19.5z"/> + <path fill="#cfd3d7" d="M328.4 260.4H21.3C10.1 260.4.9 251.2.9 240V22c0-11.2 9.2-20.4 20.4-20.4h307.1c11.2 0 20.4 9.2 20.4 20.4v218c0 11.2-9.3 20.4-20.4 20.4zM21.3 3.4C11 3.4 2.7 11.7 2.7 22v218c0 10.3 8.3 18.6 18.6 18.6h307.1c10.3 0 18.6-8.3 18.6-18.6V22c0-10.3-8.3-18.6-18.6-18.6H21.3z"/> + <path fill="#434447" d="M94.9 54.3c0 2.7-.4 5-1.3 7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l-.9 3.1c-1-.6-2.5-1.1-4.7-1.1-5.1 0-7.9 3.8-7.9 8.4 0 5.2 3.3 8.3 7.7 8.3 2.3 0 3.8-.6 5-1.1l.7 3.2zM170.9 189.4h4.1v32.7h-4.1v-32.7zM200.1 210.8c0 8.3-5.7 11.9-11.1 11.9-6 0-10.7-4.4-10.7-11.5 0-7.5 4.9-11.9 11.1-11.9 6.4 0 10.7 4.7 10.7 11.5zm-17.7.2c0 4.9 2.8 8.6 6.8 8.6 3.9 0 6.8-3.6 6.8-8.7 0-3.8-1.9-8.6-6.7-8.6-4.8.1-6.9 4.5-6.9 8.7zM222.1 216c0 2.3 0 4.3.2 6.1h-3.6l-.2-3.6h-.1c-1.1 1.8-3.4 4.2-7.4 4.2-3.5 0-7.7-1.9-7.7-9.8v-13.1h4.1v12.4c0 4.2 1.3 7.1 5 7.1 2.7 0 4.6-1.9 5.3-3.7.2-.6.4-1.3.4-2.1v-13.7h4.1V216h-.1zM246.2 189.4v27c0 2 0 4.2.2 5.8h-3.6l-.2-3.9h-.1c-1.2 2.5-4 4.4-7.6 4.4-5.4 0-9.5-4.6-9.5-11.3 0-7.4 4.6-12 10-12 3.4 0 5.7 1.6 6.7 3.4h.1v-13.3l4-.1zm-4 19.5c0-.5 0-1.2-.2-1.7-.6-2.6-2.8-4.7-5.9-4.7-4.2 0-6.7 3.7-6.7 8.6 0 4.5 2.2 8.3 6.6 8.3 2.7 0 5.2-1.8 5.9-4.8.1-.6.2-1.1.2-1.8l.1-3.9z"/> + </g> +</svg>
\ No newline at end of file diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_passed.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_passed.svg new file mode 100644 index 00000000000..12bc8205ff8 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_passed.svg @@ -0,0 +1,13 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 350 262.5" width="128px" height="96px"> + <path fill="#fff" d="M328.4 259.5H21.5C10.9 259.5 2 250.8 2 240V21.9C2 11.3 10.7 2.4 21.5 2.4h307.1c10.6 0 19.5 8.7 19.5 19.5V240c-.2 10.8-8.8 19.5-19.7 19.5z"/> + <path fill="#cfd3d7" d="M328.4 260.4H21.5c-11.2 0-20.4-9.2-20.4-20.4V21.9c0-11.2 9-20.4 20.4-20.4h307.1c11.2 0 20.4 9.2 20.4 20.4V240c-.2 11.2-9.2 20.4-20.6 20.4zM21.5 3.3c-10.3 0-18.6 8.3-18.6 18.6V240c0 10.3 8.3 18.6 18.6 18.6h307.1c10.3 0 18.6-8.3 18.6-18.6V21.9c0-10.3-8.3-18.6-18.6-18.6H21.5z"/> + <path fill="#434447" d="M94.9 54.1c0 2.7-.4 5-1.3 7-.9 1.9-2.1 3.5-3.6 4.6l5 3.9-2.5 2.3-5.9-4.7c-.9.2-1.9.3-2.9.3-2.2 0-4.1-.5-5.8-1.6-1.7-1.1-3-2.6-3.9-4.6-.9-2-1.4-4.3-1.4-6.9v-2c0-2.7.5-5 1.4-7.1.9-2.1 2.2-3.6 3.9-4.7s3.6-1.6 5.8-1.6c2.2 0 4.2.5 5.9 1.6 1.7 1.1 3 2.6 3.9 4.7.9 2 1.4 4.4 1.4 7.1v1.7zm-3.6-1.8c0-3.3-.7-5.8-2-7.6-1.3-1.8-3.2-2.7-5.6-2.7-2.3 0-4.1.9-5.5 2.6-1.3 1.8-2 4.2-2.1 7.4v2c0 3.2.7 5.7 2 7.5 1.3 1.8 3.2 2.8 5.6 2.8s4.2-.9 5.5-2.6c1.3-1.7 2-4.2 2-7.4v-2zM112.8 65.1c-1.4 1.6-3.4 2.4-6.1 2.4-2.2 0-3.9-.6-5-1.9s-1.7-3.2-1.7-5.7V46.5h3.5v13.4c0 3.1 1.3 4.7 3.8 4.7 2.7 0 4.5-1 5.4-3v-15h3.5v20.7h-3.4v-2.2zM134.4 67.1c-.2-.4-.4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h-.1c-1.2 2.5-4 4.4-7.6 4.4-5.4 0-9.5-4.6-9.5-11.3 0-7.4 4.6-12 10-12 3.4 0 5.7 1.6 6.7 3.4h.1v-13.3l4-.1zm-4 19.5c0-.5 0-1.2-.2-1.7-.6-2.6-2.8-4.7-5.9-4.7-4.2 0-6.7 3.7-6.7 8.6 0 4.5 2.2 8.3 6.6 8.3 2.7 0 5.2-1.8 5.9-4.8.1-.6.2-1.1.2-1.8l.1-3.9z"/> + </g> +</svg>
\ No newline at end of file diff --git a/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_warn.svg b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_warn.svg new file mode 100644 index 00000000000..48e4d353950 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/sonarqube/quality_gate_warn.svg @@ -0,0 +1,13 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 350 262.5" width="128px" height="96px"> + <path fill="#fff" d="M328.4 259.5H21.3c-10.6 0-19.5-8.7-19.5-19.5V22c0-10.6 8.7-19.5 19.5-19.5h307.1c10.6 0 19.5 8.7 19.5 19.5v218c0 10.8-8.9 19.5-19.5 19.5z"/> + <path fill="#cfd3d7" d="M328.4 260.4H21.3C10.1 260.4.9 251.2.9 240V22c0-11.2 9.2-20.4 20.4-20.4h307.1c11.2 0 20.4 9.2 20.4 20.4v218c0 11.2-9.3 20.4-20.4 20.4zM21.3 3.4C11 3.4 2.7 11.7 2.7 22v218c0 10.3 8.3 18.6 18.6 18.6h307.1c10.3 0 18.6-8.3 18.6-18.6V22c0-10.3-8.3-18.6-18.6-18.6H21.3z"/> + <path fill="#434447" d="M94.9 54.3c0 2.7-.4 5-1.3 7-.9 1.9-2.1 3.5-3.6 4.6l5 3.9-2.5 2.2-5.9-4.7c-.9.2-1.9.3-2.9.3-2.2 0-4.1-.5-5.8-1.6-1.7-1.1-3-2.6-3.9-4.6s-1.4-4.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4h-7V207zM167.9 221.3c-1.1.6-3.4 1.3-6.4 1.3-6.7 0-11.1-4.6-11.1-11.4 0-6.9 4.7-11.9 12-11.9 2.4 0 4.5.6 5.6 1.2l-.9 3.1c-1-.6-2.5-1.1-4.7-1.1-5.1 0-7.9 3.8-7.9 8.4 0 5.2 3.3 8.3 7.7 8.3 2.3 0 3.8-.6 5-1.1l.7 3.2zM170.9 189.4h4.1v32.7h-4.1v-32.7zM200.1 210.8c0 8.3-5.7 11.9-11.1 11.9-6 0-10.7-4.4-10.7-11.5 0-7.5 4.9-11.9 11.1-11.9 6.4 0 10.7 4.7 10.7 11.5zm-17.7.2c0 4.9 2.8 8.6 6.8 8.6 3.9 0 6.8-3.6 6.8-8.7 0-3.8-1.9-8.6-6.7-8.6-4.8.1-6.9 4.5-6.9 8.7zM222.1 216c0 2.3 0 4.3.2 6.1h-3.6l-.2-3.6h-.1c-1.1 1.8-3.4 4.2-7.4 4.2-3.5 0-7.7-1.9-7.7-9.8v-13.1h4.1v12.4c0 4.2 1.3 7.1 5 7.1 2.7 0 4.6-1.9 5.3-3.7.2-.6.4-1.3.4-2.1v-13.7h4.1V216h-.1zM246.2 189.4v27c0 2 0 4.2.2 5.8h-3.6l-.2-3.9h-.1c-1.2 2.5-4 4.4-7.6 4.4-5.4 0-9.5-4.6-9.5-11.3 0-7.4 4.6-12 10-12 3.4 0 5.7 1.6 6.7 3.4h.1v-13.3l4-.1zm-4 19.5c0-.5 0-1.2-.2-1.7-.6-2.6-2.8-4.7-5.9-4.7-4.2 0-6.7 3.7-6.7 8.6 0 4.5 2.2 8.3 6.6 8.3 2.7 0 5.2-1.8 5.9-4.8.1-.6.2-1.1.2-1.8l.1-3.9z"/> + </g> +</svg>
\ No newline at end of file diff --git a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java index 034441c567d..1f1f9e00f11 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java @@ -26,6 +26,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.sonar.api.config.internal.MapSettings; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric.Level; import org.sonar.api.server.ws.WebService; @@ -70,8 +71,10 @@ public class MeasureActionTest { @Rule public DbTester db = DbTester.create(); + private MapSettings mapSettings = new MapSettings().setProperty("sonar.sonarcloud.enabled", false); + private WsActionTester ws = new WsActionTester( - new MeasureAction(userSession, db.getDbClient(), new ComponentFinder(db.getDbClient(), null), new SvgGenerator())); + new MeasureAction(userSession, db.getDbClient(), new ComponentFinder(db.getDbClient(), null), new SvgGenerator(mapSettings.asConfig()))); @Test public void int_measure() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/ProjectBadgesWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/ProjectBadgesWsModuleTest.java index 0b6f717b2c0..856b0c7dc8b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/ProjectBadgesWsModuleTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/ProjectBadgesWsModuleTest.java @@ -20,7 +20,6 @@ package org.sonar.server.badge.ws; import org.junit.Test; -import org.sonar.api.config.internal.MapSettings; import org.sonar.core.platform.ComponentContainer; import static org.assertj.core.api.Assertions.assertThat; @@ -29,25 +28,13 @@ import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COM public class ProjectBadgesWsModuleTest { private ComponentContainer container = new ComponentContainer(); - private MapSettings mapSettings = new MapSettings(); - private ProjectBadgesWsModule underTest = new ProjectBadgesWsModule(mapSettings.asConfig()); + private ProjectBadgesWsModule underTest = new ProjectBadgesWsModule(); @Test public void verify_count_of_added_components() { - mapSettings.setProperty("sonar.sonarcloud.enabled", true); - underTest.configure(container); assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 4); } - @Test - public void no_component_when_not_on_sonar_cloud() { - mapSettings.setProperty("sonar.sonarcloud.enabled", false); - - underTest.configure(container); - - assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER); - } - } diff --git a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java index 2071e6c2c6f..5b9d0c94fec 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java @@ -24,6 +24,7 @@ import org.apache.commons.io.IOUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.sonar.api.config.internal.MapSettings; import org.sonar.api.measures.Metric.Level; import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; @@ -55,8 +56,10 @@ public class QualityGateActionTest { @Rule public DbTester db = DbTester.create(); + private MapSettings mapSettings = new MapSettings().setProperty("sonar.sonarcloud.enabled", false); + private WsActionTester ws = new WsActionTester( - new QualityGateAction(userSession, db.getDbClient(), new ComponentFinder(db.getDbClient(), null), new SvgGenerator())); + new QualityGateAction(userSession, db.getDbClient(), new ComponentFinder(db.getDbClient(), null), new SvgGenerator(mapSettings.asConfig()))); @Test public void quality_gate_passed() { @@ -217,7 +220,7 @@ public class QualityGateActionTest { private String readTemplate(String template) { try { - return IOUtils.toString(getClass().getResource("templates/" + template), UTF_8); + return IOUtils.toString(getClass().getResource("templates/sonarqube/" + template), UTF_8); } catch (IOException e) { throw new IllegalStateException(String.format("Can't read svg template '%s'", template), e); } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectBadgesTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectBadgesTest.java index 3e9f23f0a60..cc47c835350 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectBadgesTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectBadgesTest.java @@ -1,6 +1,6 @@ /* * SonarQube - * Copyright (C) 2009-2018 SonarSource SA + * Copyright (C) 2009-2017 SonarSource SA * mailto:info AT sonarsource DOT com * * This program is free software; you can redistribute it and/or @@ -43,10 +43,9 @@ public class ProjectBadgesTest { private static final String WS_MEASURE_BADGES_ON_QUALITY_GATE = "api/project_badges/measure?project=" + PROJECT_KEY + "&metric=alert_status"; private static final String WS_MEASURE_BADGES_ON_BUGS = "api/project_badges/measure?project=" + PROJECT_KEY + "&metric=bugs"; private static final String WS_QUALITY_GATE_BADGE = "api/project_badges/quality_gate?project=" + PROJECT_KEY; - private static final String SONAR_CLOUD_ORANGE_BADGE = "images/project_badges/sonarcloud-orange.svg"; @ClassRule - public static Orchestrator orchestrator = SonarCloudProjectSuite.ORCHESTRATOR; + public static Orchestrator orchestrator = ProjectSuite.ORCHESTRATOR; @Rule public Tester tester = new Tester(orchestrator); @@ -57,7 +56,7 @@ public class ProjectBadgesTest { tester.openBrowser("/projects").openProjectDashboard(PROJECT_KEY); SelenideElement badgesModal = openBadgesModal(); - ElementsCollection badgeButtons = badgesModal.$$(".badge-button").shouldHaveSize(3); + ElementsCollection badgeButtons = badgesModal.$$(".badge-button").shouldHaveSize(2); // Check quality gate badge shouldHaveUrl(badgesModal, WS_MEASURE_BADGES_ON_QUALITY_GATE); @@ -69,11 +68,6 @@ public class ProjectBadgesTest { // Check marketing quality gate badge badgeButtons.get(1).click(); shouldHaveUrl(badgesModal, WS_QUALITY_GATE_BADGE); - - // Check scanned on SonarCloud badge - badgeButtons.get(2).click(); - selectOption("Orange"); - shouldHaveUrl(badgesModal, SONAR_CLOUD_ORANGE_BADGE); } @Test @@ -96,7 +90,6 @@ public class ProjectBadgesTest { assertThat(tester.wsClient().wsConnector().call(new GetRequest(WS_MEASURE_BADGES_ON_QUALITY_GATE)).failIfNotSuccessful().contentType()).isEqualTo("image/svg+xml"); assertThat(tester.wsClient().wsConnector().call(new GetRequest(WS_MEASURE_BADGES_ON_BUGS)).failIfNotSuccessful().contentType()).isEqualTo("image/svg+xml"); assertThat(tester.wsClient().wsConnector().call(new GetRequest(WS_QUALITY_GATE_BADGE)).failIfNotSuccessful().contentType()).isEqualTo("image/svg+xml"); - assertThat(tester.wsClient().wsConnector().call(new GetRequest(SONAR_CLOUD_ORANGE_BADGE)).failIfNotSuccessful().contentType()).isEqualTo("image/svg+xml"); } private void shouldNotHaveBadges() { diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectSuite.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectSuite.java index eaf2ba850be..b16447be779 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectSuite.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectSuite.java @@ -32,6 +32,7 @@ import static util.ItUtils.xooPlugin; @RunWith(Suite.class) @Suite.SuiteClasses({ + ProjectBadgesTest.class, ProjectBulkDeletionTest.class, ProjectBulkDeletionPageTest.class, ProjectDeletionTest.class, diff --git a/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectBadgesTest.java b/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectBadgesTest.java new file mode 100644 index 00000000000..87833c335d9 --- /dev/null +++ b/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectBadgesTest.java @@ -0,0 +1,122 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.tests.project; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.SelenideElement; +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarScanner; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.sonarqube.qa.util.Tester; +import org.sonarqube.ws.Organizations.Organization; +import org.sonarqube.ws.Users.CreateWsResponse.User; +import org.sonarqube.ws.client.GetRequest; +import org.sonarqube.ws.client.projects.UpdateVisibilityRequest; + +import static com.codeborne.selenide.Selenide.$; +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; + +public class SonarCloudProjectBadgesTest { + + private static final String PROJECT_KEY = "sample"; + private static final String WS_MEASURE_BADGES_ON_QUALITY_GATE = "api/project_badges/measure?project=" + PROJECT_KEY + "&metric=alert_status"; + private static final String WS_MEASURE_BADGES_ON_BUGS = "api/project_badges/measure?project=" + PROJECT_KEY + "&metric=bugs"; + private static final String WS_QUALITY_GATE_BADGE = "api/project_badges/quality_gate?project=" + PROJECT_KEY; + private static final String SONAR_CLOUD_ORANGE_BADGE = "images/project_badges/sonarcloud-orange.svg"; + + @ClassRule + public static Orchestrator orchestrator = SonarCloudProjectSuite.ORCHESTRATOR; + + @Rule + public Tester tester = new Tester(orchestrator); + + @Test + public void public_project_badges() { + orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"))); + tester.openBrowser("/projects").openProjectDashboard(PROJECT_KEY); + + SelenideElement badgesModal = openBadgesModal(); + ElementsCollection badgeButtons = badgesModal.$$(".badge-button").shouldHaveSize(3); + + // Check quality gate badge + shouldHaveUrl(badgesModal, WS_MEASURE_BADGES_ON_QUALITY_GATE); + + // Check bugs badge + selectOption("Bugs"); + shouldHaveUrl(badgesModal, WS_MEASURE_BADGES_ON_BUGS); + + // Check marketing quality gate badge + badgeButtons.get(1).click(); + shouldHaveUrl(badgesModal, WS_QUALITY_GATE_BADGE); + + // Check scanned on SonarCloud badge + badgeButtons.get(2).click(); + selectOption("Orange"); + shouldHaveUrl(badgesModal, SONAR_CLOUD_ORANGE_BADGE); + } + + @Test + public void private_project_do_not_have_badges() { + Organization org = tester.organizations().generate(); + User user = tester.users().generateAdministrator(org); + orchestrator.executeBuild( + SonarScanner + .create(projectDir("shared/xoo-sample")) + .setProperties("sonar.organization", org.getKey(), "sonar.login", user.getLogin(), "sonar.password", user.getLogin()) + ); + tester.wsClient().projects().updateVisibility(new UpdateVisibilityRequest().setProject("sample").setVisibility("private")); + tester.openBrowser("/projects").logIn().submitCredentials(user.getLogin()).openProjectDashboard(PROJECT_KEY); + shouldNotHaveBadges(); + } + + @Test + public void project_badges_ws() { + orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"))); + assertThat(tester.wsClient().wsConnector().call(new GetRequest(WS_MEASURE_BADGES_ON_QUALITY_GATE)).failIfNotSuccessful().contentType()).isEqualTo("image/svg+xml"); + assertThat(tester.wsClient().wsConnector().call(new GetRequest(WS_MEASURE_BADGES_ON_BUGS)).failIfNotSuccessful().contentType()).isEqualTo("image/svg+xml"); + assertThat(tester.wsClient().wsConnector().call(new GetRequest(WS_QUALITY_GATE_BADGE)).failIfNotSuccessful().contentType()).isEqualTo("image/svg+xml"); + assertThat(tester.wsClient().wsConnector().call(new GetRequest(SONAR_CLOUD_ORANGE_BADGE)).failIfNotSuccessful().contentType()).isEqualTo("image/svg+xml"); + } + + private void shouldNotHaveBadges() { + $(".js-project-badges").shouldNot(Condition.exist); + } + + private SelenideElement openBadgesModal() { + $(".js-project-badges").shouldBe(Condition.visible).click(); + return $(".modal-body").shouldBe(Condition.visible); + } + + private void selectOption(String option) { + SelenideElement select = $(".Select").should(Condition.visible); + select.click(); + select.$$(".Select-option").find(Condition.text(option)).should(Condition.exist).click(); + } + + private void shouldHaveUrl(SelenideElement badgesModal, String url) { + badgesModal.$(".code-snippet pre") + .shouldBe(Condition.visible) + .shouldHave(Condition.text(url)); + } +} diff --git a/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectSuite.java b/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectSuite.java index d65f7b52c37..af9aba43eea 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectSuite.java +++ b/tests/src/test/java/org/sonarqube/tests/project/SonarCloudProjectSuite.java @@ -29,7 +29,7 @@ import static util.ItUtils.xooPlugin; @RunWith(Suite.class) @Suite.SuiteClasses({ - ProjectBadgesTest.class + SonarCloudProjectBadgesTest.class }) public class SonarCloudProjectSuite { |