-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Remove unused imports and fixes some compile time errors for some tests #4934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unused imports and fixes some compile time errors for some tests #4934
Conversation
when: | ||
UserDetails userDetails = new UserDetailsManagerConfigurer<InMemoryUserDetailsManager,UserDetailsManagerConfigurer<InMemoryUserDetailsManager>>(userDetailsManager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are suppose to be validating UserDetailsManagerConfigurer
not InMemoryUserDetailsManagerConfigurer
. Is there a reason you switched this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact I did a mistake here. But rather than parameterizing UserDetailsManagerConfigurer
with InMemoryUserDetailsManager
I think it should be better to use AuthenticationManagerBuilder
as follows (for the first parameter):
UserDetails userDetails = new UserDetailsManagerConfigurer<AuthenticationManagerBuilder,
InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder>>(userDetailsManager)
That's because as the first generic parameter type for UserDetailsManagerConfigurer
which is B
extends ProviderManagerBuilder
, I realized that it should make sense to use AuthenticationManagerBuilder
.
If I keep using InMemoryUserDetailsManager
for the first generic parameter type, I got the following error on STS:
Groovy:The type InMemoryUserDetailsManager is not a valid substitute
for the bounded parameter
<B extends org.springframework.security.config
.annotation.authentication.ProviderManagerBuilder<B>>
I made the changes to use AuthenticationManagerBuilder
as proposed but did not pushed yet just to preserve our conversation here. If you think it makes sense to be applied I can submit the changes.
public void loadUserWhenUserRequestIsNullThenThrowIllegalArgumentException() { | ||
DelegatingOAuth2UserService<OAuth2UserRequest, OAuth2User> delegatingUserService = | ||
new DelegatingOAuth2UserService<>( | ||
Arrays.asList(mock(OAuth2UserService.class), mock(OAuth2UserService.class))); | ||
Arrays.asList(mock(DefaultOAuth2UserService.class), mock(DefaultOAuth2UserService.class))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of this test is to ensure that the OAuth2UserRequest
passed into loadUser
is not null else throw IllegalArgumentException
. Changing the List
of OAuth2UserService
mocks to DefaultOAuth2UserService
doesn't really apply to what is being tested here. Please revert this. Thank you.
Closing in favor of #4949 |
Remove invalid imports referencing
org.springframework.security.config.annotation.authentication.AuthenticationManagerBuilder
.Change the way to use
contains
method fromAsssertions
class from Assertj. When checkingfor a concrete class against a generic collection, Eclipse and IntelliJ were presenting compiling time errors. There is an issue regarding the usage of generic types on
contains
method fromAssertions
class as follows:assertj/assertj#772
DelegatingOAuth2UserServiceTests
to start using concrete types to create theArrayList
of services that are needed to create an instance ofDelegatingOAuth2UserService
.