Search in sources :

Example 1 with ComputationStep

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

the class LoadMeasureComputersStepTest method not_fail_if_input_metrics_are_same_as_output_metrics.

@Test
public void not_fail_if_input_metrics_are_same_as_output_metrics() throws Exception {
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_1), array(NEW_METRIC_1)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute();
    assertThat(holder.getMeasureComputers()).hasSize(1);
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) Test(org.junit.Test)

Example 2 with ComputationStep

use of org.sonar.server.computation.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() throws Exception {
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NCLOC_KEY), array(NEW_METRIC_1)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute();
    assertThat(holder.getMeasureComputers()).hasSize(1);
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) Test(org.junit.Test)

Example 3 with ComputationStep

use of org.sonar.server.computation.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() throws Exception {
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_1), array(NEW_METRIC_2)) };
    ComputationStep underTest = new LoadMeasureComputersStep(holder, array(new TestMetrics()), computers);
    underTest.execute();
    assertThat(holder.getMeasureComputers()).hasSize(1);
}
Also used : MeasureComputer(org.sonar.api.ce.measure.MeasureComputer) ComputationStep(org.sonar.server.computation.task.step.ComputationStep) Test(org.junit.Test)

Example 4 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_not_define_by_plugin.

@Test
public void fail_with_ISE_when_output_metric_is_not_define_by_plugin() throws Exception {
    thrown.expect(IllegalStateException.class);
    thrown.expectMessage("Metric 'unknown' cannot be used as an output metric as no plugin declare this metric");
    MeasureComputer[] computers = new MeasureComputer[] { newMeasureComputer(array(NEW_METRIC_4), array("unknown")) };
    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 5 with ComputationStep

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

the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_MessageException_when_report_has_no_organizationKey_but_does_not_belong_to_the_default_organization.

@Test
public void execute_fails_with_MessageException_when_report_has_no_organizationKey_but_does_not_belong_to_the_default_organization() {
    reportReader.setMetadata(newBatchReportBuilder().build());
    OrganizationDto nonDefaultOrganizationDto = dbTester.organizations().insert();
    ComputationStep underTest = createStep(createCeTask(PROJECT_KEY, nonDefaultOrganizationDto.getUuid()));
    expectedException.expect(MessageException.class);
    expectedException.expectMessage("Report does not specify an OrganizationKey but it has been submitted to another organization (" + nonDefaultOrganizationDto.getKey() + ") than the default one (" + dbTester.getDefaultOrganization().getKey() + ")");
    underTest.execute();
}
Also used : ComputationStep(org.sonar.server.computation.task.step.ComputationStep) OrganizationDto(org.sonar.db.organization.OrganizationDto) 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