aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-common/src/test
diff options
context:
space:
mode:
authorAntoine Vigneau <antoine.vigneau@sonarsource.com>2023-05-04 14:58:54 +0200
committersonartech <sonartech@sonarsource.com>2023-05-11 20:03:14 +0000
commit965d66bb3385fc196ba867e5ccabbe23a574ca39 (patch)
tree10cf16bdc900c0c1952282680001bc502bf83a85 /server/sonar-server-common/src/test
parentbfacb4c8eab9949a52afb6e467504c6afb150a31 (diff)
downloadsonarqube-965d66bb3385fc196ba867e5ccabbe23a574ca39.tar.gz
sonarqube-965d66bb3385fc196ba867e5ccabbe23a574ca39.zip
SONAR-19084 Return GitHub as provider managing the instance in system/info
Diffstat (limited to 'server/sonar-server-common/src/test')
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/management/DelegatingManagedInstanceServiceTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/management/DelegatingManagedInstanceServiceTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/management/DelegatingManagedInstanceServiceTest.java
index aee38302901..5f3b35dac93 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/management/DelegatingManagedInstanceServiceTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/management/DelegatingManagedInstanceServiceTest.java
@@ -30,6 +30,7 @@ import org.sonar.db.DbSession;
import static java.util.Collections.emptySet;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -40,6 +41,22 @@ public class DelegatingManagedInstanceServiceTest {
private DbSession dbSession;
@Test
+ public void getProviderName_whenNotManaged_shouldThrow() {
+ DelegatingManagedInstanceService managedInstanceService = new DelegatingManagedInstanceService(emptySet());
+
+ assertThatThrownBy(() -> managedInstanceService.getProviderName())
+ .isInstanceOf(IllegalStateException.class)
+ .hasMessage("This instance is not managed.");
+ }
+
+ @Test
+ public void getProviderName_whenManaged_shouldReturnName() {
+ DelegatingManagedInstanceService managedInstanceService = new DelegatingManagedInstanceService(Set.of(new AlwaysManagedInstanceService()));
+
+ assertThat(managedInstanceService.getProviderName()).isEqualTo("Always");
+ }
+
+ @Test
public void isInstanceExternallyManaged_whenNoManagedInstanceService_returnsFalse() {
DelegatingManagedInstanceService managedInstanceService = new DelegatingManagedInstanceService(emptySet());
assertThat(managedInstanceService.isInstanceExternallyManaged()).isFalse();
@@ -177,6 +194,11 @@ public class DelegatingManagedInstanceServiceTest {
}
@Override
+ public String getProviderName() {
+ return "Never";
+ }
+
+ @Override
public Map<String, Boolean> getUserUuidToManaged(DbSession dbSession, Set<String> userUuids) {
return null;
}
@@ -205,6 +227,11 @@ public class DelegatingManagedInstanceServiceTest {
}
@Override
+ public String getProviderName() {
+ return "Always";
+ }
+
+ @Override
public Map<String, Boolean> getUserUuidToManaged(DbSession dbSession, Set<String> userUuids) {
return null;
}