use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class ClosedIssuesInputFactoryTest method underTest_returns_inputFactory_loading_closed_issues_from_moved_component_when_present.
@Test
public void underTest_returns_inputFactory_loading_closed_issues_from_moved_component_when_present() {
String componentUuid = randomAlphanumeric(12);
String originalComponentUuid = randomAlphanumeric(12);
ReportComponent component = ReportComponent.builder(Component.Type.FILE, 1).setUuid(componentUuid).build();
when(movedFilesRepository.getOriginalFile(component)).thenReturn(Optional.of(new MovedFilesRepository.OriginalFile(originalComponentUuid, randomAlphanumeric(2))));
Input<DefaultIssue> input = underTest.create(component);
verifyZeroInteractions(dbClient, issuesLoader);
List<DefaultIssue> issues = ImmutableList.of();
when(issuesLoader.loadClosedIssues(originalComponentUuid)).thenReturn(issues);
assertThat(input.getIssues()).isSameAs(issues);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class ClosedIssuesInputFactoryTest method underTest_returns_inputFactory_which_caches_loaded_issues.
@Test
public void underTest_returns_inputFactory_which_caches_loaded_issues() {
String componentUuid = randomAlphanumeric(12);
ReportComponent component = ReportComponent.builder(Component.Type.FILE, 1).setUuid(componentUuid).build();
when(movedFilesRepository.getOriginalFile(component)).thenReturn(Optional.empty());
Input<DefaultIssue> input = underTest.create(component);
verifyZeroInteractions(dbClient, issuesLoader);
List<DefaultIssue> issues = ImmutableList.of(new DefaultIssue());
when(issuesLoader.loadClosedIssues(componentUuid)).thenReturn(issues);
assertThat(input.getIssues()).isSameAs(issues);
reset(issuesLoader);
assertThat(input.getIssues()).isSameAs(issues);
verifyZeroInteractions(issuesLoader);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class SumFormulaExecutionTest method add_measures.
@Test
public void add_measures() {
ReportComponent project = builder(PROJECT, 1).addChildren(builder(DIRECTORY, 111).addChildren(builder(Component.Type.FILE, 1111).build(), builder(Component.Type.FILE, 1112).build()).build(), builder(DIRECTORY, 121).addChildren(builder(Component.Type.FILE, 1211).build()).build()).build();
treeRootHolder.setRoot(project);
measureRepository.addRawMeasure(1111, LINES_KEY, newMeasureBuilder().create(10));
measureRepository.addRawMeasure(1112, LINES_KEY, newMeasureBuilder().create(8));
measureRepository.addRawMeasure(1211, LINES_KEY, newMeasureBuilder().create(2));
new PathAwareCrawler<>(underTest).visit(project);
assertThat(toEntries(measureRepository.getAddedRawMeasures(1))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(20)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(111))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(18)));
assertThat(measureRepository.getAddedRawMeasures(1111)).isEmpty();
assertThat(measureRepository.getAddedRawMeasures(1112)).isEmpty();
assertThat(toEntries(measureRepository.getAddedRawMeasures(121))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(2)));
assertThat(measureRepository.getAddedRawMeasures(1211)).isEmpty();
}
Aggregations