Search in sources :

Example 31 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class CommentDensityRuleTest method no_issues_if_enough_comments.

@Test
public void no_issues_if_enough_comments() {
    activeRuleHolder.put(new ActiveRule(RULE_KEY, Severity.CRITICAL, ImmutableMap.of(CommonRuleKeys.INSUFFICIENT_COMMENT_DENSITY_PROPERTY, "25"), 1_000L));
    measureRepository.addRawMeasure(FILE.getReportAttributes().getRef(), CoreMetrics.COMMENT_LINES_DENSITY_KEY, Measure.newMeasureBuilder().create(90.0, 1));
    DefaultIssue issue = underTest.processFile(FILE, "java");
    assertThat(issue).isNull();
}
Also used : ActiveRule(org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule) DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 32 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class MovedIssueVisitorTest method onIssue_throws_ISE_if_issue_has_different_component_uuid_but_component_has_no_original_file.

@Test
public void onIssue_throws_ISE_if_issue_has_different_component_uuid_but_component_has_no_original_file() {
    DefaultIssue issue = mockIssue("other component uuid");
    when(issue.toString()).thenReturn("[bad issue, bad!]");
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("Issue [bad issue, bad!] for component ReportComponent{ref=1, key='key_1', type=FILE} " + "has a different component key but no original file exist in MovedFilesRepository");
    underTest.onIssue(FILE, issue);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 33 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class MovedIssueVisitorTest method onIssue_does_not_alter_issue_if_component_file_but_issue_has_the_same_component_uuid.

@Test
public void onIssue_does_not_alter_issue_if_component_file_but_issue_has_the_same_component_uuid() {
    DefaultIssue issue = mockIssue(FILE_UUID);
    underTest.onIssue(FILE, issue);
    verify(issue).componentUuid();
    verifyNoMoreInteractions(issue);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 34 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class NewEffortAggregatorTest method sum_new_securtiy_effort_of_issues.

@Test
public void sum_new_securtiy_effort_of_issues() {
    periodsHolder.setPeriod(PERIOD);
    DefaultIssue unresolved1 = newVulnerabilityIssue(10L);
    DefaultIssue unresolved2 = newVulnerabilityIssue(30L);
    DefaultIssue unresolvedWithoutDebt = newVulnerabilityIssueWithoutEffort();
    DefaultIssue resolved = newVulnerabilityIssue(50L).setResolution(RESOLUTION_FIXED);
    when(calculator.calculate(same(unresolved1), anyList(), same(PERIOD))).thenReturn(4L);
    when(calculator.calculate(same(unresolved2), anyList(), same(PERIOD))).thenReturn(3L);
    verifyNoMoreInteractions(calculator);
    underTest.beforeComponent(FILE);
    underTest.onIssue(FILE, unresolved1);
    underTest.onIssue(FILE, unresolved2);
    underTest.onIssue(FILE, unresolvedWithoutDebt);
    underTest.onIssue(FILE, resolved);
    underTest.afterComponent(FILE);
    assertVariation(FILE, NEW_SECURITY_REMEDIATION_EFFORT_KEY, 3 + 4);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Example 35 with DefaultIssue

use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.

the class NewEffortAggregatorTest method sum_new_maintainability_effort_of_issues.

@Test
public void sum_new_maintainability_effort_of_issues() {
    periodsHolder.setPeriod(PERIOD);
    DefaultIssue unresolved1 = newCodeSmellIssue(10L);
    DefaultIssue unresolved2 = newCodeSmellIssue(30L);
    DefaultIssue unresolvedWithoutDebt = newCodeSmellIssueWithoutEffort();
    DefaultIssue resolved = newCodeSmellIssue(50L).setResolution(RESOLUTION_FIXED);
    when(calculator.calculate(same(unresolved1), anyList(), same(PERIOD))).thenReturn(4L);
    when(calculator.calculate(same(unresolved2), anyList(), same(PERIOD))).thenReturn(3L);
    verifyNoMoreInteractions(calculator);
    underTest.beforeComponent(FILE);
    underTest.onIssue(FILE, unresolved1);
    underTest.onIssue(FILE, unresolved2);
    underTest.onIssue(FILE, unresolvedWithoutDebt);
    underTest.onIssue(FILE, resolved);
    underTest.afterComponent(FILE);
    assertVariation(FILE, NEW_TECHNICAL_DEBT_KEY, 3 + 4);
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Test(org.junit.Test)

Aggregations

DefaultIssue (org.sonar.core.issue.DefaultIssue)140 Test (org.junit.Test)120 Date (java.util.Date)27 ActiveRule (org.sonar.server.computation.task.projectanalysis.qualityprofile.ActiveRule)15 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)14 DefaultIssueComment (org.sonar.core.issue.DefaultIssueComment)8 IssueDto (org.sonar.db.issue.IssueDto)8 DbSession (org.sonar.db.DbSession)6 ComponentDto (org.sonar.db.component.ComponentDto)5 Issue (org.sonar.api.issue.Issue)4 FieldDiffs (org.sonar.core.issue.FieldDiffs)4 ArrayList (java.util.ArrayList)3 RuleKey (org.sonar.api.rule.RuleKey)3 User (org.sonar.api.user.User)3 IssueChangeMapper (org.sonar.db.issue.IssueChangeMapper)3 IssueMapper (org.sonar.db.issue.IssueMapper)3 RuleDto (org.sonar.db.rule.RuleDto)3 IssueChangeNotification (org.sonar.server.issue.notification.IssueChangeNotification)3 DefaultUser (org.sonar.core.user.DefaultUser)2 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)2