diff options
Diffstat (limited to 'server/sonar-auth-common/src')
-rw-r--r-- | server/sonar-auth-common/src/test/java/org/sonar/auth/OAuthRestClientTest.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/server/sonar-auth-common/src/test/java/org/sonar/auth/OAuthRestClientTest.java b/server/sonar-auth-common/src/test/java/org/sonar/auth/OAuthRestClientTest.java index 02730651fc5..6488c491d90 100644 --- a/server/sonar-auth-common/src/test/java/org/sonar/auth/OAuthRestClientTest.java +++ b/server/sonar-auth-common/src/test/java/org/sonar/auth/OAuthRestClientTest.java @@ -32,20 +32,16 @@ import okhttp3.mockwebserver.MockWebServer; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import static java.lang.String.format; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; 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.sonar.auth.OAuthRestClient.executePaginatedRequest; import static org.sonar.auth.OAuthRestClient.executeRequest; public class OAuthRestClientTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule public MockWebServer mockWebServer = new MockWebServer(); @@ -77,10 +73,9 @@ public class OAuthRestClientTest { public void fail_to_execute_request() throws IOException { mockWebServer.enqueue(new MockResponse().setResponseCode(404).setBody("Error!")); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage(format("Fail to execute request '%s/test'. HTTP code: 404, response: Error!", serverUrl)); - - executeRequest(serverUrl + "/test", oAuth20Service, auth2AccessToken); + assertThatThrownBy(() -> executeRequest(serverUrl + "/test", oAuth20Service, auth2AccessToken)) + .isInstanceOf(IllegalStateException.class) + .hasMessage(format("Fail to execute request '%s/test'. HTTP code: 404, response: Error!", serverUrl)); } @Test @@ -135,10 +130,9 @@ public class OAuthRestClientTest { .setBody("A")); mockWebServer.enqueue(new MockResponse().setResponseCode(404).setBody("Error!")); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage(format("Fail to execute request '%s/test?per_page=100&page=2'. HTTP code: 404, response: Error!", serverUrl)); - - executePaginatedRequest(serverUrl + "/test", oAuth20Service, auth2AccessToken, Arrays::asList); + assertThatThrownBy(() -> executePaginatedRequest(serverUrl + "/test", oAuth20Service, auth2AccessToken, Arrays::asList)) + .isInstanceOf(IllegalStateException.class) + .hasMessage(format("Fail to execute request '%s/test?per_page=100&page=2'. HTTP code: 404, response: Error!", serverUrl)); } private class TestAPI extends DefaultApi20 { |