use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class MovedIssueVisitorTest method onIssue_update_component_and_module_fields_to_component_and_flag_issue_has_changed.
@Test
public void onIssue_update_component_and_module_fields_to_component_and_flag_issue_has_changed() {
MovedFilesRepository.OriginalFile originalFile = new MovedFilesRepository.OriginalFile(6451, "original uuid", "original key");
DefaultIssue issue = mockIssue(originalFile.getUuid());
when(movedFilesRepository.getOriginalFile(FILE)).thenReturn(Optional.of(originalFile));
underTest.onIssue(FILE, issue);
verify(issue).setComponentUuid(FILE.getUuid());
verify(issue).setComponentKey(FILE.getKey());
verify(issue).setModuleUuid(null);
verify(issue).setModuleUuidPath(null);
verify(issue).setChanged(true);
ArgumentCaptor<IssueChangeContext> issueChangeContextCaptor = ArgumentCaptor.forClass(IssueChangeContext.class);
verify(issue).setFieldChange(issueChangeContextCaptor.capture(), eq("file"), eq(originalFile.getUuid()), eq(FILE.getUuid()));
assertThat(issueChangeContextCaptor.getValue().date()).isEqualTo(new Date(ANALYSIS_DATE));
assertThat(issueChangeContextCaptor.getValue().login()).isNull();
assertThat(issueChangeContextCaptor.getValue().scan()).isFalse();
}
use of org.sonar.core.issue.DefaultIssue in project sonarqube by SonarSource.
the class MovedIssueVisitorTest method mockIssue.
private DefaultIssue mockIssue(String fileUuid) {
DefaultIssue issue = mock(DefaultIssue.class);
when(issue.componentUuid()).thenReturn(fileUuid);
return issue;
}
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);
}
Aggregations