aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@searchbox.com>2014-05-08 18:19:03 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-05-08 18:19:03 +0200
commita376c8c0fdec360131823bd52c9d970f859d34ec (patch)
treed71a81f6d56c6f70ef15c0f3f5cf07756adf4c63 /sonar-server
parentc3999588a43d2c9e9779a2b66070b0a1c645c794 (diff)
downloadsonarqube-a376c8c0fdec360131823bd52c9d970f859d34ec.tar.gz
sonarqube-a376c8c0fdec360131823bd52c9d970f859d34ec.zip
added tag test to RuleDaoTest
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule2/RuleDaoTest.java32
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/rule2/RuleDaoTest/select_tags_by_rule_id.xml16
2 files changed, 19 insertions, 29 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/rule2/RuleDaoTest.java b/sonar-server/src/test/java/org/sonar/server/rule2/RuleDaoTest.java
index bffa49bb6d5..be63b5a5e9b 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule2/RuleDaoTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule2/RuleDaoTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.rule2;
-import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import org.junit.After;
@@ -383,27 +382,16 @@ public class RuleDaoTest extends AbstractDaoTestCase {
checkTables("update_parameter", "rules_parameters");
}
-//
-// @Test
-// public void select_tags_by_rule_id() throws Exception {
-// setupData("select_tags_by_rule_id");
-//
-// assertThat(dao.selectTagsByRuleId(3)).hasSize(2);
-// }
-//
-// @Test
-// public void select_tags_by_rule_ids() throws Exception {
-// setupData("select_tags_by_rule_ids");
-//
-// assertThat(dao.selectTagsByRuleIds(newArrayList(3, 4))).hasSize(3);
-// }
- private List<Integer> idsFromRuleDtos(List<RuleDto> ruleDtos){
- return newArrayList(Iterables.transform(ruleDtos, new Function<RuleDto, Integer>() {
- @Override
- public Integer apply(RuleDto input) {
- return input.getId();
- }
- }));
+ @Test
+ public void select_tags_by_rule() throws Exception {
+ setupData("select_tags_by_rule_id");
+
+ RuleDto rule = dao.getById(1, session);
+ assertThat(rule.getSystemTags()).hasSize(2);
+ assertThat(rule.getTags()).hasSize(3);
+ assertThat(rule.getTags()).containsOnly("tag1", "tag2","tag3");
+ assertThat(rule.getSystemTags()).containsOnly("systag1", "systag2");
+
}
}
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule2/RuleDaoTest/select_tags_by_rule_id.xml b/sonar-server/src/test/resources/org/sonar/server/rule2/RuleDaoTest/select_tags_by_rule_id.xml
index 8d252e540b4..3feba4d4b8e 100644
--- a/sonar-server/src/test/resources/org/sonar/server/rule2/RuleDaoTest/select_tags_by_rule_id.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/rule2/RuleDaoTest/select_tags_by_rule_id.xml
@@ -1,11 +1,13 @@
<dataset>
- <rule_tags id="3" tag="tag1"/>
- <rule_tags id="4" tag="tag3"/>
- <rule_tags id="5" tag="tag5"/>
-
- <rules_rule_tags id="3" rule_id="3" rule_tag_id="3" tag_type="SYSTEM"/>
- <rules_rule_tags id="4" rule_id="3" rule_tag_id="4" tag_type="SYSTEM"/>
- <rules_rule_tags id="5" rule_id="4" rule_tag_id="5" tag_type="SYSTEM"/>
+ <rules tags="tag1,tag2,tag3" system_tags="systag1,systag2" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
+ plugin_config_key="NewConfigKey" priority="0" cardinality="MULTIPLE" language="dart" created_at="2013-12-16" updated_at="2013-12-17" parent_id="3"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
+ characteristic_id="100" default_characteristic_id="101"
+ remediation_function="linear" default_remediation_function="linear_offset"
+ remediation_coeff="1h" default_remediation_coeff="5d"
+ remediation_offset="5min" default_remediation_offset="10h"
+ effort_to_fix_description="squid.S115.effortToFix"
+ />
</dataset>