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-saml | |
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-saml')
-rw-r--r-- | server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlSettingsTest.java | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlSettingsTest.java b/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlSettingsTest.java index df260abe40f..89d35c7554c 100644 --- a/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlSettingsTest.java +++ b/server/sonar-auth-saml/src/test/java/org/sonar/auth/saml/SamlSettingsTest.java @@ -22,21 +22,18 @@ package org.sonar.auth.saml; import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; import com.tngtech.java.junit.dataprovider.UseDataProvider; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.utils.System2; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; @RunWith(DataProviderRunner.class) public class SamlSettingsTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); private MapSettings settings = new MapSettings(new PropertyDefinitions(System2.INSTANCE, SamlSettings.definitions())); @@ -177,42 +174,37 @@ public class SamlSettingsTest { @Test public void fail_to_get_provider_id_when_null() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Provider ID is missing"); - - underTest.getProviderId(); + assertThatThrownBy(() -> underTest.getProviderId()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Provider ID is missing"); } @Test public void fail_to_get_login_url_when_null() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Login URL is missing"); - - underTest.getLoginUrl(); + assertThatThrownBy(() -> underTest.getLoginUrl()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Login URL is missing"); } @Test public void fail_to_get_certificate_when_null() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Certificate is missing"); - - underTest.getCertificate(); + assertThatThrownBy(() -> underTest.getCertificate()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Certificate is missing"); } @Test public void fail_to_get_user_login_attribute_when_null() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("User login attribute is missing"); - - underTest.getUserLogin(); + assertThatThrownBy(() -> underTest.getUserLogin()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("User login attribute is missing"); } @Test public void fail_to_get_user_name_attribute_when_null() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("User name attribute is missing"); - - underTest.getUserName(); + assertThatThrownBy(() -> underTest.getUserName()) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("User name attribute is missing"); } private void initAllSettings() { |