java - PodamFactory 没有设置带有注释的字段
问题描述
我正在为我的类做单元测试,我使用 PodamFactoryImpl 用虚拟数据填充对象。
问题:
似乎具有@NotEmpty(来自javax.validation.constraints)等注释的字段为NULL。
有什么方法可以配置 PodamFactoryImpl 实例来填充所有字段?(比如将其配置为忽略注释)
我的填充方法:
public static <T> T fillObject(Class<T> clazz) {
PodamFactory factory = new PodamFactoryImpl();
return factory.manufacturePojoWithFullData(clazz);
}
我可悲的例子 POJO:
public class Location {
@NotEmpty
private String tenant; //will be null
@NotEmpty
private String serviceName; //will be null
@NotNull
private List<LocationData> locations; //will be with value
@NotNull
private Boolean async; //will be with value
@NotNull
private Long companyIndex; //will be with value
@NotEmpty
private String topicId; //will also be null
}
解决方案
你将升级神器版本
<dependency>
<groupId>uk.co.jemos.podam</groupId>
<artifactId>podam</artifactId>
<version>7.2.6.RELEASE</version>
<scope>test</scope>
</dependency>
推荐阅读
- python - 使用 SpaCy 从德语句子中提取主从句
- xamarin - 以编程方式使用 webview 打印 uwp 应用程序
- python - matmul:输入操作数 1 的核心维度 0 不匹配,带有 gufunc 签名 (n?,k),(k,m?)->(n?,m?)(大小 5 与 1 不同)
- python - 人脸识别中的增量学习
- json - 这个 JSON 响应顶部的 `)]}'` 有什么作用?
- reactjs - 如何修复 Jest 错误:ReferenceError: regeneratorRuntime 未定义
- mysql - 选择多个值
- c# - 发送带有内嵌图像的电子邮件时出现问题
- es6-promise - Modernizr 异步测试
- python - 如何通过 Beautiful Soup 过滤雅虎财经数据