six2six / fixture-factory

Generator fake objects from a template
Apache License 2.0
445 stars 88 forks source link

Default template #4

Closed aparra closed 11 years ago

aparra commented 12 years ago

Create default template that allows override properties. Example:

Fixture.of(Address.class).addTemplate("sao_paulo", new Rule(){{ add("id", random(Long.class, range(1L, 100L))); add("street", random("Paulista Avenue", "Ibirapuera Avenue")); add("city", "São Paulo"); add("state", "${city}"); add("country", "Brazil"); add("zipCode", random("06608000", "17720000")); }});

otherwise extends the sao_paulo template:

Fixture.of(Address.class).addTemplate("barueri").extends("sao_paulo", new Rule(){{ add("city", "Barueri"); add("state", "Sao Paulo"); }});