aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-27 12:11:02 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-28 09:29:04 +0200
commit9c1417ee34fcf0f4da7553baa6f9d6a1657d7157 (patch)
treecfe5561fef31b529e558aea606740c0920a63aa2 /sonar-core
parentbedce38e52fb67ae66bb9549b69864dd15b45da5 (diff)
downloadsonarqube-9c1417ee34fcf0f4da7553baa6f9d6a1657d7157.tar.gz
sonarqube-9c1417ee34fcf0f4da7553baa6f9d6a1657d7157.zip
SONAR-6370 move the remaining extensions out of core plugin
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/DefaultResourceTypes.java82
-rw-r--r--sonar-core/src/test/java/org/sonar/core/resource/DefaultResourceTypesTest.java47
2 files changed, 129 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourceTypes.java b/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourceTypes.java
new file mode 100644
index 00000000000..76e88053609
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourceTypes.java
@@ -0,0 +1,82 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.sonar.core.resource;
+
+import org.sonar.api.ExtensionProvider;
+import org.sonar.api.batch.BatchSide;
+import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.ResourceType;
+import org.sonar.api.resources.ResourceTypeTree;
+import org.sonar.api.server.ServerSide;
+
+@BatchSide
+@ServerSide
+@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
+public final class DefaultResourceTypes extends ExtensionProvider {
+
+ private static final String SUPPORTS_MEASURE_FILTERS = "supportsMeasureFilters";
+ private static final String CONFIGURABLE = "configurable";
+ private static final String UPDATABLE_KEY = "updatable_key";
+
+ @Override
+ public ResourceTypeTree provide() {
+
+ 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.PACKAGE)
+ .build())
+ .addType(ResourceType.builder(Qualifiers.FILE)
+ .hasSourceCode()
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
+ .build())
+ .addType(ResourceType.builder(Qualifiers.CLASS)
+ .hasSourceCode()
+ .build())
+ .addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE)
+ .hasSourceCode()
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
+ .build())
+
+ .addRelations(Qualifiers.PROJECT, Qualifiers.MODULE)
+ .addRelations(Qualifiers.MODULE, Qualifiers.DIRECTORY, Qualifiers.PACKAGE)
+ .addRelations(Qualifiers.DIRECTORY, Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE)
+ .addRelations(Qualifiers.PACKAGE, Qualifiers.CLASS, Qualifiers.UNIT_TEST_FILE)
+
+ .build();
+ }
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourceTypesTest.java b/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourceTypesTest.java
new file mode 100644
index 00000000000..ed418b96709
--- /dev/null
+++ b/sonar-core/src/test/java/org/sonar/core/resource/DefaultResourceTypesTest.java
@@ -0,0 +1,47 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.sonar.core.resource;
+
+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;
+
+public class DefaultResourceTypesTest {
+ @Test
+ public void provide_types() {
+ ResourceTypeTree tree = new DefaultResourceTypes().provide();
+
+ assertThat(tree.getTypes()).hasSize(7);
+ assertThat(tree.getChildren(Qualifiers.PROJECT)).containsExactly(Qualifiers.MODULE);
+ }
+
+ @Test
+ public void projects_should_be_available_for_global_widgets() {
+ ResourceTypeTree tree = new DefaultResourceTypes().provide();
+
+ ResourceType projectResourceType = tree.getTypes().get(0);
+
+ assertThat(projectResourceType.getQualifier()).isEqualTo(Qualifiers.PROJECT);
+ assertThat(projectResourceType.getBooleanProperty("supportsGlobalDashboards")).isTrue();
+ }
+}