Search in sources :

Example 21 with ComputationStep

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

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

the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_MessageException_if_projectKey_is_null_in_CE_task.

@Test
public void execute_fails_with_MessageException_if_projectKey_is_null_in_CE_task() {
    CeTask res = mock(CeTask.class);
    Optional<CeTask.Component> component = Optional.of(new CeTask.Component("prj_uuid", null, null));
    when(res.getComponent()).thenReturn(component);
    when(res.getMainComponent()).thenReturn(Optional.of(new CeTask.Component("main_prj_uuid", "main_prj_key", null)));
    reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
    ComputationStep underTest = createStep(res);
    assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())).isInstanceOf(MessageException.class).hasMessage("Compute Engine task component key is null. Project with UUID prj_uuid must have been deleted since report was uploaded. Can not proceed.");
}
Also used : MessageException(org.sonar.api.utils.MessageException) ComputationStep(org.sonar.ce.task.step.ComputationStep) CeTask(org.sonar.ce.task.CeTask) 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