use of org.sonar.scanner.rule.LoadedActiveRule in project sonarqube by SonarSource.
the class ActiveRulesProviderTest method testCombinationOfRules.
@Test
public void testCombinationOfRules() {
LoadedActiveRule r1 = mockRule("rule1");
LoadedActiveRule r2 = mockRule("rule2");
LoadedActiveRule r3 = mockRule("rule3");
List<LoadedActiveRule> qp1Rules = ImmutableList.of(r1, r2);
List<LoadedActiveRule> qp2Rules = ImmutableList.of(r2, r3);
List<LoadedActiveRule> qp3Rules = ImmutableList.of(r1, r3);
when(loader.load(eq("qp1"))).thenReturn(qp1Rules);
when(loader.load(eq("qp2"))).thenReturn(qp2Rules);
when(loader.load(eq("qp3"))).thenReturn(qp3Rules);
ModuleQProfiles profiles = mockProfiles("qp1", "qp2", "qp3");
ActiveRules activeRules = provider.provide(loader, profiles);
assertThat(activeRules.findAll()).hasSize(3);
assertThat(activeRules.findAll()).extracting("ruleKey").containsOnly(RuleKey.of("rule1", "rule1"), RuleKey.of("rule2", "rule2"), RuleKey.of("rule3", "rule3"));
verify(loader).load(eq("qp1"));
verify(loader).load(eq("qp2"));
verify(loader).load(eq("qp3"));
verifyNoMoreInteractions(loader);
}
use of org.sonar.scanner.rule.LoadedActiveRule in project sonarqube by SonarSource.
the class ActiveRulesProviderTest method mockRule.
private static LoadedActiveRule mockRule(String name) {
LoadedActiveRule r = new LoadedActiveRule();
r.setName(name);
r.setRuleKey(RuleKey.of(name, name));
return r;
}
use of org.sonar.scanner.rule.LoadedActiveRule in project sonarqube by SonarSource.
the class ChecksMediumTest method createActiveRuleWithParam.
private LoadedActiveRule createActiveRuleWithParam(String repositoryKey, String ruleKey, @Nullable String templateRuleKey, String name, @Nullable String severity, @Nullable String internalKey, @Nullable String languag, String paramKey, String paramValue) {
LoadedActiveRule r = new LoadedActiveRule();
r.setInternalKey(internalKey);
r.setRuleKey(RuleKey.of(repositoryKey, ruleKey));
r.setName(name);
r.setTemplateRuleKey(templateRuleKey);
r.setLanguage(languag);
r.setSeverity(severity);
Map<String, String> params = new HashMap<>();
params.put(paramKey, paramValue);
r.setParams(params);
return r;
}
Aggregations