Search in sources :

Example 26 with MeasureComputer

use of org.sonar.api.ce.measure.MeasureComputer in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method fail_with_ISE_when_output_metric_is_a_core_metric.

@Test
public void fail_with_ISE_when_output_metric_is_a_core_metric() {
    assertThatThrownBy(() -> {
        MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_4), array(NCLOC_KEY)) };
        ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
        underTest.execute(new TestComputationStepContext());
    }).isInstanceOf(IllegalStateException.class).hasMessage("Metric 'ncloc' cannot be used as an output metric because it's a core metric");
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.ce.task.step.ComputationStep) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 27 with MeasureComputer

use of org.sonar.api.ce.measure.MeasureComputer in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method fail_with_ISE_when_two_measure_computers_generate_the_same_output_metric.

@Test
public void fail_with_ISE_when_two_measure_computers_generate_the_same_output_metric() {
    assertThatThrownBy(() -> {
        MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NCLOC_KEY), array(NEW_METRIC_1)), newMeasureComputer(array(CLASSES_KEY), array(NEW_METRIC_1)) };
        ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
        underTest.execute(new TestComputationStepContext());
    }).isInstanceOf(IllegalStateException.class).hasMessage("Output metric 'metric1' is already defined by another measure computer 'TestMeasureComputer'");
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.ce.task.step.ComputationStep) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 28 with MeasureComputer

use of org.sonar.api.ce.measure.MeasureComputer in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method support_plugin_metrics_as_input_metrics.

@Test
public void support_plugin_metrics_as_input_metrics() {
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_1), array(NEW_METRIC_2)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute(new TestComputationStepContext());
    assertThat(holder.getMeasureComputers()).hasSize(1);
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.ce.task.step.ComputationStep) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Aggregations

MeasureComputer (org.sonar.api.ce.measure.MeasureComputer)28 Test (org.junit.Test)24 ComputationStep (org.sonar.ce.task.step.ComputationStep)11 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)11 ComputationStep (org.sonar.server.computation.task.step.ComputationStep)11 MeasureComputerWrapper (org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper)5 MeasureComputerWrapper (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper)5 MeasureComputerContextImpl (org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerContextImpl)1 MeasureComputerDefinitionImpl (org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerDefinitionImpl)1 VisitorsCrawler (org.sonar.ce.task.projectanalysis.component.VisitorsCrawler)1 MeasureComputerContextImpl (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerContextImpl)1 MeasureComputerDefinitionImpl (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerDefinitionImpl)1 VisitorsCrawler (org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler)1