aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-01-16 10:58:31 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-01-16 10:58:40 +0100
commitb0176aa4b35999935a4c849ccded5c072af50908 (patch)
treea0414273683bed4b3019b2a84f428534fd487ca4 /sonar-plugin-api
parent81830f26191f2f7eff1457f68b9833465abe3784 (diff)
downloadsonarqube-b0176aa4b35999935a4c849ccded5c072af50908.tar.gz
sonarqube-b0176aa4b35999935a4c849ccded5c072af50908.zip
SONAR-4908 fix deprecated RuleRepository with empty name
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java6
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java7
2 files changed, 11 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java
index ffcdbca26cf..ffc553ddccc 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RuleDefinitions.java
@@ -155,8 +155,10 @@ public interface RuleDefinitions extends ServerExtension {
}
@Override
- public NewRepositoryImpl setName(String s) {
- this.name = s;
+ public NewRepositoryImpl setName(@Nullable String s) {
+ if (StringUtils.isNotEmpty(s)) {
+ this.name = s;
+ }
return this;
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java
index 33b06647c07..9245e4163c3 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/rule/RuleDefinitionsTest.java
@@ -158,6 +158,13 @@ public class RuleDefinitionsTest {
}
@Test
+ public void cant_set_blank_repository_name() throws Exception {
+ context.newRepository("findbugs", "java").setName(null).done();
+
+ assertThat(context.repository("findbugs").name()).isEqualTo("findbugs");
+ }
+
+ @Test
public void fail_if_duplicated_repo_keys() {
context.newRepository("findbugs", "java").done();
try {