Search in sources :

Example 1 with Organization

use of org.sonar.server.computation.task.projectanalysis.analysis.Organization in project sonarqube by SonarSource.

the class LoadReportAnalysisMetadataHolderStep method execute.

@Override
public void execute() {
    ScannerReport.Metadata reportMetadata = reportReader.readMetadata();
    mutableAnalysisMetadataHolder.setAnalysisDate(reportMetadata.getAnalysisDate());
    checkProjectKeyConsistency(reportMetadata);
    Organization organization = toOrganization(ceTask.getOrganizationUuid());
    checkOrganizationKeyConsistency(reportMetadata, organization);
    mutableAnalysisMetadataHolder.setRootComponentRef(reportMetadata.getRootComponentRef());
    mutableAnalysisMetadataHolder.setBranch(isNotEmpty(reportMetadata.getBranch()) ? reportMetadata.getBranch() : null);
    mutableAnalysisMetadataHolder.setCrossProjectDuplicationEnabled(reportMetadata.getCrossProjectDuplicationActivated());
    mutableAnalysisMetadataHolder.setQProfilesByLanguage(transformValues(reportMetadata.getQprofilesPerLanguage(), TO_COMPUTE_QPROFILE));
    mutableAnalysisMetadataHolder.setOrganization(organization);
}
Also used : Organization(org.sonar.server.computation.task.projectanalysis.analysis.Organization) ScannerReport(org.sonar.scanner.protocol.output.ScannerReport)

Example 2 with Organization

use of org.sonar.server.computation.task.projectanalysis.analysis.Organization in project sonarqube by SonarSource.

the class LoadReportAnalysisMetadataHolderStepTest method execute_set_organization_from_ce_task_when_organizationKey_is_set_in_report.

@Test
public void execute_set_organization_from_ce_task_when_organizationKey_is_set_in_report() {
    reportReader.setMetadata(newBatchReportBuilder().setOrganizationKey(dbTester.getDefaultOrganization().getKey()).build());
    underTest.execute();
    Organization organization = analysisMetadataHolder.getOrganization();
    OrganizationDto defaultOrganization = dbTester.getDefaultOrganization();
    assertThat(organization.getUuid()).isEqualTo(defaultOrganization.getUuid());
    assertThat(organization.getKey()).isEqualTo(defaultOrganization.getKey());
    assertThat(organization.getName()).isEqualTo(defaultOrganization.getName());
}
Also used : Organization(org.sonar.server.computation.task.projectanalysis.analysis.Organization) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 3 with Organization

use of org.sonar.server.computation.task.projectanalysis.analysis.Organization 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 4 with Organization

use of org.sonar.server.computation.task.projectanalysis.analysis.Organization in project sonarqube by SonarSource.

the class LoadReportAnalysisMetadataHolderStepTest method execute_set_organization_from_ce_task_when_organizationKey_is_not_set_in_report.

@Test
public void execute_set_organization_from_ce_task_when_organizationKey_is_not_set_in_report() {
    reportReader.setMetadata(newBatchReportBuilder().build());
    underTest.execute();
    Organization organization = analysisMetadataHolder.getOrganization();
    OrganizationDto defaultOrganization = dbTester.getDefaultOrganization();
    assertThat(organization.getUuid()).isEqualTo(defaultOrganization.getUuid());
    assertThat(organization.getKey()).isEqualTo(defaultOrganization.getKey());
    assertThat(organization.getName()).isEqualTo(defaultOrganization.getName());
}
Also used : Organization(org.sonar.server.computation.task.projectanalysis.analysis.Organization) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Aggregations

Organization (org.sonar.server.computation.task.projectanalysis.analysis.Organization)4 Test (org.junit.Test)3 OrganizationDto (org.sonar.db.organization.OrganizationDto)3 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)1 ComputationStep (org.sonar.server.computation.task.step.ComputationStep)1