bigtop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnowl...@apache.org
Subject [03/11] bigtop git commit: BIGTOP-1984. Extract samplers library from BigPetStore data generator
Date Tue, 25 Aug 2015 14:21:37 GMT
http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/TestProduct.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/TestProduct.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/TestProduct.java
new file mode 100644
index 0000000..313b725
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/datamodels/TestProduct.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.datamodels;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.junit.Test;
+
+import com.google.common.collect.Maps;
+
+public class TestProduct
+{
+
+	@Test
+	public void testString()
+	{
+		Map<String, Object> fields = Maps.newHashMap();
+		fields.put(Constants.PRODUCT_CATEGORY, "poop bags");
+		fields.put(Constants.PRODUCT_QUANTITY, 120);
+		fields.put("price", 12.80);
+
+		Product product = new Product(fields);
+
+		assertEquals(product.getFieldValueAsString(Constants.PRODUCT_CATEGORY), "poop bags");
+		assertEquals(product.getFieldValueAsString("price"), "12.8");
+		assertEquals(product.getFieldValueAsString(Constants.PRODUCT_QUANTITY), "120");
+	}
+
+	@Test
+	public void testDouble()
+	{
+		Map<String, Object> fields = Maps.newHashMap();
+		fields.put(Constants.PRODUCT_CATEGORY, "poop bags");
+		fields.put(Constants.PRODUCT_QUANTITY, 120);
+		fields.put("price", 12.80);
+
+		Product product = new Product(fields);
+
+		assertNull(product.getFieldValueAsDouble(Constants.PRODUCT_CATEGORY));
+		assertEquals(product.getFieldValueAsDouble("price"), 12.80, 1e-5);
+		assertNull(product.getFieldValueAsDouble(Constants.PRODUCT_QUANTITY));
+	}
+
+	@Test
+	public void testLong()
+	{
+		Map<String, Object> fields = Maps.newHashMap();
+		fields.put(Constants.PRODUCT_CATEGORY, "poop bags");
+		fields.put(Constants.PRODUCT_QUANTITY, 120);
+		fields.put("price", 12.80);
+
+		Product product = new Product(fields);
+
+		assertNull(product.getFieldValueAsLong(Constants.PRODUCT_CATEGORY));
+		assertNull(product.getFieldValueAsLong("price"));
+		assertEquals((long) product.getFieldValueAsLong(Constants.PRODUCT_QUANTITY), 120L);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerLocationPDF.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerLocationPDF.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerLocationPDF.java
new file mode 100644
index 0000000..60733a9
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerLocationPDF.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.customer;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.customer.CustomerLocationPDF;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Test;
+
+public class TestCustomerLocationPDF
+{
+
+	@Test
+	public void testProbability() throws Exception
+	{
+		List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+				new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+				new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+				new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300)
+				});
+
+		List<Store> stores = new ArrayList<Store>();
+		for(int i = 0; i < zipcodes.size(); i++)
+		{
+			Store store = new Store(i, "Store_" + i, zipcodes.get(i));
+			stores.add(store);
+		}
+
+		CustomerLocationPDF customerLocationPDF = new CustomerLocationPDF(zipcodes, stores.get(0),
+					Constants.AVERAGE_CUSTOMER_STORE_DISTANCE);
+
+		double prob = customerLocationPDF.probability(zipcodes.get(0));
+
+		assertTrue(prob > 0.0);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerSampler.java
new file mode 100644
index 0000000..8bb3c87
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerSampler.java
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.customer;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Customer;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.customer.CustomerLocationPDF;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.customer.CustomerSampler;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.pdfs.ProbabilityDensityFunction;
+import org.apache.bigtop.datagenerators.samplers.samplers.ConditionalSampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.RouletteWheelSampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.SequenceSampler;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Test;
+
+import com.google.common.collect.Maps;
+
+public class TestCustomerSampler
+{
+	protected ConditionalSampler<ZipcodeRecord, Store> buildLocationSampler(List<Store> stores, List<ZipcodeRecord> records,
+			SeedFactory factory)
+	{
+		final Map<Store, Sampler<ZipcodeRecord>> locationSamplers = Maps.newHashMap();
+		for(Store store : stores)
+		{
+			ProbabilityDensityFunction<ZipcodeRecord> locationPDF = new CustomerLocationPDF(records,
+					store, Constants.AVERAGE_CUSTOMER_STORE_DISTANCE);
+			Sampler<ZipcodeRecord> locationSampler = RouletteWheelSampler.create(records, locationPDF, factory);
+			locationSamplers.put(store, locationSampler);
+		}
+
+		return new ConditionalSampler<ZipcodeRecord, Store>()
+				{
+					public ZipcodeRecord sample(Store store) throws Exception
+					{
+						return locationSamplers.get(store).sample();
+					}
+				};
+	}
+
+	@Test
+	public void testBuild() throws Exception
+	{
+		SeedFactory factory = new SeedFactory(1234);
+
+		Collection<String> nameList = Arrays.asList(new String[] {"Fred", "Gary", "George", "Fiona"});
+		List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+				new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+				new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+				new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300)
+				});
+
+		List<Store> stores = new ArrayList<Store>();
+		for(int i = 0; i < zipcodes.size(); i++)
+		{
+			Store store = new Store(i, "Store_" + i, zipcodes.get(i));
+			stores.add(store);
+		}
+
+
+		Sampler<Integer> idSampler = new SequenceSampler();
+		Sampler<String> nameSampler = RouletteWheelSampler.createUniform(nameList, factory);
+		Sampler<Store> storeSampler = RouletteWheelSampler.createUniform(stores, factory);
+		ConditionalSampler<ZipcodeRecord, Store> zipcodeSampler = buildLocationSampler(stores, zipcodes, factory);
+
+		Sampler<Customer> sampler = new CustomerSampler(idSampler, nameSampler, nameSampler, storeSampler, zipcodeSampler);
+
+		Customer customer = sampler.sample();
+
+		assertNotNull(customer);
+		assertTrue(customer.getId() >= 0);
+		assertNotNull(customer.getName());
+		assertNotNull(customer.getName().getLeft());
+		assertTrue(nameList.contains(customer.getName().getLeft()));
+		assertNotNull(customer.getName().getRight());
+		assertTrue(nameList.contains(customer.getName().getRight()));
+		assertNotNull(customer.getLocation());
+		assertTrue(zipcodes.contains(customer.getLocation()));
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerSamplerBuilder.java
new file mode 100644
index 0000000..786c7fc
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/customer/TestCustomerSamplerBuilder.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.customer;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Customer;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.InputData;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.Names;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.customer.CustomerSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class TestCustomerSamplerBuilder
+{
+
+	@Test
+	public void testSample() throws Exception
+	{
+		Map<String, Double> nameList = ImmutableMap.of("Fred", 1.0, "George", 1.0, "Gary", 1.0, "Fiona", 1.0);
+		List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+				new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+				new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+				new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300)
+				});
+
+		Names names = new Names(nameList, nameList);
+
+		// don't need product categories for building customers
+		InputData inputData = new InputData(zipcodes, names);
+
+		List<Store> stores = Arrays.asList(new Store(0, "Store_0", zipcodes.get(0)),
+				new Store(1, "Store_1", zipcodes.get(1)),
+				new Store(2, "Store_2", zipcodes.get(2))
+				);
+
+		SeedFactory factory = new SeedFactory(1234);
+
+		CustomerSamplerBuilder builder = new CustomerSamplerBuilder(stores, inputData, factory);
+		Sampler<Customer> sampler = builder.build();
+
+		Customer customer = sampler.sample();
+
+		assertNotNull(customer);
+		assertTrue(customer.getId() >= 0);
+		assertNotNull(customer.getName());
+		assertNotNull(customer.getName().getLeft());
+		assertNotNull(customer.getName().getRight());
+		assertNotNull(customer.getLocation());
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/TestCartesianProductBase.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/TestCartesianProductBase.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/TestCartesianProductBase.java
new file mode 100644
index 0000000..6393b67
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/TestCartesianProductBase.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.products.cartesian;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.cartesian.CartesianProductBase;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestCartesianProductBase
+{
+	@Test
+	public void testNext()
+	{
+		Iterator<Map<String, Double>> iter = new CartesianProductBase<Double>("count",
+				Arrays.asList(1.0, 2.0, 3.0));
+
+		Assert.assertTrue(iter.hasNext());
+
+		Map<String, Double> map = iter.next();
+		Assert.assertEquals(1, map.size());
+		Assert.assertTrue(map.containsKey("count"));
+		Assert.assertEquals( (double) map.get("count"), (double) 1.0, 0.0001);
+
+		Assert.assertTrue(iter.hasNext());
+
+		map = iter.next();
+		Assert.assertEquals(1, map.size());
+		Assert.assertTrue(map.containsKey("count"));
+		Assert.assertEquals( (double) map.get("count"), (double) 2.0, 0.0001);
+
+		Assert.assertTrue(iter.hasNext());
+
+		map = iter.next();
+		Assert.assertEquals(1, map.size());
+		Assert.assertTrue(map.containsKey("count"));
+		Assert.assertEquals( (double) map.get("count"), (double) 3.0, 0.0001);
+
+		Assert.assertFalse(iter.hasNext());
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/TestCartesianProductField.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/TestCartesianProductField.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/TestCartesianProductField.java
new file mode 100644
index 0000000..b4a74f3
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/cartesian/TestCartesianProductField.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.products.cartesian;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.cartesian.CartesianProductBase;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.cartesian.CartesianProductField;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestCartesianProductField
+{
+
+	@Test
+	public void testTwoLevels()
+	{
+		Iterator<Map<String, String>> iter = new CartesianProductField<String>(
+				"children", Arrays.asList("1", "2"),
+					new CartesianProductBase<String>(
+							"animal", Arrays.asList("cat", "dog")));
+
+		Assert.assertEquals(iter.hasNext(), true);
+		Map<String, String> map = iter.next();
+		Assert.assertEquals(map.size(), 2);
+		Assert.assertTrue(map.containsKey("animal"));
+		Assert.assertTrue(map.containsKey("children"));
+		Assert.assertEquals(map.get("animal"), "cat");
+		Assert.assertEquals(map.get("children"), "1");
+
+		Assert.assertEquals(iter.hasNext(), true);
+		map = iter.next();
+		Assert.assertEquals(map.size(), 2);
+		Assert.assertTrue(map.containsKey("animal"));
+		Assert.assertTrue(map.containsKey("children"));
+		Assert.assertEquals(map.get("animal"), "cat");
+		Assert.assertEquals(map.get("children"), "2");
+
+		Assert.assertEquals(iter.hasNext(), true);
+		map = iter.next();
+		Assert.assertEquals(map.size(), 2);
+		Assert.assertTrue(map.containsKey("animal"));
+		Assert.assertTrue(map.containsKey("children"));
+		Assert.assertEquals(map.get("animal"), "dog");
+		Assert.assertEquals(map.get("children"), "1");
+
+		Assert.assertEquals(iter.hasNext(), true);
+		map = iter.next();
+		Assert.assertEquals(map.size(), 2);
+		Assert.assertTrue(map.containsKey("animal"));
+		Assert.assertTrue(map.containsKey("children"));
+		Assert.assertEquals(map.get("animal"), "dog");
+		Assert.assertEquals(map.get("children"), "2");
+
+		Assert.assertFalse(iter.hasNext());
+		Assert.assertFalse(iter.hasNext());
+		Assert.assertFalse(iter.hasNext());
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestAlwaysTrueRule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestAlwaysTrueRule.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestAlwaysTrueRule.java
new file mode 100644
index 0000000..2738456
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestAlwaysTrueRule.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules;
+
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.AlwaysTrueRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.Rule;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestAlwaysTrueRule
+{
+
+	@Test
+	public void testRuleMatches()
+	{
+		Rule rule = new AlwaysTrueRule();
+		Assert.assertTrue(rule.ruleMatches(null));
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestAndRule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestAndRule.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestAndRule.java
new file mode 100644
index 0000000..7757048
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestAndRule.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules;
+
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.AlwaysTrueRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.AndRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.NotRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.Rule;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestAndRule
+{
+
+	@Test
+	public void testRuleMatches()
+	{
+		Rule rule = new AndRule(
+				new AlwaysTrueRule(),
+				new AlwaysTrueRule());
+		Assert.assertTrue(rule.ruleMatches(null));
+
+		rule = new AndRule(
+				new AlwaysTrueRule(),
+				new NotRule(
+						new AlwaysTrueRule()));
+		Assert.assertFalse(rule.ruleMatches(null));
+
+		rule = new AndRule(
+				new NotRule(
+						new AlwaysTrueRule()),
+				new AlwaysTrueRule());
+		Assert.assertFalse(rule.ruleMatches(null));
+
+		rule = new AndRule(
+				new NotRule(
+						new AlwaysTrueRule()),
+				new NotRule(
+						new AlwaysTrueRule()));
+		Assert.assertFalse(rule.ruleMatches(null));
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestFieldPredicate.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestFieldPredicate.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestFieldPredicate.java
new file mode 100644
index 0000000..1139f16
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestFieldPredicate.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules;
+
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.FieldPredicate;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.Rule;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class TestFieldPredicate
+{
+
+	@Test
+	public void testRuleMatches()
+	{
+		Map<String, Object> fields = ImmutableMap.of("brand", (Object) "Chef Corgi",
+				"flavor", (Object) "chicken");
+		Product product = new Product(fields);
+
+		Rule rule = new FieldPredicate("brand", "Chef Corgi");
+		Assert.assertTrue(rule.ruleMatches(product));
+
+		rule = new FieldPredicate("brand", "Happy Pup");
+		Assert.assertFalse(rule.ruleMatches(product));
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestNotRule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestNotRule.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestNotRule.java
new file mode 100644
index 0000000..44b5aaa
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestNotRule.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules;
+
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.AlwaysTrueRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.NotRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.Rule;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestNotRule
+{
+
+	@Test
+	public void testRuleMatches()
+	{
+		Rule rule = new NotRule(
+				new AlwaysTrueRule());
+		Assert.assertFalse(rule.ruleMatches(null));
+
+		rule = new NotRule(
+				new NotRule(
+						new AlwaysTrueRule()));
+		Assert.assertTrue(rule.ruleMatches(null));
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestOrRule.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestOrRule.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestOrRule.java
new file mode 100644
index 0000000..c9e7ec7
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/products/rules/TestOrRule.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules;
+
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.AlwaysTrueRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.NotRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.OrRule;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.rules.Rule;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestOrRule
+{
+
+	@Test
+	public void testRuleMatches()
+	{
+		Rule rule = new OrRule(
+				new AlwaysTrueRule(),
+				new AlwaysTrueRule());
+		Assert.assertTrue(rule.ruleMatches(null));
+
+		rule = new OrRule(
+				new AlwaysTrueRule(),
+				new NotRule(
+						new AlwaysTrueRule()));
+		Assert.assertTrue(rule.ruleMatches(null));
+
+		rule = new OrRule(
+				new NotRule(
+						new AlwaysTrueRule()),
+				new AlwaysTrueRule());
+		Assert.assertTrue(rule.ruleMatches(null));
+
+		rule = new OrRule(
+				new NotRule(
+						new AlwaysTrueRule()),
+				new NotRule(
+						new AlwaysTrueRule()));
+		Assert.assertFalse(rule.ruleMatches(null));
+	}
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestProductCategoryMarkovModelSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestProductCategoryMarkovModelSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestProductCategoryMarkovModelSampler.java
new file mode 100644
index 0000000..0453eec
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestProductCategoryMarkovModelSampler.java
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.purchase;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.ProductCategoryBuilder;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.MarkovModelProductCategorySampler;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.markovmodels.MarkovModel;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.UniformSampler;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class TestProductCategoryMarkovModelSampler
+{
+
+	private List<ProductCategory> createProducts()
+	{
+		List<ProductCategory> productCategories = Lists.newArrayList();
+
+		ProductCategoryBuilder foodBuilder = new ProductCategoryBuilder();
+		foodBuilder.addApplicableSpecies(PetSpecies.DOG);
+		foodBuilder.setAmountUsedPetPetAverage(1.0);
+		foodBuilder.setAmountUsedPetPetVariance(1.0);
+		foodBuilder.setDailyUsageRate(2.0);
+		foodBuilder.setCategory("dogFood");
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 60.0, "Flavor", "Fish & Potato")));
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 30.0, "Flavor", "Chicken & Rice")));
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 15.0, "Flavor", "Lamb & Barley")));
+		productCategories.add(foodBuilder.build());
+
+		ProductCategoryBuilder bagBuilder = new ProductCategoryBuilder();
+		bagBuilder.addApplicableSpecies(PetSpecies.DOG);
+		bagBuilder.setAmountUsedPetPetAverage(1.0);
+		bagBuilder.setAmountUsedPetPetVariance(1.0);
+		bagBuilder.setDailyUsageRate(2.0);
+		bagBuilder.setCategory("Poop Bags");
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 60.0, "Color", "Blue")));
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 30.0, "Color", "Red")));
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 120.0, "Flavor", "Multicolor")));
+		productCategories.add(bagBuilder.build());
+
+		return productCategories;
+	}
+
+	@Test
+	public void testSample() throws Exception
+	{
+		SeedFactory seedFactory = new SeedFactory(1245);
+
+		List<ProductCategory> productCategories = createProducts();
+
+		ProductCategory productCategory = productCategories.get(0);
+
+		Sampler<Double> fieldWeightSampler = new UniformSampler(seedFactory);
+
+		Map<String, Double> fieldWeights = Maps.newHashMap();
+		for(String fieldName : productCategory.getFieldNames())
+		{
+			fieldWeights.put(fieldName, fieldWeightSampler.sample());
+		}
+
+		MarkovModelProductCategorySampler generator = new MarkovModelProductCategorySampler(productCategory,
+				fieldWeights, new UniformSampler(seedFactory), new UniformSampler(seedFactory)
+				);
+
+		MarkovModel<Product> model = generator.sample();
+
+		assertNotNull(model);
+		assertNotNull(model.getStartWeights());
+		assertNotNull(model.getTransitionWeights());
+		assertTrue(model.getStartWeights().size() > 0);
+		assertTrue(model.getTransitionWeights().size() > 0);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingModelSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingModelSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingModelSampler.java
new file mode 100644
index 0000000..25a43ed
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingModelSampler.java
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.purchase;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.ProductCategoryBuilder;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.MarkovPurchasingModel;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.PurchasingModelSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+
+public class TestPurchasingModelSampler
+{
+
+	private List<ProductCategory> createProducts()
+	{
+		List<ProductCategory> productCategories = Lists.newArrayList();
+
+		ProductCategoryBuilder foodBuilder = new ProductCategoryBuilder();
+		foodBuilder.addApplicableSpecies(PetSpecies.DOG);
+		foodBuilder.setAmountUsedPetPetAverage(1.0);
+		foodBuilder.setAmountUsedPetPetVariance(1.0);
+		foodBuilder.setDailyUsageRate(2.0);
+		foodBuilder.setCategory("dogFood");
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 60.0, "Flavor", "Fish & Potato")));
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 30.0, "Flavor", "Chicken & Rice")));
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 15.0, "Flavor", "Lamb & Barley")));
+		productCategories.add(foodBuilder.build());
+
+		ProductCategoryBuilder bagBuilder = new ProductCategoryBuilder();
+		bagBuilder.addApplicableSpecies(PetSpecies.DOG);
+		bagBuilder.setAmountUsedPetPetAverage(1.0);
+		bagBuilder.setAmountUsedPetPetVariance(1.0);
+		bagBuilder.setDailyUsageRate(2.0);
+		bagBuilder.setCategory("Poop Bags");
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 60.0, "Color", "Blue")));
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 30.0, "Color", "Red")));
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 120.0, "Color", "Multicolor")));
+		productCategories.add(bagBuilder.build());
+
+		return productCategories;
+	}
+
+	@Test
+	public void testSample() throws Exception
+	{
+		SeedFactory seedFactory = new SeedFactory(1245);
+
+		List<ProductCategory> productCategories = createProducts();
+
+		PurchasingModelSamplerBuilder builder = new PurchasingModelSamplerBuilder(productCategories, seedFactory);
+		Sampler<MarkovPurchasingModel> sampler = builder.buildMarkovPurchasingModel();
+		MarkovPurchasingModel profile = sampler.sample();
+
+		assertNotNull(profile);
+		assertNotNull(profile.getProductCategories());
+		assertTrue(profile.getProductCategories().size() > 0);
+
+		for(String label : profile.getProductCategories())
+		{
+			assertNotNull(profile.getProfile(label));
+			assertNotNull(profile.getProfile(label).getStartWeights());
+			assertTrue(profile.getProfile(label).getStartWeights().size() > 0);
+			assertNotNull(profile.getProfile(label).getTransitionWeights());
+			assertTrue(profile.getProfile(label).getTransitionWeights().size() > 0);
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingModelSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingModelSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingModelSamplerBuilder.java
new file mode 100644
index 0000000..79d9821
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingModelSamplerBuilder.java
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.purchase;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.ProductCategoryBuilder;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.MarkovPurchasingModel;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.PurchasingModelSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+
+public class TestPurchasingModelSamplerBuilder
+{
+
+	private List<ProductCategory> createProducts()
+	{
+		List<ProductCategory> productCategories = Lists.newArrayList();
+
+		ProductCategoryBuilder foodBuilder = new ProductCategoryBuilder();
+		foodBuilder.addApplicableSpecies(PetSpecies.DOG);
+		foodBuilder.setAmountUsedPetPetAverage(1.0);
+		foodBuilder.setAmountUsedPetPetVariance(1.0);
+		foodBuilder.setDailyUsageRate(2.0);
+		foodBuilder.setCategory("dogFood");
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 60.0, "Flavor", "Fish & Potato")));
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 30.0, "Flavor", "Chicken & Rice")));
+		foodBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "dogFood",
+				Constants.PRODUCT_QUANTITY, (Object) 15.0, "Flavor", "Lamb & Barley")));
+		productCategories.add(foodBuilder.build());
+
+		ProductCategoryBuilder bagBuilder = new ProductCategoryBuilder();
+		bagBuilder.addApplicableSpecies(PetSpecies.DOG);
+		bagBuilder.setAmountUsedPetPetAverage(1.0);
+		bagBuilder.setAmountUsedPetPetVariance(1.0);
+		bagBuilder.setDailyUsageRate(2.0);
+		bagBuilder.setCategory("Poop Bags");
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 60.0, "Color", "Blue")));
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 30.0, "Color", "Red")));
+		bagBuilder.addProduct(new Product(ImmutableMap.of(Constants.PRODUCT_CATEGORY, (Object) "Poop Bags",
+				Constants.PRODUCT_QUANTITY, (Object) 120.0, "Color", "Multicolor")));
+		productCategories.add(bagBuilder.build());
+
+		return productCategories;
+	}
+
+	@Test
+	public void testBuild() throws Exception
+	{
+		SeedFactory seedFactory = new SeedFactory(1245);
+
+		List<ProductCategory> productCategories = createProducts();
+
+		PurchasingModelSamplerBuilder builder = new PurchasingModelSamplerBuilder(productCategories, seedFactory);
+		Sampler<MarkovPurchasingModel> sampler = builder.buildMarkovPurchasingModel();
+		MarkovPurchasingModel profile = sampler.sample();
+
+		assertNotNull(profile);
+		assertNotNull(profile.getProductCategories());
+		assertTrue(profile.getProductCategories().size() > 0);
+
+		for(String label : profile.getProductCategories())
+		{
+			assertNotNull(profile.getProfile(label));
+			assertNotNull(profile.getProfile(label).getStartWeights());
+			assertTrue(profile.getProfile(label).getStartWeights().size() > 0);
+			assertNotNull(profile.getProfile(label).getTransitionWeights());
+			assertTrue(profile.getProfile(label).getTransitionWeights().size() > 0);
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingProcesses.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingProcesses.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingProcesses.java
new file mode 100644
index 0000000..eadc61d
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/purchase/TestPurchasingProcesses.java
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.purchase;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.purchase.PurchasingProcesses;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.RouletteWheelSampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.junit.Test;
+
+import com.google.common.collect.Maps;
+
+public class TestPurchasingProcesses
+{
+
+	@Test
+	public void testSimulatePurchase() throws Exception
+	{
+		Map<Product, Double> productPDF = Maps.newHashMap();
+
+		for(int i = 0; i < 10; i++)
+		{
+			Map<String, Object> fields = Maps.newHashMap();
+			fields.put(Constants.PRODUCT_CATEGORY, "dog food");
+			fields.put(Constants.PRODUCT_QUANTITY, (double) (i + 1));
+			Product product = new Product(fields);
+			productPDF.put(product, 0.1);
+		}
+
+		SeedFactory seedFactory = new SeedFactory(1234);
+		Sampler<Product> sampler = RouletteWheelSampler.create(productPDF, seedFactory);
+
+
+		Map<String, Sampler<Product>> processesMap = Maps.newHashMap();
+		processesMap.put("dog food", sampler);
+		PurchasingProcesses processes = new PurchasingProcesses(processesMap);
+
+		Product product = processes.sample("dog food");
+
+		assertNotNull(product);
+		assertNotNull(product.getFieldValue(Constants.PRODUCT_CATEGORY));
+		assertNotNull(product.getFieldValue(Constants.PRODUCT_QUANTITY));
+
+		product = processes.sample("dog food");
+
+		assertNotNull(product);
+		assertNotNull(product.getFieldValue(Constants.PRODUCT_CATEGORY));
+		assertNotNull(product.getFieldValue(Constants.PRODUCT_QUANTITY));
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreLocationIncomePDF.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreLocationIncomePDF.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreLocationIncomePDF.java
new file mode 100644
index 0000000..b194c3a
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreLocationIncomePDF.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.store;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.store.StoreLocationIncomePDF;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Test;
+
+public class TestStoreLocationIncomePDF
+{
+
+	@Test
+	public void testProbability() throws Exception
+	{
+		List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+				new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+				new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+				new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300)
+				});
+
+		StoreLocationIncomePDF pdf = new StoreLocationIncomePDF(zipcodes, 100.0);
+
+		for(ZipcodeRecord record : zipcodes)
+		{
+			assertTrue(pdf.probability(record) > 0.0);
+		}
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreLocationPopulationPDF.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreLocationPopulationPDF.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreLocationPopulationPDF.java
new file mode 100644
index 0000000..002e14f
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreLocationPopulationPDF.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.store;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.store.StoreLocationPopulationPDF;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Test;
+
+public class TestStoreLocationPopulationPDF
+{
+
+	@Test
+	public void testProbability() throws Exception
+	{
+		List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+				new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+				new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+				new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300)
+				});
+
+		StoreLocationPopulationPDF pdf = new StoreLocationPopulationPDF(zipcodes);
+
+		for(ZipcodeRecord record : zipcodes)
+		{
+			assertTrue(pdf.probability(record) > 0.0);
+		}
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreSampler.java
new file mode 100644
index 0000000..2594509
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreSampler.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.store;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.store.StoreSampler;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.RouletteWheelSampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.apache.bigtop.datagenerators.samplers.samplers.SequenceSampler;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Test;
+
+public class TestStoreSampler
+{
+
+	@Test
+	public void testSampler() throws Exception
+	{
+		Collection<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+				new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+				new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+				new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300)
+				});
+
+		SeedFactory factory = new SeedFactory(1234);
+
+		Sampler<Store> sampler = new StoreSampler(new SequenceSampler(),
+				RouletteWheelSampler.createUniform(zipcodes, factory));
+
+		Store store = sampler.sample();
+		assertNotNull(store);
+		assertTrue(store.getId() >= 0);
+		assertNotNull(store.getName());
+		assertNotNull(store.getLocation());
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreSamplerBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreSamplerBuilder.java
new file mode 100644
index 0000000..f440ff6
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/store/TestStoreSamplerBuilder.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.store;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Store;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.store.StoreSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Test;
+
+public class TestStoreSamplerBuilder
+{
+
+	@Test
+	public void testBuild() throws Exception
+	{
+		List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+				new ZipcodeRecord("11111", Pair.of(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+				new ZipcodeRecord("22222", Pair.of(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+				new ZipcodeRecord("33333", Pair.of(3.0, 3.0), "AZ", "Flagstaff", 60000.0, 300)
+				});
+
+		assertTrue(zipcodes.size() > 0);
+
+		SeedFactory factory = new SeedFactory(1234);
+
+		StoreSamplerBuilder builder = new StoreSamplerBuilder(zipcodes, factory);
+		Sampler<Store> sampler = builder.build();
+
+		Store store = sampler.sample();
+		assertNotNull(store);
+		assertTrue(store.getId() >= 0);
+		assertNotNull(store.getName());
+		assertNotNull(store.getLocation());
+
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerInventory.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerInventory.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerInventory.java
new file mode 100644
index 0000000..1d0ded4
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerInventory.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.transaction;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.ProductCategoryBuilder;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerInventory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParameters;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParametersSamplerBuilder;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.ProductCategoryInventory;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.junit.Test;
+
+import com.google.common.collect.Maps;
+
+public class TestCustomerInventory
+{
+
+	@Test
+	public void testPurchase() throws Exception
+	{
+		SeedFactory seedFactory = new SeedFactory(1234);
+
+		CustomerTransactionParametersSamplerBuilder transParamsBuilder = new CustomerTransactionParametersSamplerBuilder(seedFactory);
+		Sampler<CustomerTransactionParameters> sampler = transParamsBuilder.build();
+
+		CustomerTransactionParameters parameters = sampler.sample();
+
+		ProductCategoryBuilder builder = new ProductCategoryBuilder();
+		builder.addApplicableSpecies(PetSpecies.DOG);
+		builder.setAmountUsedPetPetAverage(1.0);
+		builder.setAmountUsedPetPetVariance(1.0);
+		builder.setDailyUsageRate(2.0);
+		builder.setCategory("dog food");
+
+
+		ProductCategory category = builder.build();
+
+		ProductCategoryInventory productInventory = new ProductCategoryInventory(category, parameters, seedFactory);
+
+		Map<String, ProductCategoryInventory> inventories = Maps.newHashMap();
+		inventories.put("dog food", productInventory);
+
+		CustomerInventory inventory = new CustomerInventory(inventories);
+
+		for(Map.Entry<String, Double> entry : inventory.getExhaustionTimes().entrySet())
+		{
+			assertEquals(entry.getValue(), 0.0, 0.0001);
+		}
+
+		for(Map.Entry<String, Double> entry : inventory.getInventoryAmounts(0.0).entrySet())
+		{
+			assertEquals(entry.getValue(), 0.0, 0.0001);
+		}
+
+		Map<String, Object> fields = Maps.newHashMap();
+		fields.put(Constants.PRODUCT_CATEGORY, "dog food");
+		fields.put(Constants.PRODUCT_QUANTITY, 30.0);
+		Product product = new Product(fields);
+
+		inventory.simulatePurchase(1.0, product);
+
+		Map<String, Double> exhaustionTimes = inventory.getExhaustionTimes();
+		assertTrue(exhaustionTimes.containsKey("dog food"));
+		assertTrue(exhaustionTimes.get("dog food") > 0.0);
+
+		Map<String, Double> amounts = inventory.getInventoryAmounts(2.0);
+		assertTrue(amounts.containsKey("dog food"));
+		assertTrue(amounts.get("dog food") > 0.0);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerInventoryBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerInventoryBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerInventoryBuilder.java
new file mode 100644
index 0000000..85aa000
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerInventoryBuilder.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.transaction;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.Product;
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.products.ProductCategoryBuilder;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerInventory;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerInventoryBuilder;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParameters;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParametersSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.junit.Test;
+
+import com.google.common.collect.Maps;
+
+public class TestCustomerInventoryBuilder
+{
+
+	@Test
+	public void testBuild() throws Exception
+	{
+		SeedFactory seedFactory = new SeedFactory(1234);
+
+		CustomerTransactionParametersSamplerBuilder transParamsBuilder = new CustomerTransactionParametersSamplerBuilder(seedFactory);
+		Sampler<CustomerTransactionParameters> sampler = transParamsBuilder.build();
+
+		CustomerTransactionParameters parameters = sampler.sample();
+
+		ProductCategoryBuilder builder = new ProductCategoryBuilder();
+		builder.addApplicableSpecies(PetSpecies.DOG);
+		builder.setAmountUsedPetPetAverage(1.0);
+		builder.setAmountUsedPetPetVariance(1.0);
+		builder.setDailyUsageRate(2.0);
+		builder.setCategory("dog food");
+
+		ProductCategory category = builder.build();
+
+		CustomerInventoryBuilder inventoryBuilder = new CustomerInventoryBuilder(parameters, seedFactory);
+		inventoryBuilder.addProductCategory(category);
+
+		CustomerInventory inventory = inventoryBuilder.build();
+
+		for(Map.Entry<String, Double> entry : inventory.getExhaustionTimes().entrySet())
+		{
+			assertEquals(entry.getValue(), 0.0, 0.0001);
+		}
+
+		for(Map.Entry<String, Double> entry : inventory.getInventoryAmounts(0.0).entrySet())
+		{
+			assertEquals(entry.getValue(), 0.0, 0.0001);
+		}
+
+		Map<String, Object> fields = Maps.newHashMap();
+		fields.put(Constants.PRODUCT_CATEGORY, "dog food");
+		fields.put(Constants.PRODUCT_QUANTITY, 30.0);
+		Product product = new Product(fields);
+
+		inventory.simulatePurchase(1.0, product);
+
+		Map<String, Double> exhaustionTimes = inventory.getExhaustionTimes();
+		assertTrue(exhaustionTimes.containsKey("dog food"));
+		assertTrue(exhaustionTimes.get("dog food") > 0.0);
+
+		Map<String, Double> amounts = inventory.getInventoryAmounts(2.0);
+		assertTrue(amounts.containsKey("dog food"));
+		assertTrue(amounts.get("dog food") > 0.0);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParameters.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParameters.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParameters.java
new file mode 100644
index 0000000..06b0881
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParameters.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.transaction;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParameters;
+import org.junit.Test;
+
+import com.google.common.collect.HashMultiset;
+import com.google.common.collect.Multiset;
+
+public class TestCustomerTransactionParameters
+{
+
+	@Test
+	public void testCountPetsBySpecies() throws Exception
+	{
+		Multiset<PetSpecies> petCounts = HashMultiset.create();
+
+		petCounts.add(PetSpecies.CAT);
+		petCounts.add(PetSpecies.CAT);
+		petCounts.add(PetSpecies.CAT);
+
+
+		CustomerTransactionParameters transParams = new CustomerTransactionParameters(
+				petCounts, 0.0, 0.0);
+
+
+		assertEquals(transParams.countPetsBySpecies(PetSpecies.CAT), 3);
+		assertEquals(transParams.countPetsBySpecies(PetSpecies.DOG), 0);
+		assertEquals(transParams.countPets(), 3);
+	}
+
+	@Test
+	public void testCountPetsByMultipleSpecies() throws Exception
+	{
+		Multiset<PetSpecies> petCounts = HashMultiset.create();
+
+		petCounts.add(PetSpecies.CAT);
+		petCounts.add(PetSpecies.CAT);
+		petCounts.add(PetSpecies.DOG);
+
+
+		CustomerTransactionParameters transParams = new CustomerTransactionParameters(
+				petCounts, 0.0, 0.0);
+
+
+		assertEquals(transParams.countPetsBySpecies(Arrays.asList(PetSpecies.values())), 3);
+		assertEquals(transParams.countPets(), 3);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParametersBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParametersBuilder.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParametersBuilder.java
new file mode 100644
index 0000000..45245d5
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParametersBuilder.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.transaction;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.bigtop.datagenerators.bigpetstore.datamodels.PetSpecies;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParameters;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParametersBuilder;
+import org.junit.Test;
+
+public class TestCustomerTransactionParametersBuilder
+{
+
+	@Test
+	public void testBuild() throws Exception
+	{
+		CustomerTransactionParametersBuilder builder = new CustomerTransactionParametersBuilder();
+
+		builder.addPet(PetSpecies.DOG);
+		builder.addPet(PetSpecies.DOG);
+		builder.addPet(PetSpecies.DOG);
+
+		builder.setAveragePurchaseTriggerTime(1.0);
+		builder.setAverageTransactionTriggerTime(2.0);
+
+		CustomerTransactionParameters transParams = builder.build();
+
+		assertTrue(transParams.countPetsBySpecies(PetSpecies.DOG) == 3);
+		assertTrue(transParams.countPetsBySpecies(PetSpecies.CAT) == 0);
+		assertTrue(transParams.getAveragePurchaseTriggerTime() == 1.0);
+		assertTrue(transParams.getAverageTransactionTriggerTime() == 2.0);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/bigtop/blob/15af83eb/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParametersSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParametersSampler.java b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParametersSampler.java
new file mode 100644
index 0000000..0f4513b
--- /dev/null
+++ b/bigtop-data-generators/bigpetstore-data-generator/src/test/java/org/apache/bigtop/datagenerators/bigpetstore/generators/transaction/TestCustomerTransactionParametersSampler.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bigtop.datagenerators.bigpetstore.generators.transaction;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.bigtop.datagenerators.bigpetstore.Constants;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParameters;
+import org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParametersSamplerBuilder;
+import org.apache.bigtop.datagenerators.samplers.SeedFactory;
+import org.apache.bigtop.datagenerators.samplers.samplers.Sampler;
+import org.junit.Test;
+
+public class TestCustomerTransactionParametersSampler
+{
+
+	@Test
+	public void testSample() throws Exception
+	{
+		SeedFactory seedFactory = new SeedFactory(1234);
+		CustomerTransactionParametersSamplerBuilder builder = new CustomerTransactionParametersSamplerBuilder(seedFactory);
+		Sampler<CustomerTransactionParameters> sampler = builder.build();
+
+		CustomerTransactionParameters transParams = sampler.sample();
+
+		assertTrue(transParams.countPets() >= Constants.MIN_PETS);
+		assertTrue(transParams.countPets() <= Constants.MAX_PETS);
+		assertTrue(transParams.getAveragePurchaseTriggerTime() >= Constants.PURCHASE_TRIGGER_TIME_MIN);
+		assertTrue(transParams.getAveragePurchaseTriggerTime() <= Constants.PURCHASE_TRIGGER_TIME_MAX);
+		assertTrue(transParams.getAverageTransactionTriggerTime() >= Constants.TRANSACTION_TRIGGER_TIME_MIN);
+		assertTrue(transParams.getAverageTransactionTriggerTime() <= Constants.TRANSACTION_TRIGGER_TIME_MAX);
+	}
+
+}


Mime
View raw message