From: Stephane Gamard Date: Fri, 23 May 2014 09:19:36 +0000 (+0200) Subject: SONAR-5007 - Added assertions for QualityProfile Registration X-Git-Tag: 4.4-RC1~874 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c3566e58ecc041f7ec0ef5c1c7d47f77df667b33;p=sonarqube.git SONAR-5007 - Added assertions for QualityProfile Registration --- diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/persistence/ActiveRuleDao.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/persistence/ActiveRuleDao.java index be56443888e..1d525c512af 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/persistence/ActiveRuleDao.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/persistence/ActiveRuleDao.java @@ -166,6 +166,14 @@ public class ActiveRuleDao extends BaseDao findParamsByKey(ActiveRuleKey key, DbSession session) { + Preconditions.checkArgument(key != null, "ActiveRuleKey cannot be null"); + ActiveRuleDto activeRule = this.getByKey(key,session); + return mapper(session).selectParamsByActiveRuleId(activeRule.getId()); + } + + public ActiveRuleParamDto getParamsByKeyAndName(ActiveRuleKey key, String name, DbSession session) { + Preconditions.checkArgument(key != null, "ActiveRuleKey cannot be null"); + Preconditions.checkArgument(name != null, "ParameterName cannot be null"); + ActiveRuleDto activeRule = this.getByKey(key,session); + return mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), name); + } + + public List findParamsByActiveRule(ActiveRuleDto dto, DbSession session) { Preconditions.checkArgument(dto.getId() != null, "ActiveRule is not persisted"); return mapper(session).selectParamsByActiveRuleId(dto.getId()); diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java index da6e03b5be0..ab100038911 100644 --- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java +++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java @@ -162,10 +162,16 @@ public class ActiveRuleServiceMediumTest { public void update_activation_but_new_parameter() throws Exception { // initial activation grantPermission(); - RuleActivation activation = new RuleActivation(ActiveRuleKey.of(profileKey, RuleKey.of("xoo", "x1"))); + ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profileKey, RuleKey.of("xoo", "x1")); + RuleActivation activation = new RuleActivation(activeRuleKey); activation.setSeverity(Severity.BLOCKER); service.activate(activation); - // TODO delete activeruleparam max + + + assertThat(dbClient.activeRuleDao().getParamsByKeyAndName(activeRuleKey,"max",dbSession)).isNotNull(); + dbClient.activeRuleDao().removeParamByKeyAndName(activeRuleKey,"max",dbSession); + dbSession.commit(); + assertThat(dbClient.activeRuleDao().getParamsByKeyAndName(activeRuleKey,"max",dbSession)).isNull(); // update