use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class AverageFormulaExecutionTest 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(DIRECTORY, 111).addChildren(builder(Component.Type.FILE, 1111).build()).build()).build();
treeRootHolder.setRoot(project);
new PathAwareCrawler<>(underTest).visit(project);
assertThat(measureRepository.getAddedRawMeasures(1)).isEmpty();
assertThat(measureRepository.getAddedRawMeasures(111)).isEmpty();
assertThat(measureRepository.getAddedRawMeasures(1111)).isEmpty();
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class DistributionFormulaExecutionTest 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(DIRECTORY, 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.ce.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() {
ReportComponent project = ReportComponent.builder(PROJECT, ROOT_REF).addChildren(ReportComponent.builder(DIRECTORY, 111).build()).build();
treeRootHolder.setRoot(project);
new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula())).visit(project);
assertAddedRawMeasure(DIRECTORY_1_REF, 0);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class ReportFormulaExecutorComponentVisitorTest method ignore_measure_defined_on_project_when_measure_is_defined_on_leaf.
@Test
public void ignore_measure_defined_on_project_when_measure_is_defined_on_leaf() {
ReportComponent root = builder(PROJECT, ROOT_REF).addChildren(builder(Component.Type.FILE, FILE_1_REF).build()).build();
treeRootHolder.setRoot(root);
measureRepository.addRawMeasure(ROOT_REF, LINES_KEY, newMeasureBuilder().create(10));
measureRepository.addRawMeasure(FILE_1_REF, LINES_KEY, newMeasureBuilder().create(2));
new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula())).visit(root);
assertAddedRawMeasure(ROOT_REF, 2);
assertAddedRawMeasure(FILE_1_REF, 2);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class ReportFormulaExecutorComponentVisitorTest method fail_when_trying_to_compute_file_measure_already_existing_in_report.
@Test
public void fail_when_trying_to_compute_file_measure_already_existing_in_report() {
ReportComponent root = builder(PROJECT, ROOT_REF).addChildren(builder(Component.Type.FILE, FILE_1_REF).build()).build();
treeRootHolder.setRoot(root);
measureRepository.addRawMeasure(FILE_1_REF, NCLOC_KEY, newMeasureBuilder().create(2));
// expectedException.expectCause(
// hasType(UnsupportedOperationException.class)
// .andMessage(String.format("A measure can only be set once for Component (ref=%s), Metric (key=%s)", FILE_1_REF, NCLOC_KEY))
// );
assertThatThrownBy(() -> new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula())).visit(root)).hasCause(new UnsupportedOperationException(String.format("A measure can only be set once for Component (ref=%s), Metric (key=%s)", FILE_1_REF, NCLOC_KEY)));
}
Aggregations