]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8355 Remove property 'supportsMeasureFilters' from ResourceType API
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 8 Nov 2016 14:11:13 +0000 (15:11 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 9 Nov 2016 15:47:34 +0000 (16:47 +0100)
sonar-core/src/main/java/org/sonar/core/component/DefaultResourceTypes.java
sonar-core/src/test/java/org/sonar/core/component/DefaultResourceTypesTest.java
sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTest.java

index 03fe1f5d58f319e16d70762b1f710a9e6b748c7d..b28f8793095fd6e54a31d19705b8ad97d993010c 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.api.server.ServerSide;
 @ComputeEngineSide
 public final class DefaultResourceTypes {
 
-  private static final String SUPPORTS_MEASURE_FILTERS = "supportsMeasureFilters";
   private static final String CONFIGURABLE = "configurable";
   private static final String UPDATABLE_KEY = "updatable_key";
 
@@ -43,29 +42,23 @@ public final class DefaultResourceTypes {
     return ResourceTypeTree.builder()
       .addType(ResourceType.builder(Qualifiers.PROJECT)
         .setProperty("deletable", true)
-        .setProperty("supportsGlobalDashboards", true)
         .setProperty("modifiable_history", true)
         .setProperty("hasRolePolicy", true)
         .setProperty(UPDATABLE_KEY, true)
-        .setProperty(SUPPORTS_MEASURE_FILTERS, true)
         .setProperty("comparable", true)
         .setProperty(CONFIGURABLE, true)
         .build())
       .addType(ResourceType.builder(Qualifiers.MODULE)
         .setProperty(UPDATABLE_KEY, true)
-        .setProperty(SUPPORTS_MEASURE_FILTERS, true)
         .setProperty(CONFIGURABLE, true)
         .build())
       .addType(ResourceType.builder(Qualifiers.DIRECTORY)
-        .setProperty(SUPPORTS_MEASURE_FILTERS, true)
         .build())
       .addType(ResourceType.builder(Qualifiers.FILE)
         .hasSourceCode()
-        .setProperty(SUPPORTS_MEASURE_FILTERS, true)
         .build())
       .addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE)
         .hasSourceCode()
-        .setProperty(SUPPORTS_MEASURE_FILTERS, true)
         .build())
 
       .addRelations(Qualifiers.PROJECT, Qualifiers.MODULE)
index 8d1557b43fe13753f396fed492478ebaff34a0ea..6705eeb09bb630db59907970d4bf73063562cabc 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.core.component;
 
 import org.junit.Test;
 import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.ResourceType;
 import org.sonar.api.resources.ResourceTypeTree;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -34,14 +33,4 @@ public class DefaultResourceTypesTest {
     assertThat(tree.getTypes()).hasSize(5);
     assertThat(tree.getChildren(Qualifiers.PROJECT)).containsExactly(Qualifiers.MODULE);
   }
-
-  @Test
-  public void projects_should_be_available_for_global_widgets() {
-    ResourceTypeTree tree = DefaultResourceTypes.get();
-
-    ResourceType projectResourceType = tree.getTypes().get(0);
-
-    assertThat(projectResourceType.getQualifier()).isEqualTo(Qualifiers.PROJECT);
-    assertThat(projectResourceType.getBooleanProperty("supportsGlobalDashboards")).isTrue();
-  }
 }
index 32768bb68b2a26147430f354c7308b69ce50f8a6..90df4eff818d9a5aee4168e00d49086236a1a504 100644 (file)
@@ -22,12 +22,10 @@ package org.sonar.api.resources;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.Maps;
-
+import java.util.Map;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 
-import java.util.Map;
-
 /**
  * <p>Experimental extension to declare types of resources.
  * <p>
@@ -156,7 +154,6 @@ public class ResourceType {
    * Builder used to create {@link ResourceType} objects.
    */
   public static class Builder {
-    private static final String SUPPORTS_MEASURE_FILTERS = "supportsMeasureFilters";
     private String qualifier;
     private String iconPath;
     private boolean hasSourceCode = false;
@@ -184,7 +181,6 @@ public class ResourceType {
      */
     @Deprecated
     public Builder availableForFilters() {
-      setProperty(SUPPORTS_MEASURE_FILTERS, "true");
       return this;
     }
 
@@ -205,11 +201,6 @@ public class ResourceType {
       Preconditions.checkNotNull(key);
       Preconditions.checkNotNull(value);
       properties.put(key, value);
-
-      // for backward-compatibility since version 3.4
-      if ("availableForFilters".equals(key)) {
-        properties.put(SUPPORTS_MEASURE_FILTERS, value);
-      }
       return this;
     }
 
index 1097b0d24e457afcd42edc5b8f38ef8b5f15c939..1e50d5b0cba832c1a950a40e1372433b2f10bc3a 100644 (file)
@@ -46,7 +46,6 @@ public class ResourceTypeTest {
     assertThat(def.getQualifier()).isEqualTo("qualifier");
     assertThat(def.getIconPath()).isEqualTo("/custom-icon.png");
     assertThat(def.hasSourceCode()).isTrue();
-    assertThat(def.getBooleanProperty("supportsMeasureFilters")).isTrue();
     assertThat(def.getStringProperty("anotherProperty")).isEqualTo("foo");
   }
 
@@ -68,35 +67,26 @@ public class ResourceTypeTest {
     assertThat(foo1.hashCode()).isEqualTo(foo1.hashCode());
   }
 
-  @Test
-  public void testDeprecatedIsAvailableForFiltesCompatibility() {
-    ResourceType def = ResourceType.builder("qualifier").build();
-    assertThat(def.getBooleanProperty("supportsMeasureFilters")).isFalse();
-
-    def = ResourceType.builder("qualifier").availableForFilters().build();
-    assertThat(def.getBooleanProperty("supportsMeasureFilters")).isTrue();
-  }
-
   @Test
   public void getBooleanProperty_is_set() {
     // set with boolean parameter
-    ResourceType def = ResourceType.builder("qualifier").setProperty("supportsMeasureFilters", true).build();
-    assertThat(def.getBooleanProperty("supportsMeasureFilters")).isTrue();
+    ResourceType def = ResourceType.builder("qualifier").setProperty("test", true).build();
+    assertThat(def.getBooleanProperty("test")).isTrue();
 
-    def = ResourceType.builder("qualifier").setProperty("supportsMeasureFilters", false).build();
-    assertThat(def.getBooleanProperty("supportsMeasureFilters")).isFalse();
+    def = ResourceType.builder("qualifier").setProperty("test", false).build();
+    assertThat(def.getBooleanProperty("test")).isFalse();
 
-    def = ResourceType.builder("qualifier").setProperty("supportsMeasureFilters", "true").build();
-    assertThat(def.getBooleanProperty("supportsMeasureFilters")).isTrue();
+    def = ResourceType.builder("qualifier").setProperty("test", "true").build();
+    assertThat(def.getBooleanProperty("test")).isTrue();
 
-    def = ResourceType.builder("qualifier").setProperty("supportsMeasureFilters", "false").build();
-    assertThat(def.getBooleanProperty("supportsMeasureFilters")).isFalse();
+    def = ResourceType.builder("qualifier").setProperty("test", "false").build();
+    assertThat(def.getBooleanProperty("test")).isFalse();
   }
 
   @Test
   public void getBooleanProperty_is_not_set() {
     ResourceType def = ResourceType.builder("qualifier").build();
-    assertThat(def.getBooleanProperty("supportsMeasureFilters")).isFalse();
+    assertThat(def.getBooleanProperty("test")).isFalse();
   }
 
   @Test