Код: Выделить всё
@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),
anyList(),
any(Object.class)
)
).thenReturn("success");
leaderboardService.increaseUserScore(userScoreEvent);
verify(stringRedisTemplate, times(1))
.execute(eq(mutableLeaderboardScript), anyList(), any(Object.class));
}
Код: Выделить всё
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"
);
-> at com.jzargo.leaderboardmicroservice.service.LeaderboardServiceImpl.executeScoreChange(LeaderboardServiceImpl.java:139)
- has following stubbing(s) with different arguments:
1. stringRedisTemplate.execute(null, [], null);
-> at com.jzargo.leaderboardmicroservice.unit.LeaderboardServiceUnitTest.test_increaseUserScore_Successful
Подробнее здесь: https://stackoverflow.com/questions/798 ... -not-match