diff options
author | Klaudio Sinani <klaudio.sinani@sonarsource.com> | 2021-11-17 22:54:06 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-11-19 20:03:27 +0000 |
commit | a3d88ea27c35921647d7602755828ca73e15e865 (patch) | |
tree | 5626c38afab1ea00ab9897da431476c17b478bbe /server/sonar-auth-github/src | |
parent | 92f482f2aa43e4aa36e0fda377d13b9dc3282ff9 (diff) | |
download | sonarqube-a3d88ea27c35921647d7602755828ca73e15e865.tar.gz sonarqube-a3d88ea27c35921647d7602755828ca73e15e865.zip |
SONAR-15631 - Refactor UTs to stop using ExpectedException
Diffstat (limited to 'server/sonar-auth-github/src')
2 files changed, 4 insertions, 11 deletions
diff --git a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubIdentityProviderTest.java b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubIdentityProviderTest.java index d7ee6b2efd2..2e5e47a770f 100644 --- a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubIdentityProviderTest.java +++ b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubIdentityProviderTest.java @@ -19,21 +19,18 @@ */ package org.sonar.auth.github; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.server.authentication.OAuth2IdentityProvider; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class GitHubIdentityProviderTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); private MapSettings settings = new MapSettings(); private GitHubSettings gitHubSettings = new GitHubSettings(settings.asConfig()); @@ -128,9 +125,9 @@ public class GitHubIdentityProviderTest { setSettings(false); OAuth2IdentityProvider.InitContext context = mock(OAuth2IdentityProvider.InitContext.class); - thrown.expect(IllegalStateException.class); - thrown.expectMessage("GitHub authentication is disabled"); - underTest.init(context); + assertThatThrownBy(() -> underTest.init(context)) + .isInstanceOf(IllegalStateException.class) + .hasMessage("GitHub authentication is disabled"); } @Test diff --git a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/UserIdentityFactoryImplTest.java b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/UserIdentityFactoryImplTest.java index 4755660dd41..09f03dbc5b0 100644 --- a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/UserIdentityFactoryImplTest.java +++ b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/UserIdentityFactoryImplTest.java @@ -19,9 +19,7 @@ */ package org.sonar.auth.github; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.server.authentication.UserIdentity; @@ -31,8 +29,6 @@ import static org.assertj.core.api.Assertions.assertThat; public class UserIdentityFactoryImplTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); private MapSettings settings = new MapSettings(new PropertyDefinitions(System2.INSTANCE, GitHubSettings.definitions())); private UserIdentityFactoryImpl underTest = new UserIdentityFactoryImpl(); |