java - 使用 Java 和 Mocking 测试在 Azure 存储中测试实体
问题描述
很久以来,我一直在寻找一种方法来测试Azure 表存储中文件中的实体(添加属性、值..) 。例如,在向实体添加属性后,我想通过测试检查属性是否成功添加(完全使用模拟测试),但问题是我不想在云中的Azure 存储中进行测试一个模拟器,我只想在本地测试它。我没有办法做到这一点。
TableServiceClient tableServiceClient = mock(TableServiceClient.class);
TableClient tableClient = mock(TableClient.class);
TableEntity tableEntity = mock(TableEntity .class);
properties is a Hash map of properties and values
when(tableEntity.addProperties(properties)).thenCallRealMethod();
when(tableEntity.getProperty(Mockito.anyString())).thenCallRealMethod();
doNothing().when(tableServiceClient.createTableIfNotExists(Mockito.anyString());
when(tableServiceClient.getTableClient(Mockito.anyString()).thenReturn(tableClient);
解决方案
推荐阅读
- mysql - Mysql Gap-lock/Next-key 锁的规则
- sonarqube - Sonarqube - 什么是规则键?
- c# - 从按日期分组的数据表中获取记录(日期间隔)
- amazon-web-services - 亚马逊 RDS 升级
- ios - 当表格视图单元格中的条件更改时,自动布局约束中断
- apache-kafka - Kafka Connect AWS Lambda 接收器
- ruby - Distinct 不适用于 select 子句
- mysql - cpanel共享主机上的Laravel找不到驱动程序
- ios - 如何在后台将视频文件上传到 AWS?
- docker - 无法在 docker Alpine 中安装 LibreOffice