Search in sources :

Example 16 with ComputationStep

use of org.sonar.ce.task.step.ComputationStep 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 17 with ComputationStep

use of org.sonar.ce.task.step.ComputationStep in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method return_empty_list_when_no_measure_computers.

@Test
public void return_empty_list_when_no_measure_computers() {
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()));
    underTest.execute(new TestComputationStepContext());
    assertThat(holder.getMeasureComputers()).isEmpty();
}
Also used : ComputationStep(org.sonar.ce.task.step.ComputationStep) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 18 with ComputationStep

use of org.sonar.ce.task.step.ComputationStep in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method fail_with_ISE_when_no_metrics_are_defined_by_plugin_but_measure_computer_use_a_new_metric.

@Test
public void fail_with_ISE_when_no_metrics_are_defined_by_plugin_but_measure_computer_use_a_new_metric() {
    assertThatThrownBy(() -> {
        MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NCLOC_KEY), array(NEW_METRIC_1)) };
        ComputationStep underTest = new LoadMeasureComputersStep(holder, computers);
        underTest.execute(new TestComputationStepContext());
    }).isInstanceOf(IllegalStateException.class).hasMessage("Metric 'metric1' cannot be used as an output metric because no plugins declare this 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 19 with ComputationStep

use of org.sonar.ce.task.step.ComputationStep 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)

Example 20 with ComputationStep

use of org.sonar.ce.task.step.ComputationStep in project sonarqube by SonarSource.

the class LoadMeasureComputersStepTest method support_core_metrics_as_input_metrics.

@Test
public void support_core_metrics_as_input_metrics() {
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NCLOC_KEY), array(NEW_METRIC_1)) };
    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

Test (org.junit.Test)22 ComputationStep (org.sonar.ce.task.step.ComputationStep)22 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)17 MeasureComputer (org.sonar.api.ce.measure.MeasureComputer)11 CeTask (org.sonar.ce.task.CeTask)3 TaskContainerImpl (org.sonar.ce.task.container.TaskContainerImpl)3 SpringComponentContainer (org.sonar.core.platform.SpringComponentContainer)3 MessageException (org.sonar.api.utils.MessageException)2 MeasureComputerWrapper (org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper)2 ComplexityMeasuresStep (org.sonar.ce.task.projectanalysis.step.ComplexityMeasuresStep)1 AuditPurgeComputationSteps (org.sonar.ce.task.projectanalysis.taskprocessor.AuditPurgeTaskProcessor.AuditPurgeComputationSteps)1 SyncComputationSteps (org.sonar.ce.task.projectanalysis.taskprocessor.IssueSyncTaskProcessor.SyncComputationSteps)1 ComponentDto (org.sonar.db.component.ComponentDto)1