diff options
Diffstat (limited to 'server/sonar-server-common/src/test')
-rw-r--r-- | server/sonar-server-common/src/test/java/org/sonar/server/management/DelegatingManagedInstanceServiceTest.java | 27 |
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; } |