Skip to content

Instantly share code, notes, and snippets.

@diego-aslz
Last active December 18, 2015 22:39
Show Gist options
  • Save diego-aslz/5855760 to your computer and use it in GitHub Desktop.
Save diego-aslz/5855760 to your computer and use it in GitHub Desktop.
package factj.test;
import factj.FactJ;
public class Application {
public static void main(String[] args) {
PersonFabricator.load();
System.out.println(FactJ.build(Person.class));
System.out.println(FactJ.build(Person.class));
}
}
Person [id=1, name=Diego, [email protected]]
Person [id=2, name=Diego, [email protected]]
package factj.test;
import static factj.DSL.field;
import static factj.DSL.sequence;
import factj.Fabricator;
import factj.decorators.SequenceDecorator.Sequence;
public abstract class PersonFabricator extends Fabricator {
static {
Sequence emailSequence = new Sequence() {
@Override
public Object generate(int count) {
return "user" + count + "@company.com";
}
};
fabricate(Person.class,
sequence("id"),
field("name", "Diego"),
sequence("email", emailSequence));
}
public static void load() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment