diff options
author | David Gageot <david@gageot.net> | 2012-07-12 16:13:15 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-07-12 17:21:01 +0200 |
commit | b5f52d01f06c94bd179e6eba6c86180199734735 (patch) | |
tree | 2ffe9ba15be9913cb27a5aa473539739edf52aba /plugins | |
parent | 99be026f67711291551d178d13040f7417825c67 (diff) | |
download | sonarqube-b5f52d01f06c94bd179e6eba6c86180199734735.tar.gz sonarqube-b5f52d01f06c94bd179e6eba6c86180199734735.zip |
SONAR-3510 Select a view or a developer when adding a widget to a global dashboard
Diffstat (limited to 'plugins')
2 files changed, 39 insertions, 32 deletions
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 index a05b3e65ef8..e2b9328d31f 100644 --- 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 @@ -29,33 +29,30 @@ import org.sonar.api.resources.ResourceTypeTree; @InstantiationStrategy(InstantiationStrategy.PER_BATCH) public final class DefaultResourceTypes extends ExtensionProvider implements BatchExtension, ServerExtension { - @Override public ResourceTypeTree provide() { return ResourceTypeTree.builder() - - .addType(ResourceType.builder(Qualifiers.PROJECT) - .setProperty("deletable", true) - .setProperty("modifiable_history", true) - .setProperty("hasRolePolicy", true) - .setProperty("updatable_key", true) - .build()) - .addType(ResourceType.builder(Qualifiers.MODULE) - .setProperty("updatable_key", true) - .build()) - .addType(ResourceType.builder(Qualifiers.DIRECTORY).build()) - .addType(ResourceType.builder(Qualifiers.PACKAGE).build()) - .addType(ResourceType.builder(Qualifiers.FILE).hasSourceCode().build()) - .addType(ResourceType.builder(Qualifiers.CLASS).hasSourceCode().build()) - .addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE).hasSourceCode().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(); - + .addType(ResourceType.builder(Qualifiers.PROJECT) + .setProperty("deletable", true) + .setProperty("supportsGlobalDashboards", true) + .setProperty("modifiable_history", true) + .setProperty("hasRolePolicy", true) + .setProperty("updatable_key", true) + .build()) + .addType(ResourceType.builder(Qualifiers.MODULE) + .setProperty("updatable_key", true) + .build()) + .addType(ResourceType.builder(Qualifiers.DIRECTORY).build()) + .addType(ResourceType.builder(Qualifiers.PACKAGE).build()) + .addType(ResourceType.builder(Qualifiers.FILE).hasSourceCode().build()) + .addType(ResourceType.builder(Qualifiers.CLASS).hasSourceCode().build()) + .addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE).hasSourceCode().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/test/java/org/sonar/plugins/core/DefaultResourceTypesTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/DefaultResourceTypesTest.java index 9bf732c734c..55b41931402 100644 --- 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 @@ -19,20 +19,30 @@ */ 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.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.IsCollectionContaining.hasItem; +import static org.fest.assertions.Assertions.assertThat; public class DefaultResourceTypesTest { @Test - public void provide() { + public void should_provide() { + 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(); - assertThat(tree.getTypes().size(), is(7)); - assertThat(tree.getChildren(Qualifiers.PROJECT).size(), is(1)); - assertThat(tree.getChildren(Qualifiers.PROJECT), hasItem(Qualifiers.MODULE)); + + ResourceType projectResourceType = tree.getTypes().get(0); + + assertThat(projectResourceType.getQualifier()).isEqualTo(Qualifiers.PROJECT); + assertThat(projectResourceType.getBooleanProperty("supportsGlobalDashboards")).isTrue(); } } |