<commit_before>Fixture Factory - generator to create fake objects from a template
================================================================== 

### [Mailing list](http://groups.google.com/group/fixture-factory)

### Installing

First clone and install projects:
	[bfgex](https://github.com/douglasrodrigo/bfgex)
	[jchronic](https://github.com/samtingleff/jchronic)

Clone fixture-factory project and install in your local repository
 
	$ mvn clean install

Use it like a maven dependency on your project

	<dependency>
		<groupId>br.com.fixturefactory</groupId>
		<artifactId>fixture-factory</artifactId>
		<version>1.1.0</version>
	</dependency>

### Usage

Writing bean template rules

	Fixture.of(Client.class).addTemplate("valid", new Rule(){{
		add("id", random(Long.class, range(1L, 200L)));
		add("name", random("<NAME>", "<NAME>"));
		add("nickname", random("nerd", "geek"));
		add("email", <EMAIL>");
		add("birthday", instant("18 years ago"));
		add("address", fixture(Address.class, "valid"));
	}});

	Fixture.of(Address.class).addTemplate("valid", 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"));
	}}); 

Gimme one object of valid label

	Client client = Fixture.of(Client.class).gimme("valid");

Gimme N objects of valid label

	List<Client> clients = Fixture.of(Client.class).gimme(5, "valid");

More helpers functions for create generic template:

#### Regex

	Fixture.of(Any.class).addTemplate("valid", new Rule(){{
	        add("id", regex("\\d{3,5}"));
	        add("phoneNumber", regex("(\\d{2})-(\\d{4})-(\\d{4})"));
	});

#### Date

	Fixture.of(Any.class).addTemplate("valid", new Rule(){{
		add("dueDate", beforeDate("2011-04-15", new SimpleDateFormat("yyyy-MM-dd")));
		add("payDate", afterDate("2011-04-15", new SimpleDateFormat("yyyy-MM-dd")));
		add("birthday", randomDate("2011-04-15", "2011-11-07", new SimpleDateFormat("yyyy-MM-dd")));
		add("cutDate", instant("now"));
	});

#### Name
<commit_msg>example new features of relationship<commit_after>Fixture Factory - generator to create fake objects from a template
================================================================== 

### [Mailing list](http://groups.google.com/group/fixture-factory)

### Installing

First clone and install projects:
	[bfgex](https://github.com/douglasrodrigo/bfgex)
	[jchronic](https://github.com/samtingleff/jchronic)

Clone fixture-factory project and install in your local repository
 
	$ mvn clean install

Use it like a maven dependency on your project

	<dependency>
		<groupId>br.com.fixturefactory</groupId>
		<artifactId>fixture-factory</artifactId>
		<version>1.2.1</version>
	</dependency>

### Usage

Writing bean template rules

	Fixture.of(Client.class).addTemplate("valid", new Rule(){{
		add("id", random(Long.class, range(1L, 200L)));
		add("name", random("<NAME>", "<NAME>"));
		add("nickname", random("nerd", "geek"));
		add("email", <EMAIL>");
		add("birthday", instant("18 years ago"));
		add("address", fixture(Address.class, "valid"));
	}});

	Fixture.of(Address.class).addTemplate("valid", 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"));
	}}); 

Gimme one object of valid label

	Client client = Fixture.of(Client.class).gimme("valid");

Gimme N objects of valid label

	List<Client> clients = Fixture.of(Client.class).gimme(5, "valid");

More helpers functions for create generic template:

#### Relationship (one-to-one and one-to-many)

	Fixture.of(Order.class).addTemplate("valid", new Rule(){{
		add("id", random(Long.class, range(1L, 200L)));
		add("items", has(3).of(Item.class, "valid"));
		add("payment", one(Payment.class, "valid"));
	}});

	Fixture.of(Item.class).addTemplate("valid", new Rule(){{
		add("productId", random(Integer.class, range(1L, 200L)));
	}});

	Fixture.of(Payment.class).addTemplate("valid", new Rule(){{
		add("id", random(Long.class, range(1L, 200L)));
	}});

#### Regex

	Fixture.of(Any.class).addTemplate("valid", new Rule(){{
	        add("id", regex("\\d{3,5}"));
	        add("phoneNumber", regex("(\\d{2})-(\\d{4})-(\\d{4})"));
	});

#### Date

	Fixture.of(Any.class).addTemplate("valid", new Rule(){{
		add("dueDate", beforeDate("2011-04-15", new SimpleDateFormat("yyyy-MM-dd")));
		add("payDate", afterDate("2011-04-15", new SimpleDateFormat("yyyy-MM-dd")));
		add("birthday", randomDate("2011-04-15", "2011-11-07", new SimpleDateFormat("yyyy-MM-dd")));
		add("cutDate", instant("now"));
	});

#### Name

{'fraction_non_alphanumeric': 0.23396304753996264, 'fraction_numerical': 0.030516919244342952, 'mean_word_length': 5.484522207267833, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '999576', 'n_tokens_mistral': 1795, 'n_tokens_neox': 1590, 'n_words': 337}