From 97ec5c921e08d9977605b5747e517124ce01e3f5 Mon Sep 17 00:00:00 2001 From: Mario Petrovski Date: Wed, 13 Sep 2023 15:08:31 +0200 Subject: [PATCH] Fix imports in tests --- .../core/OAuth2AuthorizationManagersTests.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/OAuth2AuthorizationManagersTests.java b/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/OAuth2AuthorizationManagersTests.java index 4b833fdd42..b436423d9b 100644 --- a/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/OAuth2AuthorizationManagersTests.java +++ b/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/OAuth2AuthorizationManagersTests.java @@ -19,8 +19,8 @@ package org.springframework.security.oauth2.core; import org.junit.jupiter.api.Test; import org.springframework.security.authorization.AuthorityAuthorizationManager; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThat; /** * Tests for {@link OAuth2AuthorizationManagers} @@ -32,27 +32,29 @@ public class OAuth2AuthorizationManagersTests { @Test void hasScope_withInvalidScope_shouldThrowIllegalArgumentException() { String scope = "SCOPE_invalid"; - assertThrows(IllegalArgumentException.class, () -> OAuth2AuthorizationManagers.hasScope(scope)); + assertThatThrownBy(() -> OAuth2AuthorizationManagers.hasScope(scope)) + .isInstanceOf(IllegalArgumentException.class); } @Test void hasScopes_withInvalidScope_shouldThrowIllegalArgumentException() { String[] scopes = { "read", "write", "SCOPE_invalid" }; - assertThrows(IllegalArgumentException.class, () -> OAuth2AuthorizationManagers.hasAnyScope(scopes)); + assertThatThrownBy(() -> OAuth2AuthorizationManagers.hasAnyScope(scopes)) + .isInstanceOf(IllegalArgumentException.class); } @Test void hasScope_withValidScope_shouldPass() { String scope = "read"; AuthorityAuthorizationManager authorizationManager = OAuth2AuthorizationManagers.hasScope(scope); - assertNotNull(authorizationManager); + assertThat(authorizationManager).isNotNull(); } @Test void hasScope_withValidScopes_shouldPass() { String[] scopes = { "read", "write" }; AuthorityAuthorizationManager authorizationManager = OAuth2AuthorizationManagers.hasAnyScope(scopes); - assertNotNull(authorizationManager); + assertThat(authorizationManager).isNotNull(); } }