08-02-2023, 07:22 AM
I use `org.springframework.security.core.Authentication` which has a method:
Collection<? extends GrantedAuthority> getAuthorities();
I want to mock it as below:
when(authentication.getAuthorities()).thenReturn(grantedAuthorities);
with authorities collection:
Collection<SimpleGrantedAuthority> grantedAuthorities = Lists.newArrayList(
new SimpleGrantedAuthority(AuthoritiesConstants.USER));
And I am using `org.springframework.security.core.authority.SimpleGrantedAuthority` which extends `GrantedAuthority`
And Intellij gives me below compile error:
Cannot resolve method 'thenReturn(java.util.Collection<org.spring.security.core.authority.SimpleGrantedAuthority>)'
I use Mockito `2.15.0` and `thenReturn()` method from it is:
OngoingStubbing<T> thenReturn(T value);
What is the problem?
Collection<? extends GrantedAuthority> getAuthorities();
I want to mock it as below:
when(authentication.getAuthorities()).thenReturn(grantedAuthorities);
with authorities collection:
Collection<SimpleGrantedAuthority> grantedAuthorities = Lists.newArrayList(
new SimpleGrantedAuthority(AuthoritiesConstants.USER));
And I am using `org.springframework.security.core.authority.SimpleGrantedAuthority` which extends `GrantedAuthority`
And Intellij gives me below compile error:
Cannot resolve method 'thenReturn(java.util.Collection<org.spring.security.core.authority.SimpleGrantedAuthority>)'
I use Mockito `2.15.0` and `thenReturn()` method from it is:
OngoingStubbing<T> thenReturn(T value);
What is the problem?