use of org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRule in project sonarqube by SonarSource.
the class CommonRuleTest method getMinDensityParam_fails_if_param_value_is_negative.
@Test
public void getMinDensityParam_fails_if_param_value_is_negative() {
assertThatThrownBy(() -> {
ActiveRule activeRule = new ActiveRule(RuleTesting.XOO_X1, Severity.MAJOR, ImmutableMap.of("minDensity", "-30.5"), 1_000L, PLUGIN_KEY, QP_KEY);
CommonRule.getMinDensityParam(activeRule, "minDensity");
}).isInstanceOf(IllegalStateException.class).hasMessage("Minimum density of rule [xoo:x1] is incorrect. Got [-30.5] but must be between 0 and 100.");
}
use of org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRule in project sonarqube by SonarSource.
the class CommonRuleTest method getMinDensityParam_fails_if_param_value_is_greater_than_100.
@Test
public void getMinDensityParam_fails_if_param_value_is_greater_than_100() {
assertThatThrownBy(() -> {
ActiveRule activeRule = new ActiveRule(RuleTesting.XOO_X1, Severity.MAJOR, ImmutableMap.of("minDensity", "305"), 1_000L, PLUGIN_KEY, QP_KEY);
CommonRule.getMinDensityParam(activeRule, "minDensity");
}).isInstanceOf(IllegalStateException.class).hasMessage("Minimum density of rule [xoo:x1] is incorrect. Got [305] but must be between 0 and 100.");
}
use of org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRule in project sonarqube by SonarSource.
the class CommonRuleTest method test_getMinDensityParam.
@Test
public void test_getMinDensityParam() {
ActiveRule activeRule = new ActiveRule(RuleTesting.XOO_X1, Severity.MAJOR, ImmutableMap.of("minDensity", "30.5"), 1_000L, PLUGIN_KEY, QP_KEY);
double minDensity = CommonRule.getMinDensityParam(activeRule, "minDensity");
assertThat(minDensity).isEqualTo(30.5);
}
use of org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRule in project sonarqube by SonarSource.
the class SkippedTestRuleTest method no_issues_if_measure_is_absent.
@Test
public void no_issues_if_measure_is_absent() {
activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.emptyMap(), 1_000L, PLUGIN_KEY, QP_KEY));
DefaultIssue issue = underTest.processFile(FILE, "java");
assertThat(issue).isNull();
}
use of org.sonar.ce.task.projectanalysis.qualityprofile.ActiveRule in project sonarqube by SonarSource.
the class CoverageRuleTest method issue_if_coverage_is_too_low.
@Test
public void issue_if_coverage_is_too_low() {
activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL, ImmutableMap.of(getMinPropertyKey(), "65"), 1_000L, PLUGIN_KEY, QP_KEY));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), getCoverageMetricKey(), Measure.newMeasureBuilder().create(20.0, 1));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), getUncoveredMetricKey(), Measure.newMeasureBuilder().create(40));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), getToCoverMetricKey(), Measure.newMeasureBuilder().create(50));
DefaultIssue issue = underTest.processFile(FILE, "java");
assertThat(issue.ruleKey()).isEqualTo(getRuleKey());
assertThat(issue.severity()).isEqualTo(Severity.CRITICAL);
// FIXME explain
assertThat(issue.gap()).isEqualTo(23.0);
assertThat(issue.message()).isEqualTo(getExpectedIssueMessage());
}
Aggregations