gpt4 book ai didi

java - org.mockito.exceptions.misusing.InvalidUseOfMatchersException 当我没有匹配器时

转载 作者:行者123 更新时间:2023-11-28 20:42:53 24 4
gpt4 key购买 nike

我尝试模拟一个方法:

    PermissionsChecker checker = mock(PermissionsChecker.class);
mockDoesUSerHasPermissions(checker, trustedUser, true);
mockDoesUSerHasPermissions(checker, nonTrustedUser, false);



private void mockDoesUSerHasPermissions(PermissionsChecker checker, UserInfo userInfo, boolean doesHasPermissions) {
when(checker.doesUserHavePermissions(Mockito.any(Venue3.class), Mockito.any(Venue3.class), userInfo, Mockito.any(ActionType.class))).thenReturn(doesHasPermissions);
}

但我收到以下错误,我无法理解它与我的代码有何关系:

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 
Invalid use of argument matchers!
4 matchers expected, 3 recorded:

This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));

For more info see javadoc for Matchers class.

最佳答案

如错误所述,您使用了原始值和匹配器的组合。 userInfo 是原始值

关于java - org.mockito.exceptions.misusing.InvalidUseOfMatchersException 当我没有匹配器时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25185217/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com