Код: Выделить всё
@Test
public void test_increaseUserScore_Successful() throws CannotCreateCachedUserException {
when(cachedUserRepository
.existsById(anyLong())
).thenReturn(true);
when(leaderboardInfoRepository
.findById(anyString())
).thenReturn(Optional.of(testLeaderboardInfo));
when(cachedUserRepository
.findById(anyLong())
).thenReturn(Optional.of(userCached));
when(stringRedisTemplate
.execute(
eq(mutableLeaderboardScript), //RedisScript
anyList(), // List with Keys
any(Object.class) // Object args... which does not match
)
).thenReturn("success");
leaderboardService.increaseUserScore(userScoreEvent);
verify(stringRedisTemplate, times(1))
.execute(eq(mutableLeaderboardScript), anyList(), any(Object.class));
}
Я либо принимаю исключение PotentialStuppingProblem:
Код: Выделить всё
org.mockito.exceptions.misusing.PotentialStubbingProblem:
Strict stubbing argument mismatch. Please check:
- this invocation of 'execute' method:
stringRedisTemplate.execute(
mutableLeaderboardScript,
[user_cached:11:dailyAttempts, user_cached:11:totalAttempts, leaderboard:lb-123:mutable, user_cached:11, global-leaderboard-stream, local-leaderboard-stream],
"11",
"10.0",
"5",
"2",
"[ZZ]",
"20",
"lb-123",
"ZZ"
);
- has following stubbing(s) with different arguments:
1. stringRedisTemplate.execute(null, [], null);
Подробнее здесь: https://stackoverflow.com/questions/798 ... -not-match
Мобильная версия