aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test/java/org/sonar/api/config
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-04-19 17:50:52 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2013-04-19 17:51:37 +0200
commit236ceee8132a8295d9102841359a53ff29b19da0 (patch)
treec3f5dc7193f3a6fa0c3e5d1b7885a754a55631cb /sonar-plugin-api/src/test/java/org/sonar/api/config
parentabdafd47033c98ffe399ebc87709f07098b5a4aa (diff)
downloadsonarqube-236ceee8132a8295d9102841359a53ff29b19da0.tar.gz
sonarqube-236ceee8132a8295d9102841359a53ff29b19da0.zip
SONAR-3159 Properties sub-categories, sort and description
Diffstat (limited to 'sonar-plugin-api/src/test/java/org/sonar/api/config')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java37
1 files changed, 25 insertions, 12 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java
index 8b590184818..6b9a2842ea2 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java
@@ -34,7 +34,7 @@ public class PropertyDefinitionsTest {
PropertyDefinition.build("foo").name("Foo").build(),
PropertyDefinition.build("one").name("One").build(),
PropertyDefinition.build("two").name("Two").defaultValue("2").build()
- );
+ );
assertProperties(def);
}
@@ -58,7 +58,7 @@ public class PropertyDefinitionsTest {
PropertyDefinitions def = new PropertyDefinitions(
PropertyDefinition.build("inCateg").name("In Categ").category("categ").build(),
PropertyDefinition.build("noCateg").name("No categ").build()
- );
+ );
assertThat(def.getCategory("inCateg")).isEqualTo("categ");
assertThat(def.getCategory("noCateg")).isEmpty();
@@ -99,7 +99,7 @@ public class PropertyDefinitionsTest {
PropertyDefinition.build("project").name("Project").category("catProject").global(false).qualifiers(Qualifiers.PROJECT).build(),
PropertyDefinition.build("module").name("Module").category("catModule").global(false).qualifiers(Qualifiers.MODULE).build(),
PropertyDefinition.build("view").name("View").category("catView").global(false).qualifiers(Qualifiers.VIEW).build()
- );
+ );
assertThat(def.getPropertiesByCategory(null).keySet()).containsOnly("catGlobal1", "catGlobal2");
assertThat(def.getPropertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly("catProject");
@@ -109,6 +109,19 @@ public class PropertyDefinitionsTest {
}
@Test
+ public void should_group_by_subcategory() {
+ PropertyDefinitions def = new PropertyDefinitions(
+ PropertyDefinition.build("global1").name("Global1").category("catGlobal1").subcategory("sub1").global(true).build(),
+ PropertyDefinition.build("global2").name("Global2").category("catGlobal1").subcategory("sub2").global(true).build(),
+ PropertyDefinition.build("global3").name("Global3").category("catGlobal1").global(true).build(),
+ PropertyDefinition.build("global4").name("Global4").category("catGlobal2").global(true).build()
+ );
+
+ assertThat(def.getPropertiesByCategory(null).get("catGlobal1").keySet()).containsOnly("default", "sub1", "sub2");
+ assertThat(def.getPropertiesByCategory(null).get("catGlobal2").keySet()).containsOnly("default");
+ }
+
+ @Test
public void should_group_by_category_on_annotation_plugin() {
PropertyDefinitions def = new PropertyDefinitions(ByCategory.class);
@@ -134,25 +147,25 @@ public class PropertyDefinitionsTest {
}
@Properties({
- @Property(key = "one", name = "One"),
- @Property(key = "two", name = "Two", defaultValue = "2")
+ @Property(key = "one", name = "One"),
+ @Property(key = "two", name = "Two", defaultValue = "2")
})
static final class PluginWithProperties {
}
@Properties({
- @Property(key = "inCateg", name = "In Categ", category = "categ"),
- @Property(key = "noCateg", name = "No categ")
+ @Property(key = "inCateg", name = "In Categ", category = "categ"),
+ @Property(key = "noCateg", name = "No categ")
})
static final class Categories {
}
@Properties({
- @Property(key = "global1", name = "Global1", category = "catGlobal1", global = true, project = false, module = false),
- @Property(key = "global2", name = "Global2", category = "catGlobal1", global = true, project = false, module = false),
- @Property(key = "global3", name = "Global3", category = "catGlobal2", global = true, project = false, module = false),
- @Property(key = "project", name = "Project", category = "catProject", global = false, project = true, module = false),
- @Property(key = "module", name = "Module", category = "catModule", global = false, project = false, module = true)
+ @Property(key = "global1", name = "Global1", category = "catGlobal1", global = true, project = false, module = false),
+ @Property(key = "global2", name = "Global2", category = "catGlobal1", global = true, project = false, module = false),
+ @Property(key = "global3", name = "Global3", category = "catGlobal2", global = true, project = false, module = false),
+ @Property(key = "project", name = "Project", category = "catProject", global = false, project = true, module = false),
+ @Property(key = "module", name = "Module", category = "catModule", global = false, project = false, module = true)
})
static final class ByCategory {
}