Search in sources :

Example 6 with ComputationStep

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

the class LoadReportAnalysisMetadataHolderStepTest method set_branch.

@Test
public void set_branch() throws Exception {
    reportReader.setMetadata(newBatchReportBuilder().setBranch(BRANCH).build());
    CeTask ceTask = createCeTask(PROJECT_KEY + ":" + BRANCH, dbTester.getDefaultOrganization().getUuid());
    ComputationStep underTest = createStep(ceTask);
    underTest.execute();
    assertThat(analysisMetadataHolder.getBranch()).isEqualTo(BRANCH);
}
Also used : ComputationStep(org.sonar.server.computation.task.step.ComputationStep) CeTask(org.sonar.ce.queue.CeTask) Test(org.junit.Test)

Example 7 with ComputationStep

use of org.sonar.server.computation.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);
    when(res.getComponentUuid()).thenReturn("prj_uuid");
    reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
    ComputationStep underTest = createStep(res);
    expectedException.expect(MessageException.class);
    expectedException.expectMessage("Compute Engine task component key is null. Project with UUID prj_uuid must have been deleted since report was uploaded. Can not proceed.");
    underTest.execute();
}
Also used : ComputationStep(org.sonar.server.computation.task.step.ComputationStep) CeTask(org.sonar.ce.queue.CeTask) Test(org.junit.Test)

Example 8 with ComputationStep

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

the class LoadReportAnalysisMetadataHolderStepTest method execute_set_non_default_organization_from_ce_task.

@Test
public void execute_set_non_default_organization_from_ce_task() {
    OrganizationDto nonDefaultOrganizationDto = dbTester.organizations().insert();
    reportReader.setMetadata(newBatchReportBuilder().setOrganizationKey(nonDefaultOrganizationDto.getKey()).build());
    ComputationStep underTest = createStep(createCeTask(PROJECT_KEY, nonDefaultOrganizationDto.getUuid()));
    underTest.execute();
    Organization organization = analysisMetadataHolder.getOrganization();
    assertThat(organization.getUuid()).isEqualTo(nonDefaultOrganizationDto.getUuid());
    assertThat(organization.getKey()).isEqualTo(nonDefaultOrganizationDto.getKey());
    assertThat(organization.getName()).isEqualTo(nonDefaultOrganizationDto.getName());
}
Also used : Organization(org.sonar.server.computation.task.projectanalysis.analysis.Organization) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 9 with ComputationStep

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

the class LoadMeasureComputersStepTest method fail_with_ISE_when_input_metric_is_unknown.

@Test
public void fail_with_ISE_when_input_metric_is_unknown() throws Exception {
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Metric 'unknown' cannot be used as an input metric as it's not a core metric and no plugin declare this metric");
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array("unknown"), array(NEW_METRIC_4)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute();
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) Test(org.junit.Test)

Example 10 with ComputationStep

use of org.sonar.server.computation.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() throws Exception {
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Metric 'ncloc' cannot be used as an output metric as it's a core metric");
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_4), array(NCLOC_KEY)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute();
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)17 ComputationStep (org.sonar.server.computation.task.step.ComputationStep)17 MeasureComputer (org.sonar.api.ce.measure.MeasureComputer)11 CeTask (org.sonar.ce.queue.CeTask)2 OrganizationDto (org.sonar.db.organization.OrganizationDto)2 MeasureComputerWrapper (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper)2 Organization (org.sonar.server.computation.task.projectanalysis.analysis.Organization)1