@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")
@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"),
@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
@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"),
@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")
underTest.reset();
- verify(ruleDao).selectEnabledAndNonManual(session);
+ verify(ruleDao).selectEnabled(session);
verify(ruleDao).update(eq(session), ruleCaptor.capture());
verifyNoMoreInteractions(ruleDao);
@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")
underTest.reset();
- verify(ruleDao).selectEnabledAndNonManual(session);
+ verify(ruleDao).selectEnabled(session);
verify(ruleDao).update(eq(session), ruleCaptor.capture());
verifyNoMoreInteractions(ruleDao);
@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())
underTest.reset();
- verify(ruleDao).selectEnabledAndNonManual(session);
+ verify(ruleDao).selectEnabled(session);
verify(ruleDao, times(2)).update(eq(session), ruleCaptor.capture());
verifyNoMoreInteractions(ruleDao);
verify(session).commit();
@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);
.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")
));
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")
));
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();
}
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"),
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_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")
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();
}
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();
}
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")
));
assertThat(underTest.restoreFromXml("<xml/>").getErrors()).hasSize(1);
- verify(ruleDao).selectEnabledAndNonManual(session);
+ verify(ruleDao).selectEnabled(session);
verify(session, never()).commit();
verify(ruleIndexer, never()).index();
}
}
@Test
- public void selectEnabledAndNonManual() {
- dbTester.prepareDbUnit(getClass(), "selectEnabledAndNonManual.xml");
- List<RuleDto> ruleDtos = underTest.selectEnabledAndNonManual(dbTester.getSession());
+ public void selectEnabled() {
+ dbTester.prepareDbUnit(getClass(), "selectEnabled.xml");
+ List<RuleDto> ruleDtos = underTest.selectEnabled(dbTester.getSession());
assertThat(ruleDtos.size()).isEqualTo(1);
RuleDto ruleDto = ruleDtos.get(0);
}
@Test
- public void selectEnabledAndNonManual_with_ResultHandler() {
- dbTester.prepareDbUnit(getClass(), "selectEnabledAndNonManual.xml");
+ public void selectEnabled_with_ResultHandler() {
+ dbTester.prepareDbUnit(getClass(), "selectEnabled.xml");
final List<RuleDto> rules = new ArrayList<>();
ResultHandler resultHandler = new ResultHandler() {
rules.add((RuleDto) resultContext.getResultObject());
}
};
- underTest.selectEnabledAndNonManual(dbTester.getSession(), resultHandler);
+ underTest.selectEnabled(dbTester.getSession(), resultHandler);
assertThat(rules.size()).isEqualTo(1);
RuleDto ruleDto = rules.get(0);
assertThat(ruleDto.getId()).isEqualTo(1);
}
- @Test
- public void select_non_manual() {
- dbTester.prepareDbUnit(getClass(), "selectNonManual.xml");
-
- List<RuleDto> ruleDtos = underTest.selectByNonManual(dbTester.getSession());
-
- assertThat(ruleDtos.size()).isEqualTo(1);
- RuleDto ruleDto = ruleDtos.get(0);
- assertThat(ruleDto.getId()).isEqualTo(1);
- assertThat(ruleDto.getName()).isEqualTo("Avoid Null");
- assertThat(ruleDto.getDescription()).isEqualTo("Should avoid NULL");
- assertThat(ruleDto.getStatus()).isEqualTo(RuleStatus.READY);
- assertThat(ruleDto.getRepositoryKey()).isEqualTo("checkstyle");
- }
-
-
@Test
public void select_by_query() {
dbTester.prepareDbUnit(getClass(), "shared.xml");