]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6370 move the remaining extensions out of core plugin
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 27 May 2015 10:11:02 +0000 (12:11 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 28 May 2015 07:29:04 +0000 (09:29 +0200)
22 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java [deleted file]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/UserManagedMetrics.java [deleted file]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/package-info.java [deleted file]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/notifications/alerts/NewAlerts.java [deleted file]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/notifications/alerts/package-info.java [deleted file]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/security/package-info.java [deleted file]
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/package-info.java [deleted file]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/CorePluginTest.java [deleted file]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/DefaultResourceTypesTest.java [deleted file]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/UserManagedMetricsTest.java [deleted file]
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/notifications/alerts/NewAlertsTest.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/event/NewAlerts.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/event/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/metric/CoreCustomMetrics.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/metric/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/test/java/org/sonar/server/event/NewAlertsTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/metric/CoreCustomMetricsTest.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
sonar-core/src/main/java/org/sonar/core/resource/DefaultResourceTypes.java [new file with mode: 0644]
sonar-core/src/test/java/org/sonar/core/resource/DefaultResourceTypesTest.java [new file with mode: 0644]

index cd0b8687a3cb962105ae07bb256ca11a84d82626..289cb0a9ccd589f15a163206925888748fb24e2d 100644 (file)
  */
 package org.sonar.plugins.core;
 
-import com.google.common.collect.ImmutableList;
+import java.util.Collections;
 import java.util.List;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.Properties;
 import org.sonar.api.Property;
 import org.sonar.api.PropertyType;
 import org.sonar.api.SonarPlugin;
-import org.sonar.plugins.core.notifications.alerts.NewAlerts;
 
 @Properties({
   @Property(
@@ -190,17 +189,7 @@ public final class CorePlugin extends SonarPlugin {
   @SuppressWarnings("rawtypes")
   @Override
   public List getExtensions() {
-    ImmutableList.Builder<Object> extensions = ImmutableList.builder();
-
-    extensions.add(
-      DefaultResourceTypes.class,
-      UserManagedMetrics.class,
-
-      // Notify alerts on my favourite projects
-      NewAlerts.class,
-      NewAlerts.newMetadata());
-
-    return extensions.build();
+    return Collections.emptyList();
   }
 
 }
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java
deleted file mode 100644 (file)
index dcb0f91..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.plugins.core;
-
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.ExtensionProvider;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.batch.InstantiationStrategy;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.ResourceType;
-import org.sonar.api.resources.ResourceTypeTree;
-
-@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/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/UserManagedMetrics.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/UserManagedMetrics.java
deleted file mode 100644 (file)
index 4014e51..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.plugins.core;
-
-import com.google.common.collect.ImmutableList;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.measures.Metrics;
-
-import java.util.List;
-
-public final class UserManagedMetrics implements Metrics {
-  private static final String DOMAIN = "Management";
-
-  @Override
-  public List<Metric> getMetrics() {
-    return ImmutableList.<Metric>of(
-      new Metric.Builder("burned_budget", "Burned budget", Metric.ValueType.FLOAT)
-        .setDirection(Metric.DIRECTION_NONE)
-        .setQualitative(false)
-        .setDomain(DOMAIN)
-        .setUserManaged(true)
-        .create(),
-      new Metric.Builder("business_value", "Business value", Metric.ValueType.FLOAT)
-        .setDirection(Metric.DIRECTION_BETTER)
-        .setQualitative(true)
-        .setDomain(DOMAIN)
-        .setUserManaged(true)
-        .create(),
-      new Metric.Builder("team_size", "Team size", Metric.ValueType.INT)
-        .setDirection(Metric.DIRECTION_NONE)
-        .setQualitative(false)
-        .setDomain(DOMAIN)
-        .setUserManaged(true)
-        .create());
-  }
-}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/package-info.java
deleted file mode 100644 (file)
index 3fd527a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.plugins.core.issue;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/notifications/alerts/NewAlerts.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/notifications/alerts/NewAlerts.java
deleted file mode 100644 (file)
index b6c4bd9..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.plugins.core.notifications.alerts;
-
-import com.google.common.collect.Multimap;
-import org.sonar.api.notifications.*;
-
-import java.util.Collection;
-import java.util.Map;
-import org.sonar.core.notification.NotificationDispatcher;
-import org.sonar.core.notification.NotificationDispatcherMetadata;
-import org.sonar.core.notification.NotificationManager;
-
-/**
- * This dispatcher means: "notify me each new alert event".
- *
- * @since 3.5
- */
-public class NewAlerts extends NotificationDispatcher {
-
-  public static final String KEY = "NewAlerts";
-  private final NotificationManager notifications;
-
-  public NewAlerts(NotificationManager notifications) {
-    super("alerts");
-    this.notifications = notifications;
-  }
-
-  @Override
-  public String getKey() {
-    return KEY;
-  }
-
-  public static NotificationDispatcherMetadata newMetadata() {
-    return NotificationDispatcherMetadata.create(KEY)
-      .setProperty(NotificationDispatcherMetadata.GLOBAL_NOTIFICATION, String.valueOf(true))
-      .setProperty(NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION, String.valueOf(true));
-  }
-
-  @Override
-  public void dispatch(Notification notification, Context context) {
-    String projectIdString = notification.getFieldValue("projectId");
-    if (projectIdString != null) {
-      int projectId = Integer.parseInt(projectIdString);
-      Multimap<String, NotificationChannel> subscribedRecipients = notifications.findSubscribedRecipientsForDispatcher(this, projectId);
-
-      for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap().entrySet()) {
-        String userLogin = channelsByRecipients.getKey();
-        for (NotificationChannel channel : channelsByRecipients.getValue()) {
-          context.addUser(userLogin, channel);
-        }
-      }
-    }
-  }
-}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/notifications/alerts/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/notifications/alerts/package-info.java
deleted file mode 100644 (file)
index 5e28de8..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.plugins.core.notifications.alerts;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/security/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/security/package-info.java
deleted file mode 100644 (file)
index df9ccea..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.plugins.core.security;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/package-info.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/package-info.java
deleted file mode 100644 (file)
index 145b58b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.plugins.core.sensors;
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/CorePluginTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/CorePluginTest.java
deleted file mode 100644 (file)
index f21fb3b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.plugins.core;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CorePluginTest {
-  @Test
-  public void should_define_extensions() {
-    assertThat(new CorePlugin().getExtensions().size()).isGreaterThan(2);
-  }
-}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/DefaultResourceTypesTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/DefaultResourceTypesTest.java
deleted file mode 100644 (file)
index 55817f9..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.plugins.core;
-
-import org.sonar.api.resources.ResourceType;
-
-import org.junit.Test;
-import org.sonar.api.resources.Qualifiers;
-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();
-  }
-}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/UserManagedMetricsTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/UserManagedMetricsTest.java
deleted file mode 100644 (file)
index 97a9e21..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.plugins.core;
-
-import org.junit.Test;
-import org.sonar.api.measures.Metric;
-
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class UserManagedMetricsTest {
-
-  @Test
-  public void checkDefinitions() {
-    UserManagedMetrics userManagedMetrics = new UserManagedMetrics();
-    List<Metric> metrics = userManagedMetrics.getMetrics();
-    assertThat(metrics.size()).isGreaterThan(2);
-    for (Metric metric : metrics) {
-      assertThat(metric.getUserManaged()).isTrue();
-      assertThat(metric.getDomain()).isEqualTo("Management");
-    }
-  }
-}
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/notifications/alerts/NewAlertsTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/notifications/alerts/NewAlertsTest.java
deleted file mode 100644 (file)
index 6a65353..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.plugins.core.notifications.alerts;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import org.junit.Test;
-import org.sonar.api.notifications.Notification;
-import org.sonar.api.notifications.NotificationChannel;
-import org.sonar.core.notification.NotificationDispatcher;
-import org.sonar.core.notification.NotificationManager;
-
-import static org.mockito.Mockito.*;
-
-public class NewAlertsTest {
-
-  NotificationManager notificationManager = mock(NotificationManager.class);
-  NotificationDispatcher.Context context = mock(NotificationDispatcher.Context.class);
-  NotificationChannel emailChannel = mock(NotificationChannel.class);
-  NotificationChannel twitterChannel = mock(NotificationChannel.class);
-  NewAlerts dispatcher = new NewAlerts(notificationManager);
-
-  @Test
-  public void should_not_dispatch_if_not_alerts_notification() {
-    Notification notification = new Notification("other-notif");
-    dispatcher.performDispatch(notification, context);
-
-    verify(context, never()).addUser(any(String.class), any(NotificationChannel.class));
-  }
-
-  @Test
-  public void should_dispatch_to_users_who_have_subscribed() {
-    Multimap<String, NotificationChannel> recipients = HashMultimap.create();
-    recipients.put("user1", emailChannel);
-    recipients.put("user2", twitterChannel);
-    when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, 34)).thenReturn(recipients);
-
-    Notification notification = new Notification("alerts").setFieldValue("projectId", "34");
-    dispatcher.performDispatch(notification, context);
-
-    verify(context).addUser("user1", emailChannel);
-    verify(context).addUser("user2", twitterChannel);
-    verifyNoMoreInteractions(context);
-  }
-
-  @Test
-  public void should_not_dispatch_if_missing_project_id() {
-    Multimap<String, NotificationChannel> recipients = HashMultimap.create();
-    recipients.put("user1", emailChannel);
-    recipients.put("user2", twitterChannel);
-    when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, 34)).thenReturn(recipients);
-
-    Notification notification = new Notification("alerts");
-    dispatcher.performDispatch(notification, context);
-
-    verifyNoMoreInteractions(context);
-  }
-
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/event/NewAlerts.java b/server/sonar-server/src/main/java/org/sonar/server/event/NewAlerts.java
new file mode 100644 (file)
index 0000000..cf4c219
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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.server.event;
+
+import com.google.common.collect.Multimap;
+import org.sonar.api.notifications.*;
+
+import java.util.Collection;
+import java.util.Map;
+import org.sonar.core.notification.NotificationDispatcher;
+import org.sonar.core.notification.NotificationDispatcherMetadata;
+import org.sonar.core.notification.NotificationManager;
+
+/**
+ * This dispatcher means: "notify me each new alert event".
+ *
+ * @since 3.5
+ */
+public class NewAlerts extends NotificationDispatcher {
+
+  public static final String KEY = "NewAlerts";
+  private final NotificationManager notifications;
+
+  public NewAlerts(NotificationManager notifications) {
+    super("alerts");
+    this.notifications = notifications;
+  }
+
+  @Override
+  public String getKey() {
+    return KEY;
+  }
+
+  public static NotificationDispatcherMetadata newMetadata() {
+    return NotificationDispatcherMetadata.create(KEY)
+      .setProperty(NotificationDispatcherMetadata.GLOBAL_NOTIFICATION, String.valueOf(true))
+      .setProperty(NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION, String.valueOf(true));
+  }
+
+  @Override
+  public void dispatch(Notification notification, Context context) {
+    String projectIdString = notification.getFieldValue("projectId");
+    if (projectIdString != null) {
+      int projectId = Integer.parseInt(projectIdString);
+      Multimap<String, NotificationChannel> subscribedRecipients = notifications.findSubscribedRecipientsForDispatcher(this, projectId);
+
+      for (Map.Entry<String, Collection<NotificationChannel>> channelsByRecipients : subscribedRecipients.asMap().entrySet()) {
+        String userLogin = channelsByRecipients.getKey();
+        for (NotificationChannel channel : channelsByRecipients.getValue()) {
+          context.addUser(userLogin, channel);
+        }
+      }
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/event/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/event/package-info.java
new file mode 100644 (file)
index 0000000..0bc35a2
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.server.event;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/CoreCustomMetrics.java b/server/sonar-server/src/main/java/org/sonar/server/metric/CoreCustomMetrics.java
new file mode 100644 (file)
index 0000000..8d600ea
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.server.metric;
+
+import com.google.common.collect.ImmutableList;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.measures.Metrics;
+
+import java.util.List;
+
+public final class CoreCustomMetrics implements Metrics {
+  private static final String DOMAIN = "Management";
+
+  @Override
+  public List<Metric> getMetrics() {
+    return ImmutableList.<Metric>of(
+      new Metric.Builder("burned_budget", "Burned budget", Metric.ValueType.FLOAT)
+        .setDirection(Metric.DIRECTION_NONE)
+        .setQualitative(false)
+        .setDomain(DOMAIN)
+        .setUserManaged(true)
+        .create(),
+      new Metric.Builder("business_value", "Business value", Metric.ValueType.FLOAT)
+        .setDirection(Metric.DIRECTION_BETTER)
+        .setQualitative(true)
+        .setDomain(DOMAIN)
+        .setUserManaged(true)
+        .create(),
+      new Metric.Builder("team_size", "Team size", Metric.ValueType.INT)
+        .setDirection(Metric.DIRECTION_NONE)
+        .setQualitative(false)
+        .setDomain(DOMAIN)
+        .setUserManaged(true)
+        .create());
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/metric/package-info.java
new file mode 100644 (file)
index 0000000..820edea
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.server.metric;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index 59f0cc900fc8fd7e3815a6caa7dd1598ee938a35..847b5234a228c190766fe322166e0977720a92dc 100644 (file)
@@ -44,6 +44,7 @@ import org.sonar.core.qualitygate.db.ProjectQgateAssociationDao;
 import org.sonar.core.qualitygate.db.QualityGateConditionDao;
 import org.sonar.core.qualitygate.db.QualityGateDao;
 import org.sonar.core.resource.DefaultResourcePermissions;
+import org.sonar.core.resource.DefaultResourceTypes;
 import org.sonar.core.timemachine.Periods;
 import org.sonar.core.user.DefaultUserFinder;
 import org.sonar.core.user.HibernateUserFinder;
@@ -122,6 +123,7 @@ import org.sonar.server.duplication.ws.DuplicationsParser;
 import org.sonar.server.duplication.ws.DuplicationsWs;
 import org.sonar.server.es.IndexCreator;
 import org.sonar.server.es.IndexDefinitions;
+import org.sonar.server.event.NewAlerts;
 import org.sonar.server.issue.ActionService;
 import org.sonar.server.issue.AddTagsAction;
 import org.sonar.server.issue.AssignAction;
@@ -166,6 +168,7 @@ import org.sonar.server.measure.template.MyFavouritesFilter;
 import org.sonar.server.measure.template.ProjectFilter;
 import org.sonar.server.measure.ws.ManualMeasuresWs;
 import org.sonar.server.measure.ws.TimeMachineWs;
+import org.sonar.server.metric.CoreCustomMetrics;
 import org.sonar.server.metric.ws.MetricsWs;
 import org.sonar.server.notifications.NotificationCenter;
 import org.sonar.server.notifications.NotificationService;
@@ -340,6 +343,7 @@ public class PlatformLevel4 extends PlatformLevel {
       DistributionAreaChart.class,
       Views.class,
       ResourceTypes.class,
+      DefaultResourceTypes.class,
       SettingsChangeNotifier.class,
       PageDecorations.class,
       DefaultResourcePermissions.class,
@@ -488,6 +492,7 @@ public class PlatformLevel4 extends PlatformLevel {
       MeasureFilterEngine.class,
       ProjectFilter.class,
       MyFavouritesFilter.class,
+      CoreCustomMetrics.class,
       DefaultMetricFinder.class,
       ServerLifecycleNotifier.class,
       TimeMachineWs.class,
@@ -579,6 +584,7 @@ public class PlatformLevel4 extends PlatformLevel {
       org.sonar.server.component.ws.AppAction.class,
       org.sonar.server.component.ws.SearchAction.class,
       EventsWs.class,
+      NewAlerts.class,
       ComponentCleanerService.class,
       ProvisionedAction.class,
       GhostsAction.class,
diff --git a/server/sonar-server/src/test/java/org/sonar/server/event/NewAlertsTest.java b/server/sonar-server/src/test/java/org/sonar/server/event/NewAlertsTest.java
new file mode 100644 (file)
index 0000000..49bb6f7
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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.server.event;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+import org.junit.Test;
+import org.sonar.api.notifications.Notification;
+import org.sonar.api.notifications.NotificationChannel;
+import org.sonar.core.notification.NotificationDispatcher;
+import org.sonar.core.notification.NotificationManager;
+
+import static org.mockito.Mockito.*;
+
+public class NewAlertsTest {
+
+  NotificationManager notificationManager = mock(NotificationManager.class);
+  NotificationDispatcher.Context context = mock(NotificationDispatcher.Context.class);
+  NotificationChannel emailChannel = mock(NotificationChannel.class);
+  NotificationChannel twitterChannel = mock(NotificationChannel.class);
+  NewAlerts dispatcher = new NewAlerts(notificationManager);
+
+  @Test
+  public void should_not_dispatch_if_not_alerts_notification() {
+    Notification notification = new Notification("other-notif");
+    dispatcher.performDispatch(notification, context);
+
+    verify(context, never()).addUser(any(String.class), any(NotificationChannel.class));
+  }
+
+  @Test
+  public void should_dispatch_to_users_who_have_subscribed() {
+    Multimap<String, NotificationChannel> recipients = HashMultimap.create();
+    recipients.put("user1", emailChannel);
+    recipients.put("user2", twitterChannel);
+    when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, 34)).thenReturn(recipients);
+
+    Notification notification = new Notification("alerts").setFieldValue("projectId", "34");
+    dispatcher.performDispatch(notification, context);
+
+    verify(context).addUser("user1", emailChannel);
+    verify(context).addUser("user2", twitterChannel);
+    verifyNoMoreInteractions(context);
+  }
+
+  @Test
+  public void should_not_dispatch_if_missing_project_id() {
+    Multimap<String, NotificationChannel> recipients = HashMultimap.create();
+    recipients.put("user1", emailChannel);
+    recipients.put("user2", twitterChannel);
+    when(notificationManager.findSubscribedRecipientsForDispatcher(dispatcher, 34)).thenReturn(recipients);
+
+    Notification notification = new Notification("alerts");
+    dispatcher.performDispatch(notification, context);
+
+    verifyNoMoreInteractions(context);
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/CoreCustomMetricsTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/CoreCustomMetricsTest.java
new file mode 100644 (file)
index 0000000..9871f91
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.server.metric;
+
+import org.junit.Test;
+import org.sonar.api.measures.Metric;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CoreCustomMetricsTest {
+
+  @Test
+  public void checkDefinitions() {
+    CoreCustomMetrics coreCustomMetrics = new CoreCustomMetrics();
+    List<Metric> metrics = coreCustomMetrics.getMetrics();
+    assertThat(metrics.size()).isGreaterThan(2);
+    for (Metric metric : metrics) {
+      assertThat(metric.getUserManaged()).isTrue();
+      assertThat(metric.getDomain()).isEqualTo("Management");
+    }
+  }
+}
index ba42319b7bd324f8ecefb464ec36bd0af656cd05..f679ae3f8ce5cbe9fc0728879c6fbf5fdd497e62 100644 (file)
@@ -75,6 +75,7 @@ import org.sonar.batch.source.CodeColorizerSensor;
 import org.sonar.batch.source.LinesSensor;
 import org.sonar.core.config.CorePropertyDefinitions;
 import org.sonar.core.notification.DefaultNotificationManager;
+import org.sonar.core.resource.DefaultResourceTypes;
 
 public class BatchComponents {
   private BatchComponents() {
@@ -83,6 +84,8 @@ public class BatchComponents {
 
   public static Collection all(DefaultAnalysisMode analysisMode) {
     List components = Lists.newArrayList(
+      DefaultResourceTypes.class,
+
       // Maven
       MavenProjectBootstrapper.class, MavenProjectConverter.class, MavenProjectBuilder.class,
 
@@ -104,8 +107,6 @@ public class BatchComponents {
       SourceProvider.class,
       RuleNameProvider.class,
 
-      QualityGateVerifier.class,
-
       // language
       LanguageDistributionDecorator.class,
 
@@ -120,6 +121,7 @@ public class BatchComponents {
 
       // Quality Gate
       GenerateQualityGateEvents.class,
+      QualityGateVerifier.class,
 
       // Issue tracking
       IssueTrackingDecorator.class,
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 (file)
index 0000000..76e8805
--- /dev/null
@@ -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 (file)
index 0000000..ed418b9
--- /dev/null
@@ -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();
+  }
+}