私信  •  关注

i.bondarenko

i.bondarenko 最近回复了
4 年前
回复了 i.bondarenko 创建的主题 » 由于rabbitmq producer导致的junit/mockito错误

你需要添加 matchRepo.findById(...) expection,否则mock将返回null,并且您的测试在 if (matchObj.isPresent()) 是的。

请尝试以下代码:

when(matchRepo.findById(match.getId())).thenReturn(Optional.empty());
when(matchRepo.save(match)).thenReturn(match);