use of org.sonar.ce.task.step.ComputationStep in project sonarqube by SonarSource.
the class LoadMeasureComputersStepTest method sort_computers.
@Test
public void sort_computers() {
// Should be the last to be executed
MeasureComputer measureComputer1 = newMeasureComputer(array(NEW_METRIC_3), array(NEW_METRIC_4));
// Should be the first to be executed
MeasureComputer measureComputer2 = newMeasureComputer(array(NEW_METRIC_1), array(NEW_METRIC_2));
// Should be the second to be executed
MeasureComputer measureComputer3 = newMeasureComputer(array(NEW_METRIC_2), array(NEW_METRIC_3));
MeasureComputer[] computers = new MeasureComputer[] { measureComputer1, measureComputer2, measureComputer3 };
ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
underTest.execute(new TestComputationStepContext());
List<MeasureComputerWrapper> result = newArrayList(holder.getMeasureComputers());
assertThat(result).hasSize(3);
assertThat(result.get(0).getComputer()).isEqualTo(measureComputer2);
assertThat(result.get(1).getComputer()).isEqualTo(measureComputer3);
assertThat(result.get(2).getComputer()).isEqualTo(measureComputer1);
}
use of org.sonar.ce.task.step.ComputationStep in project sonarqube by SonarSource.
the class LoadMeasureComputersStepTest method fail_with_ISE_when_output_metric_is_not_define_by_plugin.
@Test
public void fail_with_ISE_when_output_metric_is_not_define_by_plugin() {
assertThatThrownBy(() -> {
MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_4), array("unknown")) };
ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
underTest.execute(new TestComputationStepContext());
}).isInstanceOf(IllegalStateException.class).hasMessage("Metric 'unknown' cannot be used as an output metric because no plugins declare this metric");
}
use of org.sonar.ce.task.step.ComputationStep in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_MessageException_if_main_projectKey_is_null_in_CE_task.
@Test
public void execute_fails_with_MessageException_if_main_projectKey_is_null_in_CE_task() {
CeTask res = mock(CeTask.class);
Optional<CeTask.Component> component = Optional.of(new CeTask.Component("main_prj_uuid", null, null));
when(res.getComponent()).thenReturn(component);
when(res.getMainComponent()).thenReturn(component);
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
ComputationStep underTest = createStep(res);
assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())).isInstanceOf(MessageException.class).hasMessage("Compute Engine task main component key is null. Project with UUID main_prj_uuid must have been deleted since report was uploaded. Can not proceed.");
}
use of org.sonar.ce.task.step.ComputationStep in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_does_not_fail_when_report_has_a_quality_profile_that_does_not_exist_anymore.
@Test
public void execute_does_not_fail_when_report_has_a_quality_profile_that_does_not_exist_anymore() {
ComponentDto project = db.components().insertPublicProject();
ScannerReport.Metadata.Builder metadataBuilder = newBatchReportBuilder();
metadataBuilder.setProjectKey(project.getDbKey());
metadataBuilder.putQprofilesPerLanguage("js", ScannerReport.Metadata.QProfile.newBuilder().setKey("p1").setName("Sonar way").setLanguage("js").build());
reportReader.setMetadata(metadataBuilder.build());
ComputationStep underTest = createStep(createCeTask(project.getDbKey()));
underTest.execute(new TestComputationStepContext());
}
use of org.sonar.ce.task.step.ComputationStep in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_ISE_if_component_is_null_in_CE_task.
@Test
public void execute_fails_with_ISE_if_component_is_null_in_CE_task() {
CeTask res = mock(CeTask.class);
when(res.getComponent()).thenReturn(Optional.empty());
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
ComputationStep underTest = createStep(res);
assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())).isInstanceOf(IllegalStateException.class).hasMessage("component missing on ce task");
}
Aggregations