aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-11-25 00:00:50 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-11-26 13:55:54 +0100
commita38602149510e58a7f2421faa02327feb8236396 (patch)
treea28902b1b3acfa2a3c877c42d845e0f54f7ea68b /sonar-plugin-api
parent2704d7b445807d96e62ab8bd51382f2069e9875b (diff)
downloadsonarqube-a38602149510e58a7f2421faa02327feb8236396.tar.gz
sonarqube-a38602149510e58a7f2421faa02327feb8236396.zip
SONAR-3825 fix loading of qualifiers in the form
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java11
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypes.java2
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTest.java26
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypesTest.java12
4 files changed, 28 insertions, 23 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
index fc0d8b0041e..bab797e764b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
@@ -40,7 +40,7 @@ import java.util.Map;
* </p>
* <ul>
* <li>"deletable": if set to "true", then this resource can be deleted/purged.</li>
- * <li>"availableForFilters": if set to "true", then this resource can be displayed in the filters results</li>
+ * <li>"supports_measure_filters": if set to "true", then this resource can be displayed in measure filters</li>
* <li>"modifiable_history": if set to "true", then the history of this resource may be modified (deletion of snapshots, modification of events, ...)</li>
* <li>"updatable_key" (since 3.2): if set to "true", then it is possible to update the key of this resource</li>
* <li>"supportsGlobalDashboards" (since 3.2): if true, this resource can be displayed in global dashboards</li>
@@ -82,11 +82,11 @@ public final class ResourceType {
}
/**
- * @deprecated since 3.0. Use {@link #setProperty(String, String)} with "availableForFilters" set to "true".
+ * @deprecated since 3.0. Use {@link #setProperty(String, String)} with "supports_measure_filters" set to "true".
*/
@Deprecated
public Builder availableForFilters() {
- setProperty("availableForFilters", "true");
+ setProperty("supports_measure_filters", "true");
return this;
}
@@ -107,6 +107,11 @@ public final class ResourceType {
Preconditions.checkNotNull(key);
Preconditions.checkNotNull(value);
properties.put(key, value);
+
+ // for backward-compatibility since version 3.4
+ if (key.equals("availableForFilters")) {
+ properties.put("supports_measure_filters", value);
+ }
return this;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypes.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypes.java
index 4821187385f..f3494e963c2 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypes.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypes.java
@@ -45,7 +45,7 @@ public final class ResourceTypes implements BatchComponent, ServerComponent {
public static final Predicate<ResourceType> AVAILABLE_FOR_FILTERS = new Predicate<ResourceType>() {
public boolean apply(@Nullable ResourceType input) {
- return input != null && input.getBooleanProperty("availableForFilters");
+ return input != null && input.getBooleanProperty("supports_measure_filters");
}
};
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTest.java
index 5d3559e9100..98e11c609d3 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTest.java
@@ -40,13 +40,13 @@ public class ResourceTypeTest {
ResourceType def = ResourceType.builder("qualifier")
.setIconPath("/custom-icon.png")
.hasSourceCode()
- .setProperty("availableForFilters", "true")
+ .setProperty("supports_measure_filters", "true")
.setProperty("anotherProperty", "foo")
.build();
assertThat(def.getQualifier()).isEqualTo("qualifier");
assertThat(def.getIconPath()).isEqualTo("/custom-icon.png");
assertThat(def.hasSourceCode()).isTrue();
- assertThat(def.getBooleanProperty("availableForFilters")).isTrue();
+ assertThat(def.getBooleanProperty("supports_measure_filters")).isTrue();
assertThat(def.getStringProperty("anotherProperty")).isEqualTo("foo");
}
@@ -71,32 +71,32 @@ public class ResourceTypeTest {
@Test
public void testDeprecatedIsAvailableForFiltesCompatibility() {
ResourceType def = ResourceType.builder("qualifier").build();
- assertThat(def.getBooleanProperty("availableForFilters")).isFalse();
+ assertThat(def.getBooleanProperty("supports_measure_filters")).isFalse();
def = ResourceType.builder("qualifier").availableForFilters().build();
- assertThat(def.getBooleanProperty("availableForFilters")).isTrue();
+ assertThat(def.getBooleanProperty("supports_measure_filters")).isTrue();
}
@Test
public void getBooleanProperty_is_set() {
// set with boolean parameter
- ResourceType def = ResourceType.builder("qualifier").setProperty("availableForFilters", true).build();
- assertThat(def.getBooleanProperty("availableForFilters")).isTrue();
+ ResourceType def = ResourceType.builder("qualifier").setProperty("supports_measure_filters", true).build();
+ assertThat(def.getBooleanProperty("supports_measure_filters")).isTrue();
- def = ResourceType.builder("qualifier").setProperty("availableForFilters", false).build();
- assertThat(def.getBooleanProperty("availableForFilters")).isFalse();
+ def = ResourceType.builder("qualifier").setProperty("supports_measure_filters", false).build();
+ assertThat(def.getBooleanProperty("supports_measure_filters")).isFalse();
- def = ResourceType.builder("qualifier").setProperty("availableForFilters", "true").build();
- assertThat(def.getBooleanProperty("availableForFilters")).isTrue();
+ def = ResourceType.builder("qualifier").setProperty("supports_measure_filters", "true").build();
+ assertThat(def.getBooleanProperty("supports_measure_filters")).isTrue();
- def = ResourceType.builder("qualifier").setProperty("availableForFilters", "false").build();
- assertThat(def.getBooleanProperty("availableForFilters")).isFalse();
+ def = ResourceType.builder("qualifier").setProperty("supports_measure_filters", "false").build();
+ assertThat(def.getBooleanProperty("supports_measure_filters")).isFalse();
}
@Test
public void getBooleanProperty_is_not_set() {
ResourceType def = ResourceType.builder("qualifier").build();
- assertThat(def.getBooleanProperty("availableForFilters")).isFalse();
+ assertThat(def.getBooleanProperty("supports_measure_filters")).isFalse();
}
@Test
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypesTest.java
index eeb96d7402f..1d73ddcc550 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypesTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypesTest.java
@@ -30,14 +30,14 @@ import static org.fest.assertions.Assertions.assertThat;
public class ResourceTypesTest {
private ResourceTypeTree viewsTree = ResourceTypeTree.builder()
- .addType(ResourceType.builder(Qualifiers.VIEW).setProperty("availableForFilters", "true").build())
+ .addType(ResourceType.builder(Qualifiers.VIEW).setProperty("supports_measure_filters", "true").build())
.addType(ResourceType.builder(Qualifiers.SUBVIEW).build())
.addRelations(Qualifiers.VIEW, Qualifiers.SUBVIEW)
.addRelations(Qualifiers.SUBVIEW, Qualifiers.PROJECT)
.build();
private ResourceTypeTree defaultTree = ResourceTypeTree.builder()
- .addType(ResourceType.builder(Qualifiers.PROJECT).setProperty("availableForFilters", "true").build())
+ .addType(ResourceType.builder(Qualifiers.PROJECT).setProperty("supports_measure_filters", "true").build())
.addType(ResourceType.builder(Qualifiers.DIRECTORY).build())
.addType(ResourceType.builder(Qualifiers.FILE).build())
.addRelations(Qualifiers.PROJECT, Qualifiers.DIRECTORY)
@@ -67,14 +67,14 @@ public class ResourceTypesTest {
@Test
public void getAllWithPropertyKey() {
- assertThat(qualifiers(types.getAllWithPropertyKey("availableForFilters"))).containsOnly(Qualifiers.VIEW, Qualifiers.PROJECT);
+ assertThat(qualifiers(types.getAllWithPropertyKey("supports_measure_filters"))).containsOnly(Qualifiers.VIEW, Qualifiers.PROJECT);
}
@Test
public void getAllWithPropertyValue() {
- assertThat(qualifiers(types.getAllWithPropertyValue("availableForFilters", "true"))).containsOnly(Qualifiers.VIEW, Qualifiers.PROJECT);
- assertThat(qualifiers(types.getAllWithPropertyValue("availableForFilters", true))).containsOnly(Qualifiers.VIEW, Qualifiers.PROJECT);
- assertThat(qualifiers(types.getAllWithPropertyValue("availableForFilters", false))).containsOnly(Qualifiers.SUBVIEW, Qualifiers.DIRECTORY, Qualifiers.FILE);
+ assertThat(qualifiers(types.getAllWithPropertyValue("supports_measure_filters", "true"))).containsOnly(Qualifiers.VIEW, Qualifiers.PROJECT);
+ assertThat(qualifiers(types.getAllWithPropertyValue("supports_measure_filters", true))).containsOnly(Qualifiers.VIEW, Qualifiers.PROJECT);
+ assertThat(qualifiers(types.getAllWithPropertyValue("supports_measure_filters", false))).containsOnly(Qualifiers.SUBVIEW, Qualifiers.DIRECTORY, Qualifiers.FILE);
}
@Test