Search in sources :

Example 1 with RuleTesting

use of org.sonar.db.rule.RuleTesting in project sonarqube by SonarSource.

the class CachingRuleFinderTest method constructor_reads_parameters_from_DB.

@Test
public void constructor_reads_parameters_from_DB() {
    DbClient dbClient = mock(DbClient.class);
    DbSession dbSession = mock(DbSession.class);
    RuleDao ruleDao = mock(RuleDao.class);
    when(dbClient.openSession(anyBoolean())).thenReturn(dbSession);
    when(dbClient.ruleDao()).thenReturn(ruleDao);
    List<RuleKey> ruleKeys = Arrays.asList(RuleKey.of("A", "B"), RuleKey.of("C", "D"), RuleKey.of("E", "F"));
    when(ruleDao.selectAllDefinitions(dbSession)).thenReturn(ruleKeys.stream().map(RuleTesting::newRule).collect(toList()));
    new CachingRuleFinder(dbClient);
    verify(ruleDao).selectAllRuleParams(dbSession);
}
Also used : RuleDao(org.sonar.db.rule.RuleDao) DbSession(org.sonar.db.DbSession) DbClient(org.sonar.db.DbClient) RuleTesting(org.sonar.db.rule.RuleTesting) RuleKey(org.sonar.api.rule.RuleKey) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 RuleKey (org.sonar.api.rule.RuleKey)1 DbClient (org.sonar.db.DbClient)1 DbSession (org.sonar.db.DbSession)1 RuleDao (org.sonar.db.rule.RuleDao)1 RuleTesting (org.sonar.db.rule.RuleTesting)1