use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class PurgeDatastoresStepTest method call_purge_method_of_the_purge_task_for_project.
@Test
public void call_purge_method_of_the_purge_task_for_project() {
Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).build();
verify_call_purge_method_of_the_purge_task(project);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class EffortAggregator method beforeComponent.
@Override
public void beforeComponent(Component component) {
effortCounter = new EffortCounter();
effortsByComponentUuid.put(component.getUuid(), effortCounter);
// aggregate children counters
for (Component child : component.getChildren()) {
// no need to keep the children in memory. They can be garbage-collected.
EffortCounter childEffortCounter = effortsByComponentUuid.remove(child.getUuid());
if (childEffortCounter != null) {
effortCounter.add(childEffortCounter);
}
}
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class FileMoveDetectionStepTest method execute_detects_no_move_if_two_files_are_empty_in_DB.
@Test
public void execute_detects_no_move_if_two_files_are_empty_in_DB() {
analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
Component file1 = fileComponent(FILE_1_REF, null);
Component file2 = fileComponent(FILE_2_REF, null);
insertFiles(file1.getUuid(), file2.getUuid());
insertContentOfFileInDb(file1.getUuid(), null);
insertContentOfFileInDb(file2.getUuid(), null);
setFilesInReport(file1, file2);
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
assertThat(movedFilesRepository.getComponentsWithOriginal()).isEmpty();
assertThat(scoreMatrixDumper.scoreMatrix).isNull();
assertThat(addedFileRepository.getComponents()).isEmpty();
verifyStatistics(context, 2, 2, 0, null);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class FileMoveDetectionStepTest method execute_detects_move_if_content_of_file_is_same_in_DB_and_report.
@Test
public void execute_detects_move_if_content_of_file_is_same_in_DB_and_report() {
analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
Component file1 = fileComponent(FILE_1_REF, null);
Component file2 = fileComponent(FILE_2_REF, CONTENT1);
ComponentDto[] dtos = insertFiles(file1.getUuid());
insertContentOfFileInDb(file1.getUuid(), CONTENT1);
setFilesInReport(file2);
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
assertThat(movedFilesRepository.getComponentsWithOriginal()).containsExactly(file2);
MovedFilesRepository.OriginalFile originalFile = movedFilesRepository.getOriginalFile(file2).get();
assertThat(originalFile.getKey()).isEqualTo(dtos[0].getDbKey());
assertThat(originalFile.getUuid()).isEqualTo(dtos[0].uuid());
assertThat(addedFileRepository.getComponents()).isEmpty();
verifyStatistics(context, 1, 1, 1, 1);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class FileMoveDetectionStepTest method execute_does_not_compute_any_distance_if_all_files_sizes_are_all_too_different.
@Test
public void execute_does_not_compute_any_distance_if_all_files_sizes_are_all_too_different() {
analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
Component file1 = fileComponent(FILE_1_REF, null);
Component file2 = fileComponent(FILE_2_REF, null);
Component file3 = fileComponent(FILE_3_REF, arrayOf(118));
Component file4 = fileComponent(5, arrayOf(25));
insertFiles(file1.getDbKey(), file2.getDbKey());
insertContentOfFileInDb(file1.getDbKey(), arrayOf(100));
insertContentOfFileInDb(file2.getDbKey(), arrayOf(30));
setFilesInReport(file3, file4);
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
assertThat(movedFilesRepository.getComponentsWithOriginal()).isEmpty();
assertThat(scoreMatrixDumper.scoreMatrix.getMaxScore()).isZero();
verifyStatistics(context, 2, 2, 2, 0);
}
Aggregations