use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class SumFormulaExecutionTest method not_add_measures_when_no_data_on_file.
@Test
public void not_add_measures_when_no_data_on_file() {
ReportComponent project = builder(PROJECT, 1).addChildren(builder(MODULE, 11).addChildren(builder(DIRECTORY, 111).addChildren(builder(Component.Type.FILE, 1111).build()).build()).build()).build();
treeRootHolder.setRoot(project);
new PathAwareCrawler<>(underTest).visit(project);
assertThat(measureRepository.getAddedRawMeasures(1)).isEmpty();
assertThat(measureRepository.getAddedRawMeasures(11)).isEmpty();
assertThat(measureRepository.getAddedRawMeasures(111)).isEmpty();
assertThat(measureRepository.getAddedRawMeasures(1111)).isEmpty();
}
use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class AverageFormulaExecutionTest 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, COMPLEXITY_IN_FUNCTIONS_KEY, newMeasureBuilder().create(5));
measureRepository.addRawMeasure(1111, FUNCTIONS_KEY, newMeasureBuilder().create(2));
measureRepository.addRawMeasure(1112, COMPLEXITY_IN_FUNCTIONS_KEY, newMeasureBuilder().create(1));
measureRepository.addRawMeasure(1112, FUNCTIONS_KEY, newMeasureBuilder().create(1));
measureRepository.addRawMeasure(1211, COMPLEXITY_IN_FUNCTIONS_KEY, newMeasureBuilder().create(9));
measureRepository.addRawMeasure(1211, FUNCTIONS_KEY, newMeasureBuilder().create(2));
new PathAwareCrawler<>(underTest).visit(project);
assertThat(toEntries(measureRepository.getAddedRawMeasures(1))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(3d, 1)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(11))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(2d, 1)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(111))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(2d, 1)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(1111))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(2.5d, 1)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(1112))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(1d, 1)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(12))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(4.5d, 1)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(121))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(4.5d, 1)));
assertThat(toEntries(measureRepository.getAddedRawMeasures(1211))).containsOnly(entryOf(FUNCTION_COMPLEXITY_KEY, newMeasureBuilder().create(4.5d, 1)));
}
use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class ReportFormulaExecutorComponentVisitorTest method add_measure_even_when_leaf_is_not_FILE.
@Test
public void add_measure_even_when_leaf_is_not_FILE() throws Exception {
ReportComponent project = ReportComponent.builder(PROJECT, ROOT_REF).addChildren(ReportComponent.builder(MODULE, MODULE_1_REF).addChildren(ReportComponent.builder(DIRECTORY, 111).build()).build()).build();
treeRootHolder.setRoot(project);
new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula())).visit(project);
assertAddedRawMeasure(MODULE_1_REF, 0);
assertAddedRawMeasure(DIRECTORY_1_REF, 0);
}
use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class CommonRuleEngineImplTest method do_not_process_files_with_unknown_language.
@Test
public void do_not_process_files_with_unknown_language() throws Exception {
ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setKey("FILE_KEY").setUuid("FILE_UUID").setFileAttributes(new FileAttributes(false, null, 1)).build();
Collection<DefaultIssue> issues = underTest.process(file);
assertThat(issues).isEmpty();
verifyZeroInteractions(rule1, rule2);
}
use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class LastCommitVisitorTest method compute_date_of_file_from_scm_repo.
@Test
public void compute_date_of_file_from_scm_repo() throws Exception {
VisitorsCrawler underTest = new VisitorsCrawler(Lists.<ComponentVisitor>newArrayList(new LastCommitVisitor(metricRepository, measureRepository, scmInfoRepository)));
scmInfoRepository.setScmInfo(FILE_1_REF, Changeset.newChangesetBuilder().setAuthor("john").setDate(1_500_000_000_000L).setRevision("rev-1").build(), Changeset.newChangesetBuilder().setAuthor("tom").setDate(1_600_000_000_000L).setRevision("rev-2").build(), Changeset.newChangesetBuilder().setAuthor("john").setDate(1_500_000_000_000L).setRevision("rev-1").build());
ReportComponent file = createFileComponent(FILE_1_REF);
treeRootHolder.setRoot(file);
underTest.visit(file);
assertDate(FILE_1_REF, 1_600_000_000_000L);
}
Aggregations