Search in sources :

Example 11 with VisitorsCrawler

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

the class ReportMeasureComputersVisitorTest method nothing_to_compute.

@Test
public void nothing_to_compute() throws Exception {
    addRawMeasure(FILE_1_REF, NCLOC_KEY, 10);
    addRawMeasure(FILE_1_REF, COMMENT_LINES_KEY, 2);
    addRawMeasure(FILE_2_REF, NCLOC_KEY, 40);
    addRawMeasure(FILE_2_REF, COMMENT_LINES_KEY, 5);
    addRawMeasure(DIRECTORY_REF, NCLOC_KEY, 50);
    addRawMeasure(DIRECTORY_REF, COMMENT_LINES_KEY, 7);
    addRawMeasure(MODULE_REF, NCLOC_KEY, 50);
    addRawMeasure(MODULE_REF, COMMENT_LINES_KEY, 7);
    addRawMeasure(ROOT_REF, NCLOC_KEY, 50);
    addRawMeasure(ROOT_REF, COMMENT_LINES_KEY, 7);
    measureComputersHolder.setMeasureComputers(Collections.<MeasureComputerWrapper>emptyList());
    VisitorsCrawler visitorsCrawler = new VisitorsCrawler(Arrays.<ComponentVisitor>asList(new MeasureComputersVisitor(metricRepository, measureRepository, null, measureComputersHolder, componentIssuesRepository)));
    visitorsCrawler.visit(ROOT);
    assertNoAddedRawMeasure(FILE_1_REF);
    assertNoAddedRawMeasure(FILE_2_REF);
    assertNoAddedRawMeasure(DIRECTORY_REF);
    assertNoAddedRawMeasure(MODULE_REF);
    assertNoAddedRawMeasure(ROOT_REF);
}
Also used : VisitorsCrawler(org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler) Test(org.junit.Test)

Example 12 with VisitorsCrawler

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

the class ViewsMeasureComputersVisitorTest method compute_plugin_measure_on_views_tree_having_only_one_view_with_a_project_view.

@Test
public void compute_plugin_measure_on_views_tree_having_only_one_view_with_a_project_view() throws Exception {
    treeRootHolder.setRoot(TREE_WITH_DIRECT_PROJECT_VIEW);
    addRawMeasure(PROJECT_VIEW_1_REF, NCLOC_KEY, 10);
    addRawMeasure(PROJECT_VIEW_1_REF, COMMENT_LINES_KEY, 2);
    addRawMeasure(PROJECT_VIEW_2_REF, NCLOC_KEY, 40);
    addRawMeasure(PROJECT_VIEW_2_REF, COMMENT_LINES_KEY, 5);
    addRawMeasure(ROOT_REF, NCLOC_KEY, 50);
    addRawMeasure(ROOT_REF, COMMENT_LINES_KEY, 7);
    measureComputersHolder.addMeasureComputer(MEASURE_COMPUTER);
    VisitorsCrawler visitorsCrawler = new VisitorsCrawler(Arrays.<ComponentVisitor>asList(new MeasureComputersVisitor(metricRepository, measureRepository, null, measureComputersHolder, componentIssuesRepository)));
    visitorsCrawler.visit(treeRootHolder.getRoot());
    assertNoAddedRawMeasureOnProjectViews();
    assertAddedRawMeasure(57, ROOT_REF, NEW_METRIC_KEY);
}
Also used : VisitorsCrawler(org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler) Test(org.junit.Test)

Example 13 with VisitorsCrawler

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

the class ViewsMeasureComputersVisitorTest method compute_plugin_measure.

@Test
public void compute_plugin_measure() throws Exception {
    treeRootHolder.setRoot(TREE_WITH_SUB_VIEWS);
    addRawMeasure(PROJECT_VIEW_1_REF, NCLOC_KEY, 10);
    addRawMeasure(PROJECT_VIEW_1_REF, COMMENT_LINES_KEY, 2);
    addRawMeasure(PROJECT_VIEW_2_REF, NCLOC_KEY, 40);
    addRawMeasure(PROJECT_VIEW_2_REF, COMMENT_LINES_KEY, 5);
    addRawMeasure(SUB_SUBVIEW_REF, NCLOC_KEY, 50);
    addRawMeasure(SUB_SUBVIEW_REF, COMMENT_LINES_KEY, 7);
    addRawMeasure(VIEW_REF, NCLOC_KEY, 50);
    addRawMeasure(VIEW_REF, COMMENT_LINES_KEY, 7);
    addRawMeasure(ROOT_REF, NCLOC_KEY, 50);
    addRawMeasure(ROOT_REF, COMMENT_LINES_KEY, 7);
    measureComputersHolder.addMeasureComputer(MEASURE_COMPUTER);
    VisitorsCrawler visitorsCrawler = new VisitorsCrawler(Arrays.<ComponentVisitor>asList(new MeasureComputersVisitor(metricRepository, measureRepository, null, measureComputersHolder, componentIssuesRepository)));
    visitorsCrawler.visit(treeRootHolder.getRoot());
    assertNoAddedRawMeasureOnProjectViews();
    assertAddedRawMeasure(57, SUB_SUBVIEW_REF, NEW_METRIC_KEY);
    assertAddedRawMeasure(57, VIEW_REF, NEW_METRIC_KEY);
    assertAddedRawMeasure(57, ROOT_REF, NEW_METRIC_KEY);
}
Also used : VisitorsCrawler(org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler) Test(org.junit.Test)

Example 14 with VisitorsCrawler

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

the class ViewsMeasureComputersVisitorTest method nothing_to_compute_when_no_project_view.

@Test
public void nothing_to_compute_when_no_project_view() throws Exception {
    treeRootHolder.setRoot(builder(VIEW, ROOT_REF).addChildren(builder(SUBVIEW, VIEW_REF).addChildren(builder(SUBVIEW, SUB_SUBVIEW_REF).build()).build()).build());
    measureComputersHolder.addMeasureComputer(MEASURE_COMPUTER);
    VisitorsCrawler visitorsCrawler = new VisitorsCrawler(Arrays.<ComponentVisitor>asList(new MeasureComputersVisitor(metricRepository, measureRepository, null, measureComputersHolder, componentIssuesRepository)));
    visitorsCrawler.visit(treeRootHolder.getRoot());
    assertNoAddedRawMeasureOnProjectViews();
    assertNoAddedRawMeasure(SUB_SUBVIEW_REF);
    assertNoAddedRawMeasure(VIEW_REF);
    assertNoAddedRawMeasure(ROOT_REF);
}
Also used : VisitorsCrawler(org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler) Test(org.junit.Test)

Aggregations

VisitorsCrawler (org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler)14 Test (org.junit.Test)10 Before (org.junit.Before)3 ReportComponent (org.sonar.server.computation.task.projectanalysis.component.ReportComponent)3 ViewsComponent (org.sonar.server.computation.task.projectanalysis.component.ViewsComponent)2 MeasureComputer (org.sonar.api.ce.measure.MeasureComputer)1 MeasureComputerDefinitionImpl (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerDefinitionImpl)1 MeasureComputerWrapper (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper)1 Component (org.sonar.server.computation.task.projectanalysis.component.Component)1 ComponentVisitor (org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor)1 Measure (org.sonar.server.computation.task.projectanalysis.measure.Measure)1