aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2018-02-05 11:58:56 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2018-02-07 16:43:01 +0100
commita403ed93afa3982c3651799a00166a44a5b7872a (patch)
treee1bfcc5904e55d4038353d3df2f6d88e4dedda05 /sonar-plugin-api/src
parent8ee77ab8844db1732360d2cd22e8f4809b0c6731 (diff)
downloadsonarqube-a403ed93afa3982c3651799a00166a44a5b7872a.tar.gz
sonarqube-a403ed93afa3982c3651799a00166a44a5b7872a.zip
SONAR-10290 Add ability to provide help message for identity providers
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/authentication/Display.java20
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/server/authentication/DisplayTest.java28
2 files changed, 40 insertions, 8 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/authentication/Display.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/authentication/Display.java
index 767e726526e..c25584db92b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/authentication/Display.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/authentication/Display.java
@@ -19,6 +19,7 @@
*/
package org.sonar.api.server.authentication;
+import javax.annotation.CheckForNull;
import javax.annotation.concurrent.Immutable;
import static com.google.common.base.Preconditions.checkArgument;
@@ -34,10 +35,12 @@ public final class Display {
private final String iconPath;
private final String backgroundColor;
+ private final String helpMessage;
private Display(Builder builder) {
this.iconPath = builder.iconPath;
this.backgroundColor = builder.backgroundColor;
+ this.helpMessage = builder.helpMessage;
}
/**
@@ -64,6 +67,14 @@ public final class Display {
return backgroundColor;
}
+ /**
+ * Optional help message to be displayed near the provider button.
+ */
+ @CheckForNull
+ public String getHelpMessage() {
+ return helpMessage;
+ }
+
public static Builder builder() {
return new Builder();
}
@@ -72,6 +83,7 @@ public final class Display {
private String iconPath;
private String backgroundColor = "#236a97";
+ private String helpMessage;
private Builder() {
}
@@ -92,6 +104,14 @@ public final class Display {
return this;
}
+ /**
+ * @see Display#getHelpMessage()
+ */
+ public Builder setHelpMessage(@CheckForNull String helpMessage) {
+ this.helpMessage = helpMessage;
+ return this;
+ }
+
public Display build() {
checkArgument(isNotBlank(iconPath), "Icon path must not be blank");
validateBackgroundColor();
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/authentication/DisplayTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/authentication/DisplayTest.java
index 0e1b832e5c4..963e571b45d 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/server/authentication/DisplayTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/authentication/DisplayTest.java
@@ -31,7 +31,7 @@ public class DisplayTest {
public ExpectedException thrown = ExpectedException.none();
@Test
- public void create_display() throws Exception {
+ public void create_display() {
Display display = Display.builder()
.setIconPath("/static/authgithub/github.svg")
.setBackgroundColor("#123456")
@@ -39,10 +39,11 @@ public class DisplayTest {
assertThat(display.getIconPath()).isEqualTo("/static/authgithub/github.svg");
assertThat(display.getBackgroundColor()).isEqualTo("#123456");
+ assertThat(display.getHelpMessage()).isNull();
}
@Test
- public void create_display_with_default_background_color() throws Exception {
+ public void create_display_with_default_background_color() {
Display display = Display.builder()
.setIconPath("/static/authgithub/github.svg")
.build();
@@ -50,8 +51,19 @@ public class DisplayTest {
assertThat(display.getBackgroundColor()).isEqualTo("#236a97");
}
+
+ @Test
+ public void create_display_with_help_message() {
+ Display display = Display.builder()
+ .setIconPath("/static/authgithub/github.svg")
+ .setHelpMessage("Help message")
+ .build();
+
+ assertThat(display.getHelpMessage()).isEqualTo("Help message");
+ }
+
@Test
- public void fail_when_icon_path_is_null() throws Exception {
+ public void fail_when_icon_path_is_null() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Icon path must not be blank");
@@ -62,7 +74,7 @@ public class DisplayTest {
}
@Test
- public void fail_when_icon_path_is_blank() throws Exception {
+ public void fail_when_icon_path_is_blank() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Icon path must not be blank");
@@ -73,7 +85,7 @@ public class DisplayTest {
}
@Test
- public void fail_when_background_color_is_null() throws Exception {
+ public void fail_when_background_color_is_null() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Background color must not be blank");
@@ -84,7 +96,7 @@ public class DisplayTest {
}
@Test
- public void fail_when_background_color_is_blank() throws Exception {
+ public void fail_when_background_color_is_blank() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Background color must not be blank");
@@ -95,7 +107,7 @@ public class DisplayTest {
}
@Test
- public void fail_when_background_color_has_wrong_size() throws Exception {
+ public void fail_when_background_color_has_wrong_size() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Background color must begin with a sharp followed by 6 characters");
@@ -106,7 +118,7 @@ public class DisplayTest {
}
@Test
- public void fail_when_background_color_doesnt_begin_with_sharp() throws Exception {
+ public void fail_when_background_color_doesnt_begin_with_sharp() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Background color must begin with a sharp followed by 6 characters");