diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-07-18 12:18:39 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-07-18 15:43:39 +0200 |
commit | c3174fada2ab193d03661209bee3291772b8f347 (patch) | |
tree | 2c421a541d108f24bbab0c861c6ab9aaedfa7bdc /server/sonar-server | |
parent | 274e9cefeb16fab1d5e35088289338f12993b208 (diff) | |
download | sonarqube-c3174fada2ab193d03661209bee3291772b8f347.tar.gz sonarqube-c3174fada2ab193d03661209bee3291772b8f347.zip |
SONAR-5417 Get active rules using batch protocol
Diffstat (limited to 'server/sonar-server')
2 files changed, 13 insertions, 8 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java index 9538f515703..3ecb31a6e4f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java @@ -41,6 +41,7 @@ import org.sonar.server.search.action.IndexAction; import org.sonar.server.search.action.KeyIndexAction; import javax.annotation.CheckForNull; + import java.sql.Timestamp; import java.util.Date; import java.util.List; @@ -58,7 +59,7 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti private static final String ACTIVE_RULE_PARAM_IS_ALREADY_PERSISTED = "ActiveRuleParam is already persisted"; private static final String PARAMETER_NAME_CANNOT_BE_NULL = "ParameterName cannot be null"; - //TODO remove once key is finalized (used only to get id for SQL statement) + // TODO remove once key is finalized (used only to get id for SQL statement) private final RuleDao ruleDao; private final QualityProfileDao profileDao; @@ -98,7 +99,7 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti ActiveRuleDto activeRule = mapper(session).selectById(activeRuleId); if (activeRule != null) { QualityProfileDto profile = profileDao.getById(activeRule.getProfileId(), session); - RuleDto rule = ruleDao.getById(session, activeRule.getRulId()); + RuleDto rule = ruleDao.getById(session, activeRule.getRuleId()); if (profile != null && rule != null) { activeRule.setKey(ActiveRuleKey.of(profile.getKey(), rule.getKey())); return activeRule; @@ -115,7 +116,7 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti @Override protected ActiveRuleDto doInsert(DbSession session, ActiveRuleDto item) { Preconditions.checkArgument(item.getProfileId() != null, QUALITY_PROFILE_IS_NOT_PERSISTED); - Preconditions.checkArgument(item.getRulId() != null, RULE_IS_NOT_PERSISTED); + Preconditions.checkArgument(item.getRuleId() != null, RULE_IS_NOT_PERSISTED); Preconditions.checkArgument(item.getId() == null, ACTIVE_RULE_IS_ALREADY_PERSISTED); mapper(session).insert(item); return item; @@ -124,7 +125,7 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti @Override protected ActiveRuleDto doUpdate(DbSession session, ActiveRuleDto item) { Preconditions.checkArgument(item.getProfileId() != null, QUALITY_PROFILE_IS_NOT_PERSISTED); - Preconditions.checkArgument(item.getRulId() != null, ActiveRuleDao.RULE_IS_NOT_PERSISTED); + Preconditions.checkArgument(item.getRuleId() != null, ActiveRuleDao.RULE_IS_NOT_PERSISTED); Preconditions.checkArgument(item.getId() != null, ACTIVE_RULE_IS_NOT_PERSISTED); mapper(session).update(item); return item; @@ -172,7 +173,7 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti } public void removeParamByKeyAndName(DbSession session, ActiveRuleKey key, String param) { - //TODO SQL rewrite to delete by key + // TODO SQL rewrite to delete by key ActiveRuleDto activeRule = getNullableByKey(session, key); if (activeRule != null) { ActiveRuleParamDto activeRuleParam = mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), param); @@ -222,7 +223,7 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti Preconditions.checkNotNull(key, ACTIVE_RULE_KEY_CANNOT_BE_NULL); Preconditions.checkNotNull(name, PARAMETER_NAME_CANNOT_BE_NULL); ActiveRuleDto activeRule = getNullableByKey(session, key); - if (activeRule!=null) { + if (activeRule != null) { return mapper(session).selectParamByActiveRuleAndKey(activeRule.getId(), name); } return null; diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileRepositoryExporterTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileRepositoryExporterTest.java index d4bf7a3ecb8..cdbc9cad7aa 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileRepositoryExporterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileRepositoryExporterTest.java @@ -50,7 +50,11 @@ import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.Fail.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class QProfileRepositoryExporterTest { @@ -105,7 +109,7 @@ public class QProfileRepositoryExporterTest { ArgumentCaptor<ActiveRuleDto> activeRuleArgument = ArgumentCaptor.forClass(ActiveRuleDto.class); verify(activeRuleDao).insert(activeRuleArgument.capture(), eq(session)); - assertThat(activeRuleArgument.getValue().getRulId()).isEqualTo(10); + assertThat(activeRuleArgument.getValue().getRuleId()).isEqualTo(10); assertThat(activeRuleArgument.getValue().getSeverityString()).isEqualTo(Severity.BLOCKER); ArgumentCaptor<ActiveRuleParamDto> activeRuleParamArgument = ArgumentCaptor.forClass(ActiveRuleParamDto.class); |