six2six/fixture-factory — pull request #67 by viniciusffj (2014-11-28 00:08:57+00:00)
Title: Unique option in one-to-many relationship

Pull request for issue https://github.com/six2six/fixture-factory/issues/65.

#### Usage

Just call unique() after has(n) in template definition:

```Java
Fixture.of(Programmer.class).addTemplate("valid", new Rule() {{
add("name", firstName());
add("skills", has(2).unique().of(Skill.class, "valid"));
}});

Fixture.of(Skill.class).addTemplate("valid", new Rule() {{
add("name", random("Java", "JavaScript"));
}});
```

It is possible to pass to `unique` the maximum times to try generating a unique value (the default is 10):

```Java
Fixture.of(Programmer.class).addTemplate("valid_custom_retry", new Rule() {{
add("name", firstName());
add("skills", has(2).unique(8).of(Skill.class, "valid"));
}});

```