You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by rn...@apache.org on 2015/03/30 19:04:24 UTC
[02/13] bigtop git commit: BIGTOP-1783: Import BigPetStore Data
Generator into BigTop
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/TestProduct.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/TestProduct.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/datamodels/TestProduct.java
new file mode 100644
index 0000000..f1e835a
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.datamodels;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Map;
+
+import org.apache.bigtop.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/markovmodels/TestMarkovModelBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/markovmodels/TestMarkovModelBuilder.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/markovmodels/TestMarkovModelBuilder.java
new file mode 100644
index 0000000..b9e63f2
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/markovmodels/TestMarkovModelBuilder.java
@@ -0,0 +1,76 @@
+/**
+ * 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.bigpetstore.datagenerator.framework.markovmodels;
+
+import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModel;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModelBuilder;
+import org.junit.Test;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.matchers.JUnitMatchers.*;
+
+public class TestMarkovModelBuilder
+{
+
+ @Test
+ public void testAddStateState()
+ {
+ MarkovModelBuilder<String> builder = MarkovModelBuilder.create();
+
+ builder.addStartState("a", 1.0);
+
+ MarkovModel<String> msm = builder.build();
+
+ assertThat(msm.getStartWeights().keySet(), hasItem("a"));
+ assertEquals((double) msm.getStartWeights().get("a"), (double) 1.0, 0.000001);
+
+ }
+
+ @Test
+ public void testAddEdgeTransition()
+ {
+ MarkovModelBuilder<String> builder = MarkovModelBuilder.create();
+
+ builder.addTransition("a", "b", 1.0);
+
+ MarkovModel<String> msm = builder.build();
+
+ assertThat(msm.getTransitionWeights().keySet(), hasItem("a"));
+ assertThat(msm.getTransitionWeights().get("a").keySet(), hasItem("b"));
+ assertEquals((double) msm.getTransitionWeights().get("a").get("b"), (double) 1.0, 0.000001);
+ }
+
+ @Test
+ public void testBuildMSM()
+ {
+ MarkovModelBuilder<String> builder = MarkovModelBuilder.create();
+
+ builder.addStartState("a", 1.0);
+ builder.addTransition("a", "b", 1.0);
+ builder.addTransition("a", "c", 1.0);
+
+ MarkovModel<String> msm = builder.build();
+
+ assertThat(msm.getStartWeights().keySet(), hasItem("a"));
+ assertThat(msm.getTransitionWeights().keySet(), hasItem("a"));
+ assertThat(msm.getTransitionWeights().get("a").keySet(), hasItem("b"));
+ assertThat(msm.getTransitionWeights().get("a").keySet(), hasItem("c"));
+ assertEquals((double) msm.getTransitionWeights().get("a").get("b"), (double) 1.0, 0.000001);
+ assertEquals((double) msm.getTransitionWeights().get("a").get("c"), (double) 1.0, 0.000001);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/markovmodels/TestMarkovProcess.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/markovmodels/TestMarkovProcess.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/markovmodels/TestMarkovProcess.java
new file mode 100644
index 0000000..e2ff4d5
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/markovmodels/TestMarkovProcess.java
@@ -0,0 +1,53 @@
+/**
+ * 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.bigpetstore.datagenerator.framework.markovmodels;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItem;
+
+import java.util.Arrays;
+
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModel;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModelBuilder;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovProcess;
+import org.junit.Test;
+
+public class TestMarkovProcess
+{
+
+ @Test
+ public void test() throws Exception
+ {
+ SeedFactory factory = new SeedFactory(1245);
+ MarkovModelBuilder<String> builder = MarkovModelBuilder.create();
+
+ builder.addStartState("a", 1.0);
+ builder.addTransition("a", "b", 1.0);
+ builder.addTransition("a", "c", 1.0);
+
+ MarkovModel<String> msm = builder.build();
+ MarkovProcess<String> process = MarkovProcess.create(msm, factory);
+
+ String firstState = process.sample();
+ assertEquals(firstState, "a");
+
+ String secondState = process.sample();
+ assertThat(Arrays.asList("b", "c"), hasItem(secondState));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java
new file mode 100644
index 0000000..fd85d08
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestBoundedMultiModalGaussianSampler.java
@@ -0,0 +1,50 @@
+/**
+ * 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.bigpetstore.datagenerator.framework.samplers;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.BoundedMultiModalGaussianSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+
+public class TestBoundedMultiModalGaussianSampler
+{
+
+ @Test
+ public void testSample() throws Exception
+ {
+ double upperbound = 10.0;
+ double lowerbound = 1.0;
+
+ List<Pair<Double, Double>> distributions = Lists.newArrayList(Pair.create(2.0, 2.0), Pair.create(7.5, 2.0));
+
+ SeedFactory seedFactory = new SeedFactory(1234);
+
+ Sampler<Double> sampler = new BoundedMultiModalGaussianSampler(distributions, lowerbound, upperbound, seedFactory);
+
+ Double result = sampler.sample();
+
+ assertTrue(result >= lowerbound);
+ assertTrue(result <= upperbound);
+ }
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestExponentialSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestExponentialSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestExponentialSampler.java
new file mode 100644
index 0000000..228b97d
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestExponentialSampler.java
@@ -0,0 +1,41 @@
+/**
+ * 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.bigpetstore.datagenerator.framework.samplers;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.ExponentialSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.junit.Test;
+
+public class TestExponentialSampler
+{
+
+ @Test
+ public void testSample() throws Exception
+ {
+ double lambda = 1.0 / 2.0;
+
+ SeedFactory seedFactory = new SeedFactory(1234);
+
+ Sampler<Double> sampler = new ExponentialSampler(lambda, seedFactory);
+
+ Double result = sampler.sample();
+
+ assertTrue(result >= 0.0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestGaussianSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestGaussianSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestGaussianSampler.java
new file mode 100644
index 0000000..fbe8c18
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestGaussianSampler.java
@@ -0,0 +1,43 @@
+/**
+ * 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.bigpetstore.datagenerator.framework.samplers;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.GaussianSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.junit.Test;
+
+public class TestGaussianSampler
+{
+
+ @Test
+ public void testSample() throws Exception
+ {
+ double mean = 2.0;
+ double var = 1.0;
+
+ SeedFactory seedFactory = new SeedFactory(1234);
+
+ Sampler<Double> sampler = new GaussianSampler(mean, var, seedFactory);
+
+ Double result = sampler.sample();
+
+ assertTrue(result >= -10);
+ assertTrue(result <= 10);
+ }
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestRouletteWheelSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestRouletteWheelSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestRouletteWheelSampler.java
new file mode 100644
index 0000000..f1152c5
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestRouletteWheelSampler.java
@@ -0,0 +1,71 @@
+/**
+ * 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.bigpetstore.datagenerator.framework.samplers;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItem;
+
+import java.util.Map;
+
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class TestRouletteWheelSampler
+{
+
+ @Test
+ public void testSample() throws Exception
+ {
+ Map<String, Double> dataPoints = ImmutableMap.of(
+ "a", 0.25,
+ "b", 0.25,
+ "c", 0.25,
+ "d", 0.25
+ );
+
+ SeedFactory seedFactory = new SeedFactory(1234);
+
+ Sampler<String> sampler = new RouletteWheelSampler<String>(dataPoints, seedFactory);
+
+ String result = sampler.sample();
+
+ assertThat(dataPoints.keySet(), hasItem(result));
+ }
+
+ @Test
+ public void testSampleUnnormalized() throws Exception
+ {
+ Map<String, Double> dataPoints = ImmutableMap.of(
+ "a", 1.0,
+ "b", 1.0,
+ "c", 1.0,
+ "d", 1.0
+ );
+
+ SeedFactory seedFactory = new SeedFactory(1234);
+
+ Sampler<String> sampler = new RouletteWheelSampler<String>(dataPoints, seedFactory);
+
+ String result = sampler.sample();
+
+ assertThat(dataPoints.keySet(), hasItem(result));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestSequenceSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestSequenceSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestSequenceSampler.java
new file mode 100644
index 0000000..6684773
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestSequenceSampler.java
@@ -0,0 +1,38 @@
+/**
+ * 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.bigpetstore.datagenerator.framework.samplers;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.SequenceSampler;
+import org.junit.Test;
+
+public class TestSequenceSampler
+{
+
+ @Test
+ public void testSample() throws Exception
+ {
+ Sampler<Integer> sampler = new SequenceSampler(0, 10, 1);
+
+ for(int i = 0; i < 10; i++)
+ {
+ Integer value = sampler.sample();
+ assertEquals( (int) value, i);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestUniformIntSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestUniformIntSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestUniformIntSampler.java
new file mode 100644
index 0000000..a700cdf
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/framework/samplers/TestUniformIntSampler.java
@@ -0,0 +1,60 @@
+/**
+ * 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.bigpetstore.datagenerator.framework.samplers;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.UniformIntSampler;
+import org.junit.Test;
+
+public class TestUniformIntSampler
+{
+
+ @Test
+ public void testSample() throws Exception
+ {
+ int upperbound = 10;
+ int lowerbound = 1;
+
+ SeedFactory seedFactory = new SeedFactory(1234);
+
+ Sampler<Integer> sampler = new UniformIntSampler(lowerbound, upperbound, seedFactory);
+
+ Integer result = sampler.sample();
+
+ assertTrue(result >= lowerbound);
+ assertTrue(result <= upperbound);
+ }
+
+ @Test
+ public void testSampleInclusive() throws Exception
+ {
+ int upperbound = 2;
+ int lowerbound = 1;
+
+ SeedFactory seedFactory = new SeedFactory(1234);
+
+ Sampler<Integer> sampler = new UniformIntSampler(lowerbound, upperbound, seedFactory);
+
+ Integer result = sampler.sample();
+
+ assertTrue(result >= lowerbound);
+ assertTrue(result <= upperbound);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerLocationPDF.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerLocationPDF.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerLocationPDF.java
new file mode 100644
index 0000000..849fead
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.generators.customer;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.bigtop.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.customer.CustomerLocationPDF;
+import org.junit.Test;
+
+public class TestCustomerLocationPDF
+{
+
+ @Test
+ public void testProbability() throws Exception
+ {
+ List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+ new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+ new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+ new ZipcodeRecord("33333", Pair.create(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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java
new file mode 100644
index 0000000..5865a83
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSampler.java
@@ -0,0 +1,113 @@
+/**
+ * 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.bigpetstore.datagenerator.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.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Customer;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.pdfs.ProbabilityDensityFunction;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.ConditionalSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.SequenceSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.customer.CustomerLocationPDF;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.customer.CustomerSampler;
+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();
+ }
+
+ public Sampler<ZipcodeRecord> fixConditional(Store store)
+ {
+ return locationSamplers.get(store);
+ }
+ };
+ }
+
+ @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.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+ new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+ new ZipcodeRecord("33333", Pair.create(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().getFirst());
+ assertTrue(nameList.contains(customer.getName().getFirst()));
+ assertNotNull(customer.getName().getSecond());
+ assertTrue(nameList.contains(customer.getName().getSecond()));
+ assertNotNull(customer.getLocation());
+ assertTrue(zipcodes.contains(customer.getLocation()));
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java
new file mode 100644
index 0000000..cd92052
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/customer/TestCustomerSamplerBuilder.java
@@ -0,0 +1,79 @@
+/**
+ * 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.bigpetstore.datagenerator.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.List;
+import java.util.Map;
+
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Customer;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.InputData;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.Names;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.customer.CustomerSamplerBuilder;
+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.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+ new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+ new ZipcodeRecord("33333", Pair.create(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, new ArrayList<ProductCategory>());
+
+ 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().getFirst());
+ assertNotNull(customer.getName().getSecond());
+ assertNotNull(customer.getLocation());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/bigtop/blob/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestProductCategoryMarkovModelSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestProductCategoryMarkovModelSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestProductCategoryMarkovModelSampler.java
new file mode 100644
index 0000000..e32994b
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestProductCategoryMarkovModelSampler.java
@@ -0,0 +1,114 @@
+/**
+ * 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.bigpetstore.datagenerator.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.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategoryBuilder;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.markovmodels.MarkovModel;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.UniformSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.ProductCategoryMarkovModelSampler;
+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.addFieldName(Constants.PRODUCT_CATEGORY);
+ foodBuilder.addFieldName(Constants.PRODUCT_QUANTITY);
+ foodBuilder.addFieldName("Flavor");
+ 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.addFieldName(Constants.PRODUCT_CATEGORY);
+ bagBuilder.addFieldName(Constants.PRODUCT_QUANTITY);
+ bagBuilder.addFieldName("Color");
+ 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());
+ }
+
+ ProductCategoryMarkovModelSampler generator = new ProductCategoryMarkovModelSampler(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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingModelSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingModelSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingModelSampler.java
new file mode 100644
index 0000000..04a20f0
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingModelSampler.java
@@ -0,0 +1,106 @@
+/**
+ * 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.bigpetstore.datagenerator.generators.purchase;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.apache.bigtop.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategoryBuilder;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.MarkovPurchasingModel;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.PurchasingModelSamplerBuilder;
+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.addFieldName(Constants.PRODUCT_CATEGORY);
+ foodBuilder.addFieldName(Constants.PRODUCT_QUANTITY);
+ foodBuilder.addFieldName("Flavor");
+ 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.addFieldName(Constants.PRODUCT_CATEGORY);
+ bagBuilder.addFieldName(Constants.PRODUCT_QUANTITY);
+ bagBuilder.addFieldName("Color");
+ 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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingModelSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingModelSamplerBuilder.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingModelSamplerBuilder.java
new file mode 100644
index 0000000..2255fc3
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingModelSamplerBuilder.java
@@ -0,0 +1,106 @@
+/**
+ * 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.bigpetstore.datagenerator.generators.purchase;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.apache.bigtop.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategoryBuilder;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.MarkovPurchasingModel;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.PurchasingModelSamplerBuilder;
+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.addFieldName(Constants.PRODUCT_CATEGORY);
+ foodBuilder.addFieldName(Constants.PRODUCT_QUANTITY);
+ foodBuilder.addFieldName("Flavor");
+ 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.addFieldName(Constants.PRODUCT_CATEGORY);
+ bagBuilder.addFieldName(Constants.PRODUCT_QUANTITY);
+ bagBuilder.addFieldName("Color");
+ 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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingProcesses.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingProcesses.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/purchase/TestPurchasingProcesses.java
new file mode 100644
index 0000000..c110def
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.generators.purchase;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Map;
+
+import org.apache.bigtop.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.purchase.PurchasingProcesses;
+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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationIncomePDF.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationIncomePDF.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationIncomePDF.java
new file mode 100644
index 0000000..ee27af7
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.generators.store;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.store.StoreLocationIncomePDF;
+import org.junit.Test;
+
+public class TestStoreLocationIncomePDF
+{
+
+ @Test
+ public void testProbability() throws Exception
+ {
+ List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+ new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+ new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+ new ZipcodeRecord("33333", Pair.create(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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationPopulationPDF.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationPopulationPDF.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreLocationPopulationPDF.java
new file mode 100644
index 0000000..7c4f522
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.generators.store;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Pair;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.store.StoreLocationPopulationPDF;
+import org.junit.Test;
+
+public class TestStoreLocationPopulationPDF
+{
+
+ @Test
+ public void testProbability() throws Exception
+ {
+ List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+ new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+ new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+ new ZipcodeRecord("33333", Pair.create(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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSampler.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSampler.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSampler.java
new file mode 100644
index 0000000..9efaef6
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.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.bigpetstore.datagenerator.datamodels.Pair;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.RouletteWheelSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.SequenceSampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.store.StoreSampler;
+import org.junit.Test;
+
+public class TestStoreSampler
+{
+
+ @Test
+ public void testSampler() throws Exception
+ {
+ Collection<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+ new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+ new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+ new ZipcodeRecord("33333", Pair.create(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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSamplerBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSamplerBuilder.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/store/TestStoreSamplerBuilder.java
new file mode 100644
index 0000000..cc896ea
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.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.bigpetstore.datagenerator.datamodels.Pair;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Store;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ZipcodeRecord;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.store.StoreSamplerBuilder;
+import org.junit.Test;
+
+public class TestStoreSamplerBuilder
+{
+
+ @Test
+ public void testBuild() throws Exception
+ {
+ List<ZipcodeRecord> zipcodes = Arrays.asList(new ZipcodeRecord[] {
+ new ZipcodeRecord("11111", Pair.create(1.0, 1.0), "AZ", "Tempte", 30000.0, 100),
+ new ZipcodeRecord("22222", Pair.create(2.0, 2.0), "AZ", "Phoenix", 45000.0, 200),
+ new ZipcodeRecord("33333", Pair.create(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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerInventory.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerInventory.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerInventory.java
new file mode 100644
index 0000000..6edb03d
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.generators.transaction;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.apache.bigtop.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategoryBuilder;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.CustomerInventory;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.CustomerTransactionParameters;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.CustomerTransactionParametersSamplerBuilder;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.ProductCategoryInventory;
+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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerInventoryBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerInventoryBuilder.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerInventoryBuilder.java
new file mode 100644
index 0000000..fb147de
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.generators.transaction;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.apache.bigtop.bigpetstore.datagenerator.Constants;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.Product;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategory;
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.inputs.ProductCategoryBuilder;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.SeedFactory;
+import org.apache.bigtop.bigpetstore.datagenerator.framework.samplers.Sampler;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.CustomerInventory;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.CustomerInventoryBuilder;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.CustomerTransactionParameters;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.CustomerTransactionParametersSamplerBuilder;
+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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerTransactionParameters.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerTransactionParameters.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerTransactionParameters.java
new file mode 100644
index 0000000..a9fdaec
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.generators.transaction;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
+import org.apache.bigtop.bigpetstore.datagenerator.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/5646c87d/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerTransactionParametersBuilder.java
----------------------------------------------------------------------
diff --git a/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerTransactionParametersBuilder.java b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/generators/transaction/TestCustomerTransactionParametersBuilder.java
new file mode 100644
index 0000000..0630c63
--- /dev/null
+++ b/bigtop-bigpetstore/bigpetstore-data-generator/src/test/java/org/apache/bigtop/bigpetstore/datagenerator/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.bigpetstore.datagenerator.generators.transaction;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.bigtop.bigpetstore.datagenerator.datamodels.PetSpecies;
+import org.apache.bigtop.bigpetstore.datagenerator.generators.transaction.CustomerTransactionParameters;
+import org.apache.bigtop.bigpetstore.datagenerator.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);
+ }
+
+}