use of org.sonar.server.computation.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(MODULE, 11).addChildren(builder(DIRECTORY, 111).addChildren(builder(Component.Type.FILE, 1111).build(), builder(Component.Type.FILE, 1112).build()).build()).build(), builder(MODULE, 12).addChildren(builder(DIRECTORY, 121).addChildren(builder(Component.Type.FILE, 1211).build()).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(11))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(18)));
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(12))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(2)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(121))).containsOnly(entryOf(LINES_KEY, newMeasureBuilder().create(2)));
assertThat(measureRepository.getAddedRawMeasures(1211)).isEmpty();
}
use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class CommonRuleEngineImplTest method process_files_with_known_language.
@Test
public void process_files_with_known_language() throws Exception {
ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setKey("FILE_KEY").setUuid("FILE_UUID").setFileAttributes(new FileAttributes(false, "java", 1)).build();
DefaultIssue issue = new DefaultIssue();
when(rule1.processFile(file, "java")).thenReturn(issue);
when(rule2.processFile(file, "java")).thenReturn(null);
Collection<DefaultIssue> issues = underTest.process(file);
assertThat(issues).containsOnly(issue);
}
use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class NewReliabilityAndSecurityRatingMeasuresVisitorTest method measures_created_for_project_are_all_A_when_they_have_no_FILE_child.
@Test
public void measures_created_for_project_are_all_A_when_they_have_no_FILE_child() {
ReportComponent root = builder(PROJECT, 1).build();
treeRootHolder.setRoot(root);
underTest.visit(root);
verifyAddedRawMeasureOnLeakPeriod(1, NEW_SECURITY_RATING_KEY, A);
verifyAddedRawMeasureOnLeakPeriod(1, NEW_RELIABILITY_RATING_KEY, A);
}
use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class ComputeQProfileMeasureStepTest method nothing_to_add_when_no_files.
@Test
public void nothing_to_add_when_no_files() throws Exception {
ReportComponent project = ReportComponent.builder(PROJECT, PROJECT_REF).build();
treeRootHolder.setRoot(project);
underTest.execute();
assertThat(measureRepository.getAddedRawMeasures(PROJECT_REF)).isEmpty();
}
use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class QualityGateLoadingStepTest method execute_sets_default_QualityGate_when_project_has_no_settings.
@Test
public void execute_sets_default_QualityGate_when_project_has_no_settings() {
ReportComponent root = ReportComponent.builder(Component.Type.PROJECT, 1).setKey(PROJECT_KEY).addChildren(ReportComponent.builder(Component.Type.FILE, 2).build()).build();
treeRootHolder.setRoot(root);
when(settingsRepository.getSettings(root)).thenReturn(new MapSettings());
underTest.execute();
verifyNoQualityGate();
// verify only project is processed
verify(settingsRepository).getSettings(root);
verifyNoMoreInteractions(settingsRepository);
}
Aggregations