use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method sum_new_reliability_effort_of_issues.
@Test
public void sum_new_reliability_effort_of_issues() {
periodsHolder.setPeriod(PERIOD);
DefaultIssue unresolved1 = newBugIssue(10L);
DefaultIssue unresolved2 = newBugIssue(30L);
DefaultIssue unresolvedWithoutDebt = newBugIssueWithoutEffort();
DefaultIssue resolved = newBugIssue(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_RELIABILITY_REMEDIATION_EFFORT_KEY, 3 + 4);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method aggregate_new_characteristic_measures_of_children.
@Test
public void aggregate_new_characteristic_measures_of_children() {
periodsHolder.setPeriod(PERIOD);
DefaultIssue codeSmellIssue = newCodeSmellIssue(10);
when(calculator.calculate(same(codeSmellIssue), anyList(), same(PERIOD))).thenReturn(4L);
DefaultIssue bugIssue = newBugIssue(8);
when(calculator.calculate(same(bugIssue), anyList(), same(PERIOD))).thenReturn(3L);
DefaultIssue vulnerabilityIssue = newVulnerabilityIssue(12);
when(calculator.calculate(same(vulnerabilityIssue), anyList(), same(PERIOD))).thenReturn(6L);
DefaultIssue codeSmellProjectIssue = newCodeSmellIssue(30);
when(calculator.calculate(same(codeSmellProjectIssue), anyList(), same(PERIOD))).thenReturn(1L);
DefaultIssue bugProjectIssue = newBugIssue(28);
when(calculator.calculate(same(bugProjectIssue), anyList(), same(PERIOD))).thenReturn(2L);
DefaultIssue vulnerabilityProjectIssue = newVulnerabilityIssue(32);
when(calculator.calculate(same(vulnerabilityProjectIssue), anyList(), same(PERIOD))).thenReturn(4L);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, codeSmellIssue);
underTest.onIssue(FILE, bugIssue);
underTest.onIssue(FILE, vulnerabilityIssue);
underTest.afterComponent(FILE);
underTest.beforeComponent(PROJECT);
underTest.onIssue(PROJECT, codeSmellProjectIssue);
underTest.onIssue(PROJECT, bugProjectIssue);
underTest.onIssue(PROJECT, vulnerabilityProjectIssue);
underTest.afterComponent(PROJECT);
assertVariation(PROJECT, NEW_TECHNICAL_DEBT_KEY, 4 + 1);
assertVariation(PROJECT, NEW_RELIABILITY_REMEDIATION_EFFORT_KEY, 3 + 2);
assertVariation(PROJECT, NEW_SECURITY_REMEDIATION_EFFORT_KEY, 6 + 4);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method new_security_effort_is_only_computed_using_vulnerability_issues.
@Test
public void new_security_effort_is_only_computed_using_vulnerability_issues() {
periodsHolder.setPeriod(PERIOD);
DefaultIssue vulnerabilityIssue = newVulnerabilityIssue(12);
// Issues of type CODE SMELL and BUG should be ignored
DefaultIssue codeSmellIssue = newCodeSmellIssue(10);
DefaultIssue bugIssue = newBugIssue(15);
when(calculator.calculate(same(vulnerabilityIssue), anyList(), same(PERIOD))).thenReturn(5L);
when(calculator.calculate(same(codeSmellIssue), anyList(), same(PERIOD))).thenReturn(4L);
when(calculator.calculate(same(bugIssue), anyList(), same(PERIOD))).thenReturn(3L);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, codeSmellIssue);
underTest.onIssue(FILE, bugIssue);
underTest.onIssue(FILE, vulnerabilityIssue);
underTest.afterComponent(FILE);
// Only effort of VULNERABILITY issue is used
assertVariation(FILE, NEW_SECURITY_REMEDIATION_EFFORT_KEY, 5);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method new_maintainability_effort_is_only_computed_using_code_smell_issues.
@Test
public void new_maintainability_effort_is_only_computed_using_code_smell_issues() {
periodsHolder.setPeriod(PERIOD);
DefaultIssue codeSmellIssue = newCodeSmellIssue(10);
// Issues of type BUG and VULNERABILITY should be ignored
DefaultIssue bugIssue = newBugIssue(15);
DefaultIssue vulnerabilityIssue = newVulnerabilityIssue(12);
when(calculator.calculate(same(codeSmellIssue), anyList(), same(PERIOD))).thenReturn(4L);
when(calculator.calculate(same(bugIssue), anyList(), same(PERIOD))).thenReturn(3L);
when(calculator.calculate(same(vulnerabilityIssue), anyList(), same(PERIOD))).thenReturn(5L);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, codeSmellIssue);
underTest.onIssue(FILE, bugIssue);
underTest.onIssue(FILE, vulnerabilityIssue);
underTest.afterComponent(FILE);
// Only effort of CODE SMELL issue is used
assertVariation(FILE, NEW_TECHNICAL_DEBT_KEY, 4);
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class IssueAssignerTest method set_assignee_to_issue.
@Test
public void set_assignee_to_issue() throws Exception {
addScmUser("john", "John C");
setSingleChangeset("john", 123456789L, "rev-1");
DefaultIssue issue = new DefaultIssue().setLine(1);
underTest.onIssue(FILE, issue);
assertThat(issue.assignee()).isEqualTo("John C");
}
Aggregations