是否有工具从模型(pojo)生成样本对象?我无法找到任何内容,可能使用了错误的搜索字词。
更详细的问题: 我有一个模型,例如(为了更好的可读性,删除了getter / setter / constr):
public class SomeModel {
private String name;
private String password;
private AnotherModel anotherModel;
}
public class AnotherModel {
private String foo;
private int bar;
}
有没有办法生成对象(或代码)以递归方式对模型进行填充?因此,工具或库可以执行以下任一操作:
new SomeModel("randomText", "randomText2", new AnotherModel("randomText3", 42))
new SomeModel("randomText4", "randomText5", new AnotherModel("randomText6", 42))
//... as many as I want
new SomeModel("randomTextN", "randomTextN", new AnotherModel("randomTextN", 42))
//or:
MockMyData<SomeModel> mocker = new MockMyData<SomeModel>()
mocker.generate()