Search in sources :

Example 56 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext 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());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) ComputationStep(org.sonar.ce.task.step.ComputationStep) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 57 with TestComputationStepContext

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

the class LoadReportAnalysisMetadataHolderStepTest method set_root_component_ref.

@Test
public void set_root_component_ref() {
    reportReader.setMetadata(newBatchReportBuilder().setRootComponentRef(1).build());
    underTest.execute(new TestComputationStepContext());
    assertThat(analysisMetadataHolder.getRootComponentRef()).isOne();
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 58 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext 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");
}
Also used : ComputationStep(org.sonar.ce.task.step.ComputationStep) CeTask(org.sonar.ce.task.CeTask) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 59 with TestComputationStepContext

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

the class LoadReportAnalysisMetadataHolderStepTest method set_cross_project_duplication_to_false_when_nothing_in_the_report.

@Test
public void set_cross_project_duplication_to_false_when_nothing_in_the_report() {
    reportReader.setMetadata(newBatchReportBuilder().build());
    underTest.execute(new TestComputationStepContext());
    assertThat(analysisMetadataHolder.isCrossProjectDuplicationEnabled()).isFalse();
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 60 with TestComputationStepContext

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

the class NewSizeMeasuresStepTest method compute_no_new_duplicated_lines_density_when_no_lines.

@Test
public void compute_no_new_duplicated_lines_density_when_no_lines() {
    underTest.execute(new TestComputationStepContext());
    assertNoRawMeasures(NEW_DUPLICATED_LINES_DENSITY_KEY);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Aggregations

TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)458 Test (org.junit.Test)431 ComponentDto (org.sonar.db.component.ComponentDto)91 ProjectDump (com.sonarsource.governance.projectdump.protobuf.ProjectDump)38 Component (org.sonar.ce.task.projectanalysis.component.Component)38 SnapshotDto (org.sonar.db.component.SnapshotDto)31 Date (java.util.Date)30 ReportComponent (org.sonar.ce.task.projectanalysis.component.ReportComponent)28 ComputationStep (org.sonar.ce.task.step.ComputationStep)24 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)17 FileSourceDto (org.sonar.db.source.FileSourceDto)15 BaseStepTest (org.sonar.ce.task.projectanalysis.step.BaseStepTest)14 Project (org.sonar.server.project.Project)14 TextBlock (org.sonar.ce.task.projectanalysis.duplication.TextBlock)13 QualityProfile (org.sonar.server.qualityprofile.QualityProfile)13 Notification (org.sonar.api.notifications.Notification)12 DefaultIssue (org.sonar.core.issue.DefaultIssue)12 MeasureComputer (org.sonar.api.ce.measure.MeasureComputer)11 IssueDto (org.sonar.db.issue.IssueDto)11 IssuesChangesNotification (org.sonar.server.issue.notification.IssuesChangesNotification)11