Search in sources :

Example 11 with ReportComponent

use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.

the class QualityGateMeasuresStepTest method no_measure_if_tree_has_no_project.

@Test
public void no_measure_if_tree_has_no_project() {
    ReportComponent notAProjectComponent = ReportComponent.builder(Component.Type.MODULE, 1).build();
    treeRootHolder.setRoot(notAProjectComponent);
    underTest.execute();
    measureRepository.getAddedRawMeasures(1).isEmpty();
}
Also used : ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Example 12 with ReportComponent

use of org.sonar.server.computation.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(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();
}
Also used : ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Example 13 with ReportComponent

use of org.sonar.server.computation.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(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();
}
Also used : ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Example 14 with ReportComponent

use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.

the class DistributionFormulaExecutionTest 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, FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=3;3.5=5;6.5=9"));
    measureRepository.addRawMeasure(1112, FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=0;3.5=2;6.5=1"));
    measureRepository.addRawMeasure(1211, FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=1;3.5=3;6.5=2"));
    new PathAwareCrawler<>(underTest).visit(project);
    assertThat(toEntries(measureRepository.getAddedRawMeasures(1))).containsOnly(entryOf(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=4;3.5=10;6.5=12")));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(11))).containsOnly(entryOf(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=3;3.5=7;6.5=10")));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(111))).containsOnly(entryOf(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=3;3.5=7;6.5=10")));
    assertThat(measureRepository.getAddedRawMeasures(1111)).isEmpty();
    assertThat(measureRepository.getAddedRawMeasures(1112)).isEmpty();
    assertThat(toEntries(measureRepository.getAddedRawMeasures(12))).containsOnly(entryOf(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=1;3.5=3;6.5=2")));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(121))).containsOnly(entryOf(FUNCTION_COMPLEXITY_DISTRIBUTION_KEY, newMeasureBuilder().create("0.5=1;3.5=3;6.5=2")));
    assertThat(measureRepository.getAddedRawMeasures(1211)).isEmpty();
}
Also used : ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Example 15 with ReportComponent

use of org.sonar.server.computation.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.

the class ReportFormulaExecutorComponentVisitorTest method measures_are_0_when_there_is_no_input_measure.

@Test
public void measures_are_0_when_there_is_no_input_measure() throws Exception {
    ReportComponent project = ReportComponent.builder(PROJECT, ROOT_REF).addChildren(ReportComponent.builder(MODULE, MODULE_1_REF).addChildren(ReportComponent.builder(DIRECTORY, DIRECTORY_1_REF).addChildren(builder(Component.Type.FILE, FILE_1_REF).build()).build()).build()).build();
    treeRootHolder.setRoot(project);
    new PathAwareCrawler<>(formulaExecutorComponentVisitor(new FakeFormula())).visit(project);
    assertAddedRawMeasure(ROOT_REF, 0);
    assertAddedRawMeasure(MODULE_1_REF, 0);
    assertAddedRawMeasure(DIRECTORY_1_REF, 0);
    assertAddedRawMeasure(FILE_1_REF, 0);
}
Also used : ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 ReportComponent (org.sonar.server.computation.task.projectanalysis.component.ReportComponent)20 FileAttributes (org.sonar.server.computation.task.projectanalysis.component.FileAttributes)3 VisitorsCrawler (org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler)3 DefaultIssue (org.sonar.core.issue.DefaultIssue)2 MapSettings (org.sonar.api.config.MapSettings)1 Component (org.sonar.server.computation.task.projectanalysis.component.Component)1 ViewsComponent (org.sonar.server.computation.task.projectanalysis.component.ViewsComponent)1 Measure (org.sonar.server.computation.task.projectanalysis.measure.Measure)1