aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-18 16:39:58 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2013-12-18 16:39:58 +0100
commite99a948405e47182d419353341560711ee8f40bf (patch)
tree587d0728de0867d2f4b159dce5b9b3b81e848099 /sonar-core
parent0d1e9894c0149962ebf7ac12b66a9c5c2de21aae (diff)
downloadsonarqube-e99a948405e47182d419353341560711ee8f40bf.tar.gz
sonarqube-e99a948405e47182d419353341560711ee8f40bf.zip
SONAR-4535 create activate / deactivate / update severity actions in QProfiles
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java64
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java12
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java16
-rw-r--r--sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java8
-rw-r--r--sonar-core/src/main/java/org/sonar/core/rule/RuleParamDto.java18
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql2
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl1
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml61
-rw-r--r--sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java75
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/delete-result.xml9
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/delete_parameters-result.xml14
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/empty.xml3
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/insertParameter-result.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/shared.xml14
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/update-result.xml9
16 files changed, 284 insertions, 26 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
index f9785136f17..d2ca80341e3 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
@@ -33,7 +33,7 @@ import java.util.List;
*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 482;
+ public static final int LAST_VERSION = 484;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java
index 2346103e655..00dc167dced 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java
@@ -32,6 +32,28 @@ public class ActiveRuleDao implements ServerComponent {
this.mybatis = mybatis;
}
+ public ActiveRuleDto selectById(Integer id) {
+ SqlSession session = mybatis.openSession();
+ try {
+ return session.getMapper(ActiveRuleMapper.class).selectById(id);
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
+ public ActiveRuleDto selectByProfileAndRule(Integer profileId, Integer ruleId) {
+ SqlSession session = mybatis.openSession();
+ try {
+ return selectByProfileAndRule(profileId, ruleId, session);
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
+ public ActiveRuleDto selectByProfileAndRule(Integer profileId, Integer ruleId, SqlSession session) {
+ return session.getMapper(ActiveRuleMapper.class).selectByProfileAndRule(profileId, ruleId);
+ }
+
public void insert(ActiveRuleDto dto, SqlSession session) {
session.getMapper(ActiveRuleMapper.class).insert(dto);
}
@@ -46,6 +68,20 @@ public class ActiveRuleDao implements ServerComponent {
}
}
+ public void update(ActiveRuleDto dto, SqlSession session) {
+ session.getMapper(ActiveRuleMapper.class).update(dto);
+ }
+
+ public void update(ActiveRuleDto dto) {
+ SqlSession session = mybatis.openSession();
+ try {
+ update(dto, session);
+ session.commit();
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
public void insert(ActiveRuleParamDto dto, SqlSession session) {
session.getMapper(ActiveRuleMapper.class).insertParameter(dto);
}
@@ -60,4 +96,32 @@ public class ActiveRuleDao implements ServerComponent {
}
}
+ public void delete(Integer activeRuleId, SqlSession session) {
+ session.getMapper(ActiveRuleMapper.class).delete(activeRuleId);
+ }
+
+ public void delete(Integer activeRuleId) {
+ SqlSession session = mybatis.openSession();
+ try {
+ delete(activeRuleId, session);
+ session.commit();
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
+ public void deleteParameters(Integer activeRuleIdo, SqlSession session) {
+ session.getMapper(ActiveRuleMapper.class).deleteParameters(activeRuleIdo);
+ }
+
+ public void deleteParameters(Integer activeRuleId) {
+ SqlSession session = mybatis.openSession();
+ try {
+ deleteParameters(activeRuleId, session);
+ session.commit();
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
}
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java
index f04dd148cb8..07137e58fd3 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java
@@ -83,31 +83,35 @@ public class ActiveRuleDto {
return noteCreatedAt;
}
- public void setNoteCreatedAt(Date noteCreatedAt) {
+ public ActiveRuleDto setNoteCreatedAt(Date noteCreatedAt) {
this.noteCreatedAt = noteCreatedAt;
+ return this;
}
public Date getNoteUpdatedAt() {
return noteUpdatedAt;
}
- public void setNoteUpdatedAt(Date noteUpdatedAt) {
+ public ActiveRuleDto setNoteUpdatedAt(Date noteUpdatedAt) {
this.noteUpdatedAt = noteUpdatedAt;
+ return this;
}
public String getNoteUserLogin() {
return noteUserLogin;
}
- public void setNoteUserLogin(String noteUserLogin) {
+ public ActiveRuleDto setNoteUserLogin(String noteUserLogin) {
this.noteUserLogin = noteUserLogin;
+ return this;
}
public String getNoteData() {
return noteData;
}
- public void setNoteData(String noteData) {
+ public ActiveRuleDto setNoteData(String noteData) {
this.noteData = noteData;
+ return this;
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java
index e4068570c50..0805237691d 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java
@@ -20,10 +20,26 @@
package org.sonar.core.qualityprofile.db;
+import org.apache.ibatis.annotations.Param;
+
+import javax.annotation.CheckForNull;
+
public interface ActiveRuleMapper {
+ @CheckForNull
+ ActiveRuleDto selectById(Integer id);
+
+ @CheckForNull
+ ActiveRuleDto selectByProfileAndRule(@Param("profileId") Integer profileId, @Param("ruleId") Integer ruleId);
+
void insert(ActiveRuleDto dto);
+ void update(ActiveRuleDto dto);
+
void insertParameter(ActiveRuleParamDto dto);
+ void delete(Integer activeRuleId);
+
+ void deleteParameters(Integer activeRuleId);
+
}
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java
index 82001371398..60fcf4b6b74 100644
--- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java
@@ -85,7 +85,7 @@ public class RuleDao implements BatchComponent, ServerComponent {
public void insert(Collection<RuleDto> rules) {
SqlSession session = mybatis.openBatchSession();
try {
- for (RuleDto rule: rules) {
+ for (RuleDto rule : rules) {
getMapper(session).insert(rule);
}
session.commit();
@@ -106,12 +106,16 @@ public class RuleDao implements BatchComponent, ServerComponent {
public List<RuleParamDto> selectParameters(Long id) {
SqlSession session = mybatis.openSession();
try {
- return getMapper(session).selectParamsForRule(id);
+ return selectParameters(id, session);
} finally {
MyBatis.closeQuietly(session);
}
}
+ public List<RuleParamDto> selectParameters(Long id, SqlSession session) {
+ return getMapper(session).selectParamsForRule(id);
+ }
+
private RuleMapper getMapper(SqlSession session) {
return session.getMapper(RuleMapper.class);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleParamDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleParamDto.java
index 793b56d22bf..7a4f999f743 100644
--- a/sonar-core/src/main/java/org/sonar/core/rule/RuleParamDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleParamDto.java
@@ -33,47 +33,53 @@ public class RuleParamDto {
return id;
}
- public void setId(int id) {
+ public RuleParamDto setId(int id) {
this.id = id;
+ return this;
}
public Long getRuleId() {
return ruleId;
}
- public void setRuleId(Long ruleId) {
+ public RuleParamDto setRuleId(Long ruleId) {
this.ruleId = ruleId;
+ return this;
}
public String getName() {
return name;
}
- public void setName(String name) {
+ public RuleParamDto setName(String name) {
this.name = name;
+ return this;
}
public String getType() {
return type;
}
- public void setType(String type) {
+ public RuleParamDto setType(String type) {
this.type = type;
+ return this;
}
public String getDefaultValue() {
return defaultValue;
}
- public void setDefaultValue(String defaultValue) {
+ public RuleParamDto setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
+ return this;
}
public String getDescription() {
return description;
}
- public void setDescription(String description) {
+ public RuleParamDto setDescription(String description) {
this.description = description;
+ return this;
}
}
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
index 3c128f020a1..e0ce7afbee1 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
@@ -193,6 +193,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('466');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('480');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('481');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('482');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('483');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('484');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
index 670337719f1..1ef71efa658 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
@@ -319,6 +319,7 @@ CREATE TABLE "ACTIVE_RULE_PARAMETERS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"ACTIVE_RULE_ID" INTEGER NOT NULL,
"RULES_PARAMETER_ID" INTEGER NOT NULL,
+ "RULES_PARAMETER_KEY" VARCHAR(128),
"VALUE" VARCHAR(4000)
);
diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml
index e47f8f4abae..009bf47efc1 100644
--- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml
@@ -4,27 +4,64 @@
<mapper namespace="org.sonar.core.qualityprofile.db.ActiveRuleMapper">
<sql id="activeRuleColumns">
- p.id,
- p.profile_id as profileId,
- p.rule_id as ruleId,
- p.failure_level as severity,
- p.version as version,
- p.used_profile as used,
- p.note_created_at,
- p.note_updated_at,
- p.note_user_login,
- p.note_data
+ a.id,
+ a.profile_id as profileId,
+ a.rule_id as ruleId,
+ a.failure_level as severity,
+ a.inheritance as inheritance,
+ a.note_data as noteData,
+ a.note_user_login as noteUserLogin,
+ a.note_updated_at as noteUpdatedAt,
+ a.note_created_at as noteCreatedAt
</sql>
+ <select id="selectById" parameterType="Integer" resultType="ActiveRule">
+ SELECT <include refid="activeRuleColumns"/>
+ FROM active_rules a
+ <where>
+ AND id=#{id}
+ </where>
+ </select>
+
+ <select id="selectByProfileAndRule" parameterType="map" resultType="ActiveRule">
+ SELECT <include refid="activeRuleColumns"/>
+ FROM active_rules a
+ <where>
+ AND profile_id=#{profileId}
+ AND rule_id=#{ruleId}
+ </where>
+ </select>
+
<insert id="insert" parameterType="ActiveRule" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
INSERT INTO active_rules (profile_id, rule_id, failure_level, inheritance, note_created_at, note_updated_at, note_user_login, note_data)
VALUES (#{profileId}, #{ruleId}, #{severity}, #{inheritance}, #{noteCreatedAt}, #{noteUpdatedAt}, #{noteUserLogin}, #{noteData})
</insert>
+ <update id="update" parameterType="ActiveRule">
+ UPDATE active_rules SET
+ profile_id=#{profileId},
+ rule_id=#{ruleId},
+ failure_level=#{severity},
+ inheritance=#{inheritance},
+ note_created_at=#{noteCreatedAt},
+ note_updated_at=#{noteUpdatedAt},
+ note_user_login=#{noteUserLogin},
+ note_data=#{noteData}
+ WHERE id=#{id}
+ </update>
+
<insert id="insertParameter" parameterType="ActiveRuleParam" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO active_rule_parameters (active_rule_id, rules_parameter_id, value)
- VALUES (#{activeRuleId}, #{rulesParameterId}, #{value})
+ INSERT INTO active_rule_parameters (active_rule_id, rules_parameter_id, rules_parameter_key, value)
+ VALUES (#{activeRuleId}, #{rulesParameterId}, #{key}, #{value})
</insert>
+ <update id="delete" parameterType="Integer">
+ DELETE FROM active_rules WHERE id=#{id}
+ </update>
+
+ <update id="deleteParameters" parameterType="Integer">
+ DELETE FROM active_rule_parameters WHERE active_rule_id=#{id}
+ </update>
+
</mapper>
diff --git a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java
index ddfe06f8c65..53114042072 100644
--- a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java
@@ -22,8 +22,11 @@ package org.sonar.core.qualityprofile.db;
import org.junit.Before;
import org.junit.Test;
+import org.sonar.api.utils.DateUtils;
import org.sonar.core.persistence.AbstractDaoTestCase;
+import static org.fest.assertions.Assertions.assertThat;
+
public class ActiveRuleDaoTest extends AbstractDaoTestCase {
ActiveRuleDao dao;
@@ -34,7 +37,41 @@ public class ActiveRuleDaoTest extends AbstractDaoTestCase {
}
@Test
+ public void select_by_id() {
+ setupData("shared");
+
+ ActiveRuleDto result = dao.selectById(1);
+ assertThat(result.getId()).isEqualTo(1);
+ assertThat(result.getProfileId()).isEqualTo(1);
+ assertThat(result.getRulId()).isEqualTo(10);
+ assertThat(result.getSeverity()).isEqualTo(2);
+ assertThat(result.getInheritance()).isEqualTo("INHERITED");
+ assertThat(result.getNoteData()).isEqualTo("some note");
+ assertThat(result.getNoteUserLogin()).isEqualTo("henry");
+ assertThat(result.getNoteCreatedAt()).isEqualTo(DateUtils.parseDate("2013-12-18"));
+ assertThat(result.getNoteUpdatedAt()).isEqualTo(DateUtils.parseDate("2013-12-18"));
+ }
+
+ @Test
+ public void select_by_profile_and_rule() {
+ setupData("shared");
+
+ ActiveRuleDto result = dao.selectByProfileAndRule(1, 10);
+ assertThat(result.getId()).isEqualTo(1);
+ assertThat(result.getProfileId()).isEqualTo(1);
+ assertThat(result.getRulId()).isEqualTo(10);
+ assertThat(result.getSeverity()).isEqualTo(2);
+ assertThat(result.getInheritance()).isEqualTo("INHERITED");
+ assertThat(result.getNoteData()).isEqualTo("some note");
+ assertThat(result.getNoteUserLogin()).isEqualTo("henry");
+ assertThat(result.getNoteCreatedAt()).isEqualTo(DateUtils.parseDate("2013-12-18"));
+ assertThat(result.getNoteUpdatedAt()).isEqualTo(DateUtils.parseDate("2013-12-18"));
+ }
+
+ @Test
public void insert() {
+ setupData("empty");
+
ActiveRuleDto dto = new ActiveRuleDto()
.setProfileId(1)
.setRuleId(10)
@@ -47,14 +84,52 @@ public class ActiveRuleDaoTest extends AbstractDaoTestCase {
}
@Test
+ public void update() {
+ setupData("shared");
+
+ ActiveRuleDto dto = new ActiveRuleDto()
+ .setId(1)
+ .setProfileId(1)
+ .setRuleId(10)
+ .setSeverity(4)
+ .setInheritance(null)
+ .setNoteData("text");
+
+ dao.update(dto);
+
+ checkTables("update", "active_rules");
+ }
+
+ @Test
public void insert_parameter() {
+ setupData("empty");
+
ActiveRuleParamDto dto = new ActiveRuleParamDto()
.setActiveRuleId(1)
.setRulesParameterId(1)
+ .setKey("max")
.setValue("20");
dao.insert(dto);
checkTables("insertParameter", "active_rule_parameters");
}
+
+ @Test
+ public void delete() {
+ setupData("shared");
+
+ dao.delete(1);
+
+ checkTables("delete", "active_rules");
+ }
+
+ @Test
+ public void delete_parameters() {
+ setupData("shared");
+
+ dao.deleteParameters(1);
+
+ checkTables("delete_parameters", "active_rule_parameters");
+ }
}
diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/delete-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/delete-result.xml
new file mode 100644
index 00000000000..2a65aa4de98
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/delete-result.xml
@@ -0,0 +1,9 @@
+<dataset>
+
+ <!--<active_rules id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"-->
+ <!--note_created_at="2013-12-18" note_updated_at="2013-12-18" note_user_login="henry" note_data="some note"/>-->
+
+ <active_rules id="2" profile_id="1" rule_id="11" failure_level="0" inheritance="[null]"
+ note_created_at="2013-12-18" note_updated_at="2013-12-18" note_user_login="john" note_data="other note"/>
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/delete_parameters-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/delete_parameters-result.xml
new file mode 100644
index 00000000000..b986e9f8b0a
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/delete_parameters-result.xml
@@ -0,0 +1,14 @@
+<dataset>
+
+ <active_rules id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"
+ note_created_at="[null]" note_updated_at="[null]" note_user_login="[null]" note_data="[null]"/>
+
+ <active_rules id="2" profile_id="1" rule_id="11" failure_level="0" inheritance="[null]"
+ note_created_at="[null]" note_updated_at="[null]" note_user_login="[null]" note_data="[null]"/>
+
+ <!--<active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>-->
+ <!--<active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" rules_parameter_key="format" value="html"/>-->
+
+ <active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/>
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/empty.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/empty.xml
new file mode 100644
index 00000000000..871dedcb5e9
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/empty.xml
@@ -0,0 +1,3 @@
+<dataset>
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/insertParameter-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/insertParameter-result.xml
index 69ec55f8007..ed2e17d48d3 100644
--- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/insertParameter-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/insertParameter-result.xml
@@ -1,5 +1,5 @@
<dataset>
- <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" value="20"/>
+ <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/shared.xml
new file mode 100644
index 00000000000..3d92151f292
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/shared.xml
@@ -0,0 +1,14 @@
+<dataset>
+
+ <active_rules id="1" profile_id="1" rule_id="10" failure_level="2" inheritance="INHERITED"
+ note_created_at="2013-12-18" note_updated_at="2013-12-18" note_user_login="henry" note_data="some note"/>
+
+ <active_rules id="2" profile_id="1" rule_id="11" failure_level="0" inheritance="[null]"
+ note_created_at="2013-12-18" note_updated_at="2013-12-18" note_user_login="john" note_data="other note"/>
+
+ <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" rules_parameter_key="max" value="20"/>
+ <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" rules_parameter_key="format" value="html"/>
+
+ <active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/>
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/update-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/update-result.xml
new file mode 100644
index 00000000000..87b48ac77a3
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/update-result.xml
@@ -0,0 +1,9 @@
+<dataset>
+
+ <active_rules id="1" profile_id="1" rule_id="10" failure_level="4" inheritance="[null]"
+ note_created_at="[null]" note_updated_at="[null]" note_user_login="[null]" note_data="text"/>
+
+ <active_rules id="2" profile_id="1" rule_id="11" failure_level="0" inheritance="[null]"
+ note_created_at="2013-12-18" note_updated_at="2013-12-18" note_user_login="john" note_data="other note"/>
+
+</dataset>