kotlin - Kotlin Mock Fuel HTTP 响应使用 Mockito
问题描述
我正在尝试使用 Mockito 模拟 Fuel HTTP 响应,如下所示:
val client = mock<Client> {
on { executeRequest(any()) } doReturn Response(
statusCode = 200,
responseMessage = response,
url = URL("https://www.mydomain.test")
)
}
但是,我遇到了反序列化的问题:
Error while communicating with x: No content to map due to end-of-input
at [Source: (BufferedInputStream); line: 1, column: 0]
java.lang.RuntimeException: Error while communicating with x: No content to map due to end-of-input
at [Source: (BufferedInputStream); line: 1, column: 0]
我已将 responseMessage 设置为非空字符串,因此不确定为什么会发生这种情况。我正在使用 Fuel 版本 > 2.0。
解决方案
推荐阅读
- python - 使用 BeautifulSoup 抓取 PowerBI 表
- .net - .net core api 中的 URL 解析
- python - 如何读取多个数据集,并创建具有年份列的单个数据框
- c# - 使用 NAudio 读取包含作品音频的 MemoryStream
- python - Python 无法打开程序:加载组件时出错
- python - 如何一次有效地运行多个 Pytorch 进程/模型?Traceback:分页文件太小,无法完成此操作
- python - 无法在 django 项目中创建过滤器
- reactjs - 如何使用 SpeedDial 上传文件?
- python - Numpy - 有没有办法指定广播维度?
- python - 如何将 3D 数组的 python 列表转换为特定形状的单个 3D 数组?