use of org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRule in project sonarqube by SonarSource.
the class LoadQualityProfilesStepTest method feed_active_rules.
@Test
public void feed_active_rules() {
ruleRepository.add(XOO_X1).setPluginKey("xoo");
ruleRepository.add(XOO_X2).setPluginKey("xoo");
ScannerReport.ActiveRule.Builder batch1 = ScannerReport.ActiveRule.newBuilder().setRuleRepository(XOO_X1.repository()).setRuleKey(XOO_X1.rule()).setSeverity(Constants.Severity.BLOCKER).setCreatedAt(1000L).setUpdatedAt(1200L);
batch1.getMutableParamsByKey().put("p1", "v1");
ScannerReport.ActiveRule.Builder batch2 = ScannerReport.ActiveRule.newBuilder().setRuleRepository(XOO_X2.repository()).setRuleKey(XOO_X2.rule()).setSeverity(Constants.Severity.MAJOR);
batchReportReader.putActiveRules(asList(batch1.build(), batch2.build()));
underTest.execute(new TestComputationStepContext());
assertThat(activeRulesHolder.getAll()).hasSize(2);
ActiveRule ar1 = activeRulesHolder.get(XOO_X1).get();
assertThat(ar1.getSeverity()).isEqualTo(Severity.BLOCKER);
assertThat(ar1.getParams()).containsExactly(MapEntry.entry("p1", "v1"));
assertThat(ar1.getPluginKey()).isEqualTo("xoo");
assertThat(ar1.getUpdatedAt()).isEqualTo(1200L);
ActiveRule ar2 = activeRulesHolder.get(XOO_X2).get();
assertThat(ar2.getSeverity()).isEqualTo(Severity.MAJOR);
assertThat(ar2.getParams()).isEmpty();
assertThat(ar2.getPluginKey()).isEqualTo("xoo");
assertThat(ar1.getUpdatedAt()).isEqualTo(1200L);
}
Aggregations