use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class TestErrorRuleTest method issue_if_errors_or_failures.
@Test
public void issue_if_errors_or_failures() throws Exception {
activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap(), 1_000L));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.TEST_ERRORS_KEY, Measure.newMeasureBuilder().create(2));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.TEST_FAILURES_KEY, Measure.newMeasureBuilder().create(1));
DefaultIssue issue = underTest.processFile(FILE, "java");
assertThat(issue.ruleKey()).isEqualTo(RULE_KEY);
assertThat(issue.severity()).isEqualTo(Severity.CRITICAL);
assertThat(issue.effortToFix()).isEqualTo(3.0);
assertThat(issue.message()).isEqualTo("Fix failing unit tests on file \"FooTest.java\".");
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class TestErrorRuleTest method no_issues_if_zero_errors_and_failures.
@Test
public void no_issues_if_zero_errors_and_failures() throws Exception {
activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, Collections.<String, String>emptyMap(), 1_000L));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.TEST_ERRORS_KEY, Measure.newMeasureBuilder().create(0));
measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.TEST_FAILURES_KEY, Measure.newMeasureBuilder().create(0));
DefaultIssue issue = underTest.processFile(FILE, "java");
assertThat(issue).isNull();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class CommonRuleEngineImplTest method do_not_process_files_with_unknown_language.
@Test
public void do_not_process_files_with_unknown_language() throws Exception {
ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setKey("FILE_KEY").setUuid("FILE_UUID").setFileAttributes(new FileAttributes(false, null, 1)).build();
Collection<DefaultIssue> issues = underTest.process(file);
assertThat(issues).isEmpty();
verifyZeroInteractions(rule1, rule2);
}
use of org.sonar.core.issue.DefaultIssue 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));
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.effortToFix()).isEqualTo(23.0);
assertThat(issue.message()).isEqualTo(getExpectedIssueMessage());
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class CoverageRuleTest method no_issue_if_coverage_is_not_set.
@Test
public void no_issue_if_coverage_is_not_set() {
activeRuleHolder.put(new ActiveRule(getRuleKey(), Severity.CRITICAL, ImmutableMap.of(getMinPropertyKey(), "65"), 1_000L));
DefaultIssue issue = underTest.processFile(FILE, "java");
assertThat(issue).isNull();
}
Aggregations