private void checkOrganizationKeyConsistency(ScannerReport.Metadata reportMetadata, Organization organization) { String organizationKey = reportMetadata.getOrganizationKey(); String resolveReportOrganizationKey = resolveReportOrganizationKey(organizationKey); if (!resolveReportOrganizationKey.equals(organization.getKey())) { if (reportBelongsToDefaultOrganization(organizationKey)) { throw MessageException.of(format( "Report does not specify an OrganizationKey but it has been submitted to another organization (%s) than the default one (%s)", organization.getKey(), defaultOrganizationProvider.get().getKey())); } else { throw MessageException.of(format( "OrganizationKey in report (%s) is not consistent with organizationKey under which the report as been submitted (%s)", resolveReportOrganizationKey, organization.getKey())); } } }
@Test public void write_project_organization() throws Exception { when(properties.organizationKey()).thenReturn(Optional.of("SonarSource")); File outputDir = temp.newFolder(); ScannerReportWriter writer = new ScannerReportWriter(outputDir); underTest.publish(writer); ScannerReportReader reader = new ScannerReportReader(outputDir); ScannerReport.Metadata metadata = reader.readMetadata(); assertThat(metadata.getOrganizationKey()).isEqualTo("SonarSource"); }
private void checkOrganizationKeyConsistency(ScannerReport.Metadata reportMetadata, Organization organization) { String organizationKey = reportMetadata.getOrganizationKey(); String resolveReportOrganizationKey = resolveReportOrganizationKey(organizationKey); if (!resolveReportOrganizationKey.equals(organization.getKey())) { if (reportBelongsToDefaultOrganization(organizationKey)) { throw MessageException.of(format( "Report does not specify an OrganizationKey but it has been submitted to another organization (%s) than the default one (%s)", organization.getKey(), defaultOrganizationProvider.get().getKey())); } else { throw MessageException.of(format( "OrganizationKey in report (%s) is not consistent with organizationKey under which the report as been submitted (%s)", resolveReportOrganizationKey, organization.getKey())); } } }