mardi 31 mars 2015

A Java function to Generate Mock data CODE by taking a Java Object

Is there a Java function to Generate Mock data CODE by taking a Java Object? The output uses the existing setter but not constructor. Say such a function named void Generate(Class<T> klazz)



Generate(person);//person is a POJO with data in it.


This will sysout the following in stdout.



Person mockPerson = new Person;
mockPerson.setName("name");
mockPerson.setAge(1);


I believe this may take advantage of Java Reflection.






Aucun commentaire:

Enregistrer un commentaire