diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-03-24 17:39:57 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-03-29 19:12:00 +0200 |
commit | e2e23d7aefd4b8a0938412327f2d9f57c3389cda (patch) | |
tree | 511260600233b8d5ae03589cb6b5d8aa025a312a /server/sonar-server | |
parent | 9fc9cbd7ed08be84e9f16dc0cdacc41dff63acad (diff) | |
download | sonarqube-e2e23d7aefd4b8a0938412327f2d9f57c3389cda.tar.gz sonarqube-e2e23d7aefd4b8a0938412327f2d9f57c3389cda.zip |
SONAR-7470 Remove 'manual' from SQL queries
Diffstat (limited to 'server/sonar-server')
4 files changed, 29 insertions, 29 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java index 3936627a40c..60b47e10347 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java @@ -88,7 +88,7 @@ public class DebtModelBackup { DbSession session = dbClient.openSession(false); try { List<RuleDebt> rules = newArrayList(); - for (RuleDto rule : dbClient.ruleDao().selectEnabledAndNonManual(session)) { + for (RuleDto rule : dbClient.ruleDao().selectEnabled(session)) { if (languageKey == null || languageKey.equals(rule.getLanguage())) { RuleDebt ruleDebt = toRuleDebt(rule); if (ruleDebt != null) { @@ -112,7 +112,7 @@ public class DebtModelBackup { DbSession session = dbClient.openSession(false); try { // Restore rules - List<RuleDto> ruleDtos = dbClient.ruleDao().selectEnabledAndNonManual(session); + List<RuleDto> ruleDtos = dbClient.ruleDao().selectEnabled(session); if (!ruleDtos.isEmpty()) { // Load default rule definitions @@ -215,7 +215,7 @@ public class DebtModelBackup { } private List<RuleDto> rules(@Nullable String languageKey, DbSession session) { - List<RuleDto> rules = dbClient.ruleDao().selectEnabledAndNonManual(session); + List<RuleDto> rules = dbClient.ruleDao().selectEnabled(session); if (languageKey == null) { return rules; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java index c6c3cd28a5d..36ad359472e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -147,7 +147,7 @@ public class RegisterRules implements Startable { private Map<RuleKey, RuleDto> loadRules(DbSession session) { Map<RuleKey, RuleDto> rules = new HashMap<>(); - for (RuleDto rule : dbClient.ruleDao().selectByNonManual(session)) { + for (RuleDto rule : dbClient.ruleDao().selectAll(session)) { rules.put(rule.getKey(), rule); } return rules; diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java index e3600f906d6..5ffb6f0fd37 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java @@ -57,7 +57,7 @@ public class ListAction implements RulesWsAction { final ListResponse.Builder listResponseBuilder = ListResponse.newBuilder(); final ListResponse.Rule.Builder ruleBuilder = ListResponse.Rule.newBuilder(); try { - dbClient.ruleDao().selectEnabledAndNonManual(dbSession, new ResultHandler() { + dbClient.ruleDao().selectEnabled(dbSession, new ResultHandler() { @Override public void handleResult(ResultContext resultContext) { RuleDto dto = (RuleDto) resultContext.getResultObject(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java index 8059f475f04..f1b87603ddb 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java @@ -114,7 +114,7 @@ public class DebtModelBackupTest { @Test public void backup() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn( + when(ruleDao.selectEnabled(session)).thenReturn( newArrayList( // Rule with overridden debt values new RuleDto().setRepositoryKey("squid").setRuleKey("UselessImportCheck") @@ -150,7 +150,7 @@ public class DebtModelBackupTest { @Test public void backup_with_disabled_rules() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( // Debt disabled new RuleDto().setRepositoryKey("squid").setRuleKey("UselessImportCheck"), @@ -167,7 +167,7 @@ public class DebtModelBackupTest { @Test public void backup_with_rule_having_default_linear_and_overridden_offset() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( // Rule with default debt values : default value is linear (only coefficient is set) and overridden value is constant per issue (only // offset is set) // -> Ony offset should be set @@ -195,7 +195,7 @@ public class DebtModelBackupTest { @Test public void backup_from_language() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java") .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.toString()) .setRemediationBaseEffort("15min"), @@ -223,7 +223,7 @@ public class DebtModelBackupTest { @Test public void reset_model() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( new RuleDto().setRepositoryKey("squid").setRuleKey("NPE") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) .setDefaultRemediationGapMultiplier("2h") @@ -245,7 +245,7 @@ public class DebtModelBackupTest { underTest.reset(); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(ruleDao).update(eq(session), ruleCaptor.capture()); verifyNoMoreInteractions(ruleDao); @@ -267,7 +267,7 @@ public class DebtModelBackupTest { @Test public void reset_model_when_no_default_value() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( new RuleDto().setRepositoryKey("squid").setRuleKey("NPE") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) .setDefaultRemediationGapMultiplier("2h") @@ -288,7 +288,7 @@ public class DebtModelBackupTest { underTest.reset(); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(ruleDao).update(eq(session), ruleCaptor.capture()); verifyNoMoreInteractions(ruleDao); @@ -304,7 +304,7 @@ public class DebtModelBackupTest { @Test public void reset_model_on_custom_rules() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( // Template rule new RuleDto().setId(5).setRepositoryKey("squid").setRuleKey("XPath") .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) @@ -331,7 +331,7 @@ public class DebtModelBackupTest { underTest.reset(); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(ruleDao, times(2)).update(eq(session), ruleCaptor.capture()); verifyNoMoreInteractions(ruleDao); verify(session).commit(); @@ -353,11 +353,11 @@ public class DebtModelBackupTest { @Test public void reset_model_do_not_load_rule_definitions_if_no_rule() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(Collections.<RuleDto>emptyList()); + when(ruleDao.selectEnabled(session)).thenReturn(Collections.<RuleDto>emptyList()); underTest.reset(); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(ruleDao, never()).update(eq(session), any(RuleDto.class)); verifyZeroInteractions(defLoader); @@ -371,7 +371,7 @@ public class DebtModelBackupTest { .setRuleKey(RuleKey.of("squid", "UselessImportCheck")) .setFunction(DebtRemediationFunction.Type.LINEAR.name()).setCoefficient("2h"))); - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") .setDefaultRemediationFunction("LINEAR").setDefaultRemediationGapMultiplier("2h") )); @@ -380,14 +380,14 @@ public class DebtModelBackupTest { verify(ruleOperations).updateRule(ruleCaptor.capture(), eq("LINEAR"), eq("2h"), isNull(String.class), eq(session)); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(session).commit(); verify(ruleIndexer).index(); } @Test public void restore_from_xml_disable_rule_debt_when_not_in_xml_and_rule_have_default_debt_values() { - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") .setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationGapMultiplier("2h").setDefaultRemediationBaseEffort("15min") )); @@ -396,7 +396,7 @@ public class DebtModelBackupTest { verify(ruleOperations).updateRule(ruleCaptor.capture(), isNull(String.class), isNull(String.class), isNull(String.class), eq(session)); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(session).commit(); verify(ruleIndexer).index(); } @@ -406,7 +406,7 @@ public class DebtModelBackupTest { when(rulesXMLImporter.importXML(anyString(), any(ValidationMessages.class))).thenReturn(newArrayList(new RuleDebt() .setRuleKey(RuleKey.of("squid", "UselessImportCheck")).setFunction(DebtRemediationFunction.Type.LINEAR.name()).setCoefficient("2h"))); - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java") .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) .setDefaultRemediationGapMultiplier("2h"), @@ -420,7 +420,7 @@ public class DebtModelBackupTest { verify(ruleOperations).updateRule(ruleCaptor.capture(), eq("LINEAR"), eq("2h"), isNull(String.class), eq(session)); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(session).commit(); verify(ruleIndexer).index(); } @@ -428,7 +428,7 @@ public class DebtModelBackupTest { @Test public void restore_from_xml_and_language_with_rule_not_in_xml() { when(rulesXMLImporter.importXML(anyString(), any(ValidationMessages.class))).thenReturn(Collections.<RuleDebt>emptyList()); - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( // Rule does not exits in XML -> debt will be disabled new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java") .setDefaultRemediationFunction("LINEAR").setDefaultRemediationGapMultiplier("2h") @@ -441,7 +441,7 @@ public class DebtModelBackupTest { verify(ruleOperations).updateRule(ruleCaptor.capture(), isNull(String.class), isNull(String.class), isNull(String.class), eq(session)); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(session).commit(); verify(ruleIndexer).index(); } @@ -451,13 +451,13 @@ public class DebtModelBackupTest { when(rulesXMLImporter.importXML(anyString(), any(ValidationMessages.class))).thenReturn(newArrayList(new RuleDebt() .setRuleKey(RuleKey.of("squid", "UselessImportCheck")).setFunction(DebtRemediationFunction.Type.LINEAR.name()).setCoefficient("2h"))); - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(Collections.<RuleDto>emptyList()); + when(ruleDao.selectEnabled(session)).thenReturn(Collections.<RuleDto>emptyList()); assertThat(underTest.restoreFromXml("<xml/>").getWarnings()).hasSize(1); verifyZeroInteractions(ruleOperations); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(session).commit(); verify(ruleIndexer).index(); } @@ -467,7 +467,7 @@ public class DebtModelBackupTest { when(rulesXMLImporter.importXML(anyString(), any(ValidationMessages.class))).thenReturn(newArrayList(new RuleDebt() .setRuleKey(RuleKey.of("squid", "UselessImportCheck")).setFunction(DebtRemediationFunction.Type.LINEAR.name()).setCoefficient("2h"))); - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( + when(ruleDao.selectEnabled(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") .setDefaultRemediationFunction("LINEAR").setDefaultRemediationGapMultiplier("2h") )); @@ -476,7 +476,7 @@ public class DebtModelBackupTest { assertThat(underTest.restoreFromXml("<xml/>").getErrors()).hasSize(1); - verify(ruleDao).selectEnabledAndNonManual(session); + verify(ruleDao).selectEnabled(session); verify(session, never()).commit(); verify(ruleIndexer, never()).index(); } |