2

我正在为我的类做单元测试,我使用 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
}
4

1 回答 1

0

你将升级神器版本

 <dependency>
    <groupId>uk.co.jemos.podam</groupId>
    <artifactId>podam</artifactId>
    <version>7.2.6.RELEASE</version>
    <scope>test</scope>
</dependency>
于 2021-03-09T12:14:17.597 回答