aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-common
diff options
context:
space:
mode:
authorJean-Baptiste Lièvremont <jb.lievremont@gmail.com>2019-01-10 14:40:39 +0100
committerSonarTech <sonartech@sonarsource.com>2019-01-18 20:21:03 +0100
commitc173166cd399c3d5b93381a0a98244c1baf73650 (patch)
treee59e780b907f9628b40a663816c8f9571d9cce5a /server/sonar-server-common
parent5c110414621fcfb2db1083f76ff09c4b6364757f (diff)
downloadsonarqube-c173166cd399c3d5b93381a0a98244c1baf73650.tar.gz
sonarqube-c173166cd399c3d5b93381a0a98244c1baf73650.zip
SONARCLOUD-312 Use key instead of UUID to send downgrade feedback (#1140)
Diffstat (limited to 'server/sonar-server-common')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/organization/BillingValidations.java8
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/organization/BillingValidationsProxyImplTest.java29
2 files changed, 18 insertions, 19 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/organization/BillingValidations.java b/server/sonar-server-common/src/main/java/org/sonar/server/organization/BillingValidations.java
index d8a765b2f38..a10acbe3d10 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/organization/BillingValidations.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/organization/BillingValidations.java
@@ -57,10 +57,12 @@ public interface BillingValidations {
class Organization {
private final String key;
private final String uuid;
+ private final String name;
- public Organization(String key, String uuid) {
+ public Organization(String key, String uuid, String name) {
this.key = requireNonNull(key, "Organization key cannot be null");
this.uuid = requireNonNull(uuid, "Organization uuid cannot be null");
+ this.name = requireNonNull(name, "Organization name cannot be null");
}
public String getKey() {
@@ -70,6 +72,10 @@ public interface BillingValidations {
public String getUuid() {
return uuid;
}
+
+ public String getName() {
+ return name;
+ }
}
class BillingValidationsException extends MessageException {
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/organization/BillingValidationsProxyImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/organization/BillingValidationsProxyImplTest.java
index c9039fb626e..46e574a186e 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/organization/BillingValidationsProxyImplTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/organization/BillingValidationsProxyImplTest.java
@@ -30,8 +30,7 @@ import static org.sonar.server.organization.BillingValidations.Organization;
public class BillingValidationsProxyImplTest {
- private static String ORGANIZATION_KEY = "ORGANIZATION_KEY";
- private static String ORGANIZATION_UUID = "ORGANIZATION_UUID";
+ private static final Organization ORGANIZATION = new Organization("ORGANIZATION_KEY", "ORGANIZATION_UUID", "ORGANIZATION_NAME");
private BillingValidationsExtension billingValidationsExtension = mock(BillingValidationsExtension.class);
@@ -40,19 +39,17 @@ public class BillingValidationsProxyImplTest {
@Test
public void checkOnProjectAnalysis_calls_extension_when_available() {
underTest = new BillingValidationsProxyImpl(billingValidationsExtension);
- Organization organization = new Organization(ORGANIZATION_KEY, ORGANIZATION_UUID);
- underTest.checkBeforeProjectAnalysis(organization);
+ underTest.checkBeforeProjectAnalysis(ORGANIZATION);
- verify(billingValidationsExtension).checkBeforeProjectAnalysis(organization);
+ verify(billingValidationsExtension).checkBeforeProjectAnalysis(ORGANIZATION);
}
@Test
public void checkOnProjectAnalysis_does_nothing_when_no_extension_available() {
underTest = new BillingValidationsProxyImpl();
- Organization organization = new Organization(ORGANIZATION_KEY, ORGANIZATION_UUID);
- underTest.checkBeforeProjectAnalysis(organization);
+ underTest.checkBeforeProjectAnalysis(ORGANIZATION);
verifyZeroInteractions(billingValidationsExtension);
}
@@ -60,19 +57,17 @@ public class BillingValidationsProxyImplTest {
@Test
public void checkCanUpdateProjectsVisibility_calls_extension_when_available() {
underTest = new BillingValidationsProxyImpl(billingValidationsExtension);
- Organization organization = new Organization(ORGANIZATION_KEY, ORGANIZATION_UUID);
- underTest.checkCanUpdateProjectVisibility(organization, true);
+ underTest.checkCanUpdateProjectVisibility(ORGANIZATION, true);
- verify(billingValidationsExtension).checkCanUpdateProjectVisibility(organization, true);
+ verify(billingValidationsExtension).checkCanUpdateProjectVisibility(ORGANIZATION, true);
}
@Test
public void checkCanUpdateProjectsVisibility_does_nothing_when_no_extension_available() {
underTest = new BillingValidationsProxyImpl();
- Organization organization = new Organization(ORGANIZATION_KEY, ORGANIZATION_UUID);
- underTest.checkCanUpdateProjectVisibility(organization, true);
+ underTest.checkCanUpdateProjectVisibility(ORGANIZATION, true);
verifyZeroInteractions(billingValidationsExtension);
}
@@ -80,21 +75,19 @@ public class BillingValidationsProxyImplTest {
@Test
public void canUpdateProjectsVisibilityToPrivate_calls_extension_when_available() {
underTest = new BillingValidationsProxyImpl(billingValidationsExtension);
- Organization organization = new Organization(ORGANIZATION_KEY, ORGANIZATION_UUID);
- when(billingValidationsExtension.canUpdateProjectVisibilityToPrivate(organization)).thenReturn(false);
+ when(billingValidationsExtension.canUpdateProjectVisibilityToPrivate(ORGANIZATION)).thenReturn(false);
- boolean result = underTest.canUpdateProjectVisibilityToPrivate(organization);
+ boolean result = underTest.canUpdateProjectVisibilityToPrivate(ORGANIZATION);
assertThat(result).isFalse();
- verify(billingValidationsExtension).canUpdateProjectVisibilityToPrivate(organization);
+ verify(billingValidationsExtension).canUpdateProjectVisibilityToPrivate(ORGANIZATION);
}
@Test
public void canUpdateProjectsVisibilityToPrivate_return_true_when_no_extension() {
underTest = new BillingValidationsProxyImpl();
- Organization organization = new Organization(ORGANIZATION_KEY, ORGANIZATION_UUID);
- boolean result = underTest.canUpdateProjectVisibilityToPrivate(organization);
+ boolean result = underTest.canUpdateProjectVisibilityToPrivate(ORGANIZATION);
assertThat(result).isTrue();
verifyZeroInteractions(billingValidationsExtension);