Search in sources :

Example 1 with TaskContainerImpl

use of org.sonar.ce.task.container.TaskContainerImpl in project sonarqube by SonarSource.

the class ProjectExportTaskProcessor method processProjectExport.

private void processProjectExport(CeTask task) {
    CeTask.Component exportComponent = mandatoryComponent(task, PROJECT_EXPORT);
    failIfNotMain(exportComponent, task);
    ProjectDescriptor projectExportDescriptor = new ProjectDescriptor(exportComponent.getUuid(), mandatoryKey(exportComponent), mandatoryName(exportComponent));
    try (TaskContainer taskContainer = new TaskContainerImpl(componentContainer, new ProjectExportContainerPopulator(projectExportDescriptor))) {
        taskContainer.bootup();
        taskContainer.getComponentByType(ProjectExportProcessor.class).process();
    }
}
Also used : TaskContainerImpl(org.sonar.ce.task.container.TaskContainerImpl) TaskContainer(org.sonar.ce.task.container.TaskContainer) ProjectExportContainerPopulator(org.sonar.ce.task.projectexport.ProjectExportContainerPopulator) CeTask(org.sonar.ce.task.CeTask) ProjectExportProcessor(org.sonar.ce.task.projectexport.ProjectExportProcessor)

Example 2 with TaskContainerImpl

use of org.sonar.ce.task.container.TaskContainerImpl in project sonarqube by SonarSource.

the class IssueSyncTaskProcessor method process.

@CheckForNull
@Override
public CeTaskResult process(CeTask task) {
    try (TaskContainer container = new TaskContainerImpl(ceEngineContainer, newContainerPopulator(task))) {
        container.bootup();
        container.getComponentByType(ComputationStepExecutor.class).execute();
    }
    return null;
}
Also used : TaskContainerImpl(org.sonar.ce.task.container.TaskContainerImpl) TaskContainer(org.sonar.ce.task.container.TaskContainer) ComputationStepExecutor(org.sonar.ce.task.step.ComputationStepExecutor) CheckForNull(javax.annotation.CheckForNull)

Example 3 with TaskContainerImpl

use of org.sonar.ce.task.container.TaskContainerImpl in project sonarqube by SonarSource.

the class ReportComputationStepsTest method instances_throws_ISE_if_container_does_not_have_second_step.

@Test
public void instances_throws_ISE_if_container_does_not_have_second_step() {
    ExtractReportStep reportExtractionStep = mock(ExtractReportStep.class);
    SpringComponentContainer componentContainer = new SpringComponentContainer() {

        {
            add(reportExtractionStep);
        }
    }.startComponents();
    TaskContainerImpl computeEngineContainer = new TaskContainerImpl(componentContainer, container -> {
    // do nothing
    });
    computeEngineContainer.startComponents();
    Iterable<ComputationStep> instances = new ReportComputationSteps(computeEngineContainer).instances();
    assertThatThrownBy(() -> newArrayList(instances)).isInstanceOf(IllegalStateException.class).hasMessageContaining("org.sonar.ce.task.projectanalysis.step.PersistScannerContextStep");
}
Also used : SpringComponentContainer(org.sonar.core.platform.SpringComponentContainer) TaskContainerImpl(org.sonar.ce.task.container.TaskContainerImpl) ComputationStep(org.sonar.ce.task.step.ComputationStep) Test(org.junit.Test)

Example 4 with TaskContainerImpl

use of org.sonar.ce.task.container.TaskContainerImpl in project sonarqube by SonarSource.

the class ReportComputationStepsTest method instances_throws_ISE_if_container_does_not_have_any_step.

@Test
public void instances_throws_ISE_if_container_does_not_have_any_step() {
    TaskContainerImpl computeEngineContainer = new TaskContainerImpl(new SpringComponentContainer(), container -> {
    // do nothing
    });
    Iterable<ComputationStep> instances = new ReportComputationSteps(computeEngineContainer).instances();
    assertThatThrownBy(() -> newArrayList(instances)).isInstanceOf(IllegalStateException.class).hasMessageContaining(ExtractReportStep.class.getName());
}
Also used : SpringComponentContainer(org.sonar.core.platform.SpringComponentContainer) TaskContainerImpl(org.sonar.ce.task.container.TaskContainerImpl) ComputationStep(org.sonar.ce.task.step.ComputationStep) Test(org.junit.Test)

Example 5 with TaskContainerImpl

use of org.sonar.ce.task.container.TaskContainerImpl in project sonarqube by SonarSource.

the class ProjectExportComputationStepsTest method instances_throws_ISE_if_container_does_not_have_second_step.

@Test
public void instances_throws_ISE_if_container_does_not_have_second_step() {
    ComplexityMeasuresStep reportExtractionStep = mock(ComplexityMeasuresStep.class);
    SpringComponentContainer componentContainer = new SpringComponentContainer() {

        {
            add(reportExtractionStep);
        }
    }.startComponents();
    TaskContainerImpl computeEngineContainer = new TaskContainerImpl(componentContainer, container -> {
    // do nothing
    });
    computeEngineContainer.startComponents();
    Iterable<ComputationStep> instances = new ProjectExportComputationSteps(computeEngineContainer).instances();
    assertThatThrownBy(() -> Lists.newArrayList(instances)).isInstanceOf(IllegalStateException.class).hasMessageContaining("class org.sonar.ce.task.projectexport.steps.LoadProjectStep");
}
Also used : SpringComponentContainer(org.sonar.core.platform.SpringComponentContainer) TaskContainerImpl(org.sonar.ce.task.container.TaskContainerImpl) ComputationStep(org.sonar.ce.task.step.ComputationStep) ComplexityMeasuresStep(org.sonar.ce.task.projectanalysis.step.ComplexityMeasuresStep) Test(org.junit.Test)

Aggregations

TaskContainerImpl (org.sonar.ce.task.container.TaskContainerImpl)6 Test (org.junit.Test)3 TaskContainer (org.sonar.ce.task.container.TaskContainer)3 ComputationStep (org.sonar.ce.task.step.ComputationStep)3 SpringComponentContainer (org.sonar.core.platform.SpringComponentContainer)3 CheckForNull (javax.annotation.CheckForNull)2 ComputationStepExecutor (org.sonar.ce.task.step.ComputationStepExecutor)2 CeTask (org.sonar.ce.task.CeTask)1 ComplexityMeasuresStep (org.sonar.ce.task.projectanalysis.step.ComplexityMeasuresStep)1 ProjectExportContainerPopulator (org.sonar.ce.task.projectexport.ProjectExportContainerPopulator)1 ProjectExportProcessor (org.sonar.ce.task.projectexport.ProjectExportProcessor)1