【发布时间】:2018-12-12 14:03:21
【问题描述】:
我使用org.springframework.security.core.Authentication,它有一个方法:
Collection<? extends GrantedAuthority> getAuthorities();
我想模拟如下:
when(authentication.getAuthorities()).thenReturn(grantedAuthorities);
与当局收集:
Collection<SimpleGrantedAuthority> grantedAuthorities = Lists.newArrayList(
new SimpleGrantedAuthority(AuthoritiesConstants.USER));
我使用的是org.springframework.security.core.authority.SimpleGrantedAuthority,它扩展了GrantedAuthority
Intellij 给了我下面的编译错误:
Cannot resolve method 'thenReturn(java.util.Collection<org.spring.security.core.authority.SimpleGrantedAuthority>)'
我使用 Mockito 2.15.0 和 thenReturn() 方法是:
OngoingStubbing<T> thenReturn(T value);
有什么问题?
【问题讨论】:
标签: spring junit spring-security mockito