openrewrite Junit Migration

This commit is contained in:
Rob Winch
2021-07-08 14:52:28 -05:00
parent 8652f01269
commit 3e93b024d6
999 changed files with 3088 additions and 3092 deletions

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -23,8 +23,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatObject;
@@ -40,7 +40,7 @@ public class ClaimAccessorTests {
private ClaimAccessor claimAccessor = (() -> this.claims);
@Before
@BeforeEach
public void setup() {
this.claims.clear();
}

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -20,7 +20,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;

View File

@@ -19,7 +19,7 @@ package org.springframework.security.oauth2.core;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -21,7 +21,7 @@ import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.util.SerializationUtils;

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -18,7 +18,7 @@ package org.springframework.security.oauth2.core;
import java.time.Instant;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -29,7 +29,7 @@ import java.util.Map;
import com.nimbusds.jose.shaded.json.JSONArray;
import com.nimbusds.jose.shaded.json.JSONObject;
import org.assertj.core.util.Lists;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.ConversionService;

View File

@@ -27,8 +27,8 @@ import com.nimbusds.jose.shaded.json.JSONArray;
import com.nimbusds.jose.shaded.json.JSONObject;
import org.assertj.core.util.Lists;
import org.assertj.core.util.Maps;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.Converter;
@@ -64,7 +64,7 @@ public class ClaimTypeConverterTests {
private ClaimTypeConverter claimTypeConverter;
@Before
@BeforeEach
@SuppressWarnings("unchecked")
public void setup() {
Converter<Object, ?> stringConverter = getConverter(TypeDescriptor.valueOf(String.class));

View File

@@ -22,9 +22,9 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.converter.Converter;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
@@ -39,7 +39,7 @@ public class DefaultMapOAuth2AccessTokenResponseConverterTests {
private Converter<Map<String, ?>, OAuth2AccessTokenResponse> messageConverter;
@Before
@BeforeEach
public void setup() {
this.messageConverter = new DefaultMapOAuth2AccessTokenResponseConverter();
}
@@ -56,23 +56,23 @@ public class DefaultMapOAuth2AccessTokenResponseConverterTests {
map.put("custom_parameter_2", "custom-value-2");
OAuth2AccessTokenResponse converted = this.messageConverter.convert(map);
OAuth2AccessToken accessToken = converted.getAccessToken();
Assert.assertNotNull(accessToken);
Assert.assertEquals("access-token-1234", accessToken.getTokenValue());
Assert.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Assertions.assertNotNull(accessToken);
Assertions.assertEquals("access-token-1234", accessToken.getTokenValue());
Assertions.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Set<String> scopes = accessToken.getScopes();
Assert.assertNotNull(scopes);
Assert.assertEquals(2, scopes.size());
Assert.assertTrue(scopes.contains("read"));
Assert.assertTrue(scopes.contains("write"));
Assert.assertEquals(3600, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
Assertions.assertNotNull(scopes);
Assertions.assertEquals(2, scopes.size());
Assertions.assertTrue(scopes.contains("read"));
Assertions.assertTrue(scopes.contains("write"));
Assertions.assertEquals(3600, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
OAuth2RefreshToken refreshToken = converted.getRefreshToken();
Assert.assertNotNull(refreshToken);
Assert.assertEquals("refresh-token-1234", refreshToken.getTokenValue());
Assertions.assertNotNull(refreshToken);
Assertions.assertEquals("refresh-token-1234", refreshToken.getTokenValue());
Map<String, Object> additionalParameters = converted.getAdditionalParameters();
Assert.assertNotNull(additionalParameters);
Assert.assertEquals(2, additionalParameters.size());
Assert.assertEquals("custom-value-1", additionalParameters.get("custom_parameter_1"));
Assert.assertEquals("custom-value-2", additionalParameters.get("custom_parameter_2"));
Assertions.assertNotNull(additionalParameters);
Assertions.assertEquals(2, additionalParameters.size());
Assertions.assertEquals("custom-value-1", additionalParameters.get("custom_parameter_1"));
Assertions.assertEquals("custom-value-2", additionalParameters.get("custom_parameter_2"));
}
@Test
@@ -82,18 +82,18 @@ public class DefaultMapOAuth2AccessTokenResponseConverterTests {
map.put("token_type", "bearer");
OAuth2AccessTokenResponse converted = this.messageConverter.convert(map);
OAuth2AccessToken accessToken = converted.getAccessToken();
Assert.assertNotNull(accessToken);
Assert.assertEquals("access-token-1234", accessToken.getTokenValue());
Assert.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Assertions.assertNotNull(accessToken);
Assertions.assertEquals("access-token-1234", accessToken.getTokenValue());
Assertions.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Set<String> scopes = accessToken.getScopes();
Assert.assertNotNull(scopes);
Assert.assertEquals(0, scopes.size());
Assert.assertEquals(1, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
Assertions.assertNotNull(scopes);
Assertions.assertEquals(0, scopes.size());
Assertions.assertEquals(1, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
OAuth2RefreshToken refreshToken = converted.getRefreshToken();
Assert.assertNull(refreshToken);
Assertions.assertNull(refreshToken);
Map<String, Object> additionalParameters = converted.getAdditionalParameters();
Assert.assertNotNull(additionalParameters);
Assert.assertEquals(0, additionalParameters.size());
Assertions.assertNotNull(additionalParameters);
Assertions.assertEquals(0, additionalParameters.size());
}
@Test
@@ -104,18 +104,18 @@ public class DefaultMapOAuth2AccessTokenResponseConverterTests {
map.put("expires_in", "2100-01-01-abc");
OAuth2AccessTokenResponse converted = this.messageConverter.convert(map);
OAuth2AccessToken accessToken = converted.getAccessToken();
Assert.assertNotNull(accessToken);
Assert.assertEquals("access-token-1234", accessToken.getTokenValue());
Assert.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Assertions.assertNotNull(accessToken);
Assertions.assertEquals("access-token-1234", accessToken.getTokenValue());
Assertions.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Set<String> scopes = accessToken.getScopes();
Assert.assertNotNull(scopes);
Assert.assertEquals(0, scopes.size());
Assert.assertEquals(1, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
Assertions.assertNotNull(scopes);
Assertions.assertEquals(0, scopes.size());
Assertions.assertEquals(1, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
OAuth2RefreshToken refreshToken = converted.getRefreshToken();
Assert.assertNull(refreshToken);
Assertions.assertNull(refreshToken);
Map<String, Object> additionalParameters = converted.getAdditionalParameters();
Assert.assertNotNull(additionalParameters);
Assert.assertEquals(0, additionalParameters.size());
Assertions.assertNotNull(additionalParameters);
Assertions.assertEquals(0, additionalParameters.size());
}
// gh-9685
@@ -127,10 +127,10 @@ public class DefaultMapOAuth2AccessTokenResponseConverterTests {
map.put("expires_in", 3600);
OAuth2AccessTokenResponse converted = this.messageConverter.convert(map);
OAuth2AccessToken accessToken = converted.getAccessToken();
Assert.assertNotNull(accessToken);
Assert.assertEquals("access-token-1234", accessToken.getTokenValue());
Assert.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Assert.assertEquals(3600, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
Assertions.assertNotNull(accessToken);
Assertions.assertEquals("access-token-1234", accessToken.getTokenValue());
Assertions.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Assertions.assertEquals(3600, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
}
// gh-9685
@@ -149,23 +149,23 @@ public class DefaultMapOAuth2AccessTokenResponseConverterTests {
map.put("custom_parameter_2", "custom-value-2");
OAuth2AccessTokenResponse converted = this.messageConverter.convert(map);
OAuth2AccessToken accessToken = converted.getAccessToken();
Assert.assertNotNull(accessToken);
Assert.assertEquals("access-token-1234", accessToken.getTokenValue());
Assert.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Assertions.assertNotNull(accessToken);
Assertions.assertEquals("access-token-1234", accessToken.getTokenValue());
Assertions.assertEquals(OAuth2AccessToken.TokenType.BEARER, accessToken.getTokenType());
Set<String> scopes = accessToken.getScopes();
Assert.assertNotNull(scopes);
Assert.assertEquals(2, scopes.size());
Assert.assertTrue(scopes.contains("read"));
Assert.assertTrue(scopes.contains("write"));
Assert.assertEquals(3600, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
Assertions.assertNotNull(scopes);
Assertions.assertEquals(2, scopes.size());
Assertions.assertTrue(scopes.contains("read"));
Assertions.assertTrue(scopes.contains("write"));
Assertions.assertEquals(3600, Duration.between(accessToken.getIssuedAt(), accessToken.getExpiresAt()).getSeconds());
OAuth2RefreshToken refreshToken = converted.getRefreshToken();
Assert.assertNotNull(refreshToken);
Assert.assertEquals("refresh-token-1234", refreshToken.getTokenValue());
Assertions.assertNotNull(refreshToken);
Assertions.assertEquals("refresh-token-1234", refreshToken.getTokenValue());
Map<String, Object> additionalParameters = converted.getAdditionalParameters();
Assert.assertNotNull(additionalParameters);
Assert.assertEquals(2, additionalParameters.size());
Assert.assertEquals(nestedObject, additionalParameters.get("custom_parameter_1"));
Assert.assertEquals("custom-value-2", additionalParameters.get("custom_parameter_2"));
Assertions.assertNotNull(additionalParameters);
Assertions.assertEquals(2, additionalParameters.size());
Assertions.assertEquals(nestedObject, additionalParameters.get("custom_parameter_1"));
Assertions.assertEquals("custom-value-2", additionalParameters.get("custom_parameter_2"));
}
}

View File

@@ -22,9 +22,9 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.converter.Converter;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
@@ -38,7 +38,7 @@ public class DefaultOAuth2AccessTokenResponseMapConverterTests {
private Converter<OAuth2AccessTokenResponse, Map<String, Object>> messageConverter;
@Before
@BeforeEach
public void setup() {
this.messageConverter = new DefaultOAuth2AccessTokenResponseMapConverter();
}
@@ -61,14 +61,14 @@ public class DefaultOAuth2AccessTokenResponseMapConverterTests {
.build();
// @formatter:on
Map<String, Object> result = this.messageConverter.convert(build);
Assert.assertEquals(7, result.size());
Assert.assertEquals("access-token-value-1234", result.get("access_token"));
Assert.assertEquals("refresh-token-value-1234", result.get("refresh_token"));
Assert.assertEquals("read write", result.get("scope"));
Assert.assertEquals("Bearer", result.get("token_type"));
Assert.assertNotNull(result.get("expires_in"));
Assert.assertEquals("custom-value-1", result.get("custom_parameter_1"));
Assert.assertEquals("custom-value-2", result.get("custom_parameter_2"));
Assertions.assertEquals(7, result.size());
Assertions.assertEquals("access-token-value-1234", result.get("access_token"));
Assertions.assertEquals("refresh-token-value-1234", result.get("refresh_token"));
Assertions.assertEquals("read write", result.get("scope"));
Assertions.assertEquals("Bearer", result.get("token_type"));
Assertions.assertNotNull(result.get("expires_in"));
Assertions.assertEquals("custom-value-1", result.get("custom_parameter_1"));
Assertions.assertEquals("custom-value-2", result.get("custom_parameter_2"));
}
@Test
@@ -79,10 +79,10 @@ public class DefaultOAuth2AccessTokenResponseMapConverterTests {
.build();
// @formatter:on
Map<String, Object> result = this.messageConverter.convert(build);
Assert.assertEquals(3, result.size());
Assert.assertEquals("access-token-value-1234", result.get("access_token"));
Assert.assertEquals("Bearer", result.get("token_type"));
Assert.assertNotNull(result.get("expires_in"));
Assertions.assertEquals(3, result.size());
Assertions.assertEquals("access-token-value-1234", result.get("access_token"));
Assertions.assertEquals("Bearer", result.get("token_type"));
Assertions.assertNotNull(result.get("expires_in"));
}
// gh-9685
@@ -107,14 +107,14 @@ public class DefaultOAuth2AccessTokenResponseMapConverterTests {
.build();
// @formatter:on
Map<String, Object> result = this.messageConverter.convert(build);
Assert.assertEquals(7, result.size());
Assert.assertEquals("access-token-value-1234", result.get("access_token"));
Assert.assertEquals("refresh-token-value-1234", result.get("refresh_token"));
Assert.assertEquals("read write", result.get("scope"));
Assert.assertEquals("Bearer", result.get("token_type"));
Assert.assertNotNull(result.get("expires_in"));
Assert.assertEquals(nestedObject, result.get("custom_parameter_1"));
Assert.assertEquals("custom-value-2", result.get("custom_parameter_2"));
Assertions.assertEquals(7, result.size());
Assertions.assertEquals("access-token-value-1234", result.get("access_token"));
Assertions.assertEquals("refresh-token-value-1234", result.get("refresh_token"));
Assertions.assertEquals("read write", result.get("scope"));
Assertions.assertEquals("Bearer", result.get("token_type"));
Assertions.assertNotNull(result.get("expires_in"));
Assertions.assertEquals(nestedObject, result.get("custom_parameter_1"));
Assertions.assertEquals("custom-value-2", result.get("custom_parameter_2"));
}
}

View File

@@ -23,7 +23,7 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.security.oauth2.core.OAuth2AccessToken;

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core.endpoint;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -23,7 +23,7 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.security.oauth2.core.AuthorizationGrantType;

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core.endpoint;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core.endpoint;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -24,8 +24,8 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.converter.Converter;
import org.springframework.http.HttpStatus;
@@ -53,7 +53,7 @@ public class OAuth2AccessTokenResponseHttpMessageConverterTests {
private OAuth2AccessTokenResponseHttpMessageConverter messageConverter;
@Before
@BeforeEach
public void setup() {
this.messageConverter = new OAuth2AccessTokenResponseHttpMessageConverter();
}

View File

@@ -16,8 +16,8 @@
package org.springframework.security.oauth2.core.http.converter;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.converter.Converter;
import org.springframework.http.HttpStatus;
@@ -43,7 +43,7 @@ public class OAuth2ErrorHttpMessageConverterTests {
private OAuth2ErrorHttpMessageConverter messageConverter;
@Before
@BeforeEach
public void setup() {
this.messageConverter = new OAuth2ErrorHttpMessageConverter();
}

View File

@@ -19,7 +19,7 @@ package org.springframework.security.oauth2.core.oidc;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -18,7 +18,7 @@ package org.springframework.security.oauth2.core.oidc;
import java.time.Instant;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -16,7 +16,7 @@
package org.springframework.security.oauth2.core.oidc;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -21,7 +21,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;

View File

@@ -20,7 +20,7 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.security.oauth2.core.oidc.IdTokenClaimNames;
import org.springframework.security.oauth2.core.oidc.OidcIdToken;

View File

@@ -20,7 +20,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

View File

@@ -19,7 +19,7 @@ package org.springframework.security.oauth2.core.user;
import java.util.Collections;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -23,8 +23,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
import org.springframework.core.codec.ByteBufferDecoder;
@@ -56,7 +56,7 @@ public class OAuth2BodyExtractorsTests {
private Map<String, Object> hints;
@Before
@BeforeEach
public void createContext() {
final List<HttpMessageReader<?>> messageReaders = new ArrayList<>();
messageReaders.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder()));