Search in sources :

Example 6 with VisitorsCrawler

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

the class MaintainabilityMeasuresVisitorTest method setUp.

@Before
public void setUp() {
    // assumes rating configuration is consistent
    when(ratingSettings.getRatingGrid()).thenReturn(new RatingGrid(RATING_GRID));
    when(ratingSettings.getDevCost(LANGUAGE_KEY_1)).thenReturn(DEV_COST_LANGUAGE_1);
    when(ratingSettings.getDevCost(LANGUAGE_KEY_2)).thenReturn(DEV_COST_LANGUAGE_2);
    underTest = new VisitorsCrawler(singletonList(new MaintainabilityMeasuresVisitor(metricRepository, measureRepository, ratingSettings)));
}
Also used : VisitorsCrawler(org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler) Before(org.junit.Before)

Example 7 with VisitorsCrawler

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

the class NewMaintainabilityMeasuresVisitorTest method setUp.

@Before
public void setUp() throws Exception {
    when(ratingSettings.getRatingGrid()).thenReturn(new RatingGrid(RATING_GRID));
    underTest = new VisitorsCrawler(Arrays.asList(new NewMaintainabilityMeasuresVisitor(metricRepository, measureRepository, scmInfoRepository, periodsHolder, ratingSettings)));
}
Also used : VisitorsCrawler(org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler) Before(org.junit.Before)

Example 8 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_measure_computers.

@Test
public void nothing_to_compute_when_no_measure_computers() 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);
    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)

Example 9 with VisitorsCrawler

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

the class CloseIssuesOnRemovedComponentsVisitorTest method setUp.

@Before
public void setUp() throws Exception {
    issueCache = new IssueCache(temp.newFile(), System2.INSTANCE);
    underTest = new VisitorsCrawler(Arrays.<ComponentVisitor>asList(new CloseIssuesOnRemovedComponentsVisitor(baseIssuesLoader, componentsWithUnprocessedIssues, issueCache, issueLifecycle)));
}
Also used : ComponentVisitor(org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor) VisitorsCrawler(org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler) Before(org.junit.Before)

Example 10 with VisitorsCrawler

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

the class ReportMeasureComputersVisitorTest method compute_plugin_measure.

@Test
public void compute_plugin_measure() 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);
    final MeasureComputer.MeasureComputerDefinition definition = new MeasureComputerDefinitionImpl.BuilderImpl().setInputMetrics(NCLOC_KEY, COMMENT_LINES_KEY).setOutputMetrics(NEW_METRIC_KEY).build();
    measureComputersHolder.setMeasureComputers(newArrayList(new MeasureComputerWrapper(new MeasureComputer() {

        @Override
        public MeasureComputerDefinition define(MeasureComputerDefinitionContext defContext) {
            return definition;
        }

        @Override
        public void compute(MeasureComputerContext context) {
            org.sonar.api.ce.measure.Measure ncloc = context.getMeasure(NCLOC_KEY);
            org.sonar.api.ce.measure.Measure comment = context.getMeasure(COMMENT_LINES_KEY);
            if (ncloc != null && comment != null) {
                context.addMeasure(NEW_METRIC_KEY, ncloc.getIntValue() + comment.getIntValue());
            }
        }
    }, definition)));
    VisitorsCrawler visitorsCrawler = new VisitorsCrawler(Arrays.<ComponentVisitor>asList(new MeasureComputersVisitor(metricRepository, measureRepository, null, measureComputersHolder, componentIssuesRepository)));
    visitorsCrawler.visit(ROOT);
    assertAddedRawMeasure(12, FILE_1_REF, NEW_METRIC_KEY);
    assertAddedRawMeasure(45, FILE_2_REF, NEW_METRIC_KEY);
    assertAddedRawMeasure(57, DIRECTORY_REF, NEW_METRIC_KEY);
    assertAddedRawMeasure(57, MODULE_REF, NEW_METRIC_KEY);
    assertAddedRawMeasure(57, ROOT_REF, NEW_METRIC_KEY);
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) MeasureComputerWrapper(org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper) MeasureComputerDefinitionImpl(org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerDefinitionImpl) 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