package com.github.rnowling.bps.datagenerator.generators.customer;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.Test;

import com.github.rnowling.bps.datagenerator.Constants;
import com.github.rnowling.bps.datagenerator.datamodels.inputs.Names;
import com.github.rnowling.bps.datagenerator.datamodels.inputs.ZipcodeRecord;
import com.github.rnowling.bps.datagenerator.datamodels.outputs.Customer;
import com.github.rnowling.bps.datagenerator.datareaders.NameReader;
import com.github.rnowling.bps.datagenerator.datareaders.ZipcodeReader;
import com.github.rnowling.bps.datagenerator.framework.SeedFactory;
import com.github.rnowling.bps.datagenerator.framework.samplers.RouletteWheelSampler;
import com.github.rnowling.bps.datagenerator.framework.samplers.Sampler;
import com.github.rnowling.bps.datagenerator.framework.samplers.SequenceSampler;
import com.github.rnowling.bps.datagenerator.generators.customer.CustomerSampler;

public class TestCustomerSamplerBuilder
{

	@Test
	public void testSample() throws Exception
	{
		ZipcodeReader zipcodeReader = new ZipcodeReader();
		zipcodeReader.setCoordinatesFile(Constants.COORDINATES_FILE);
		zipcodeReader.setIncomesFile(Constants.INCOMES_FILE);
		zipcodeReader.setPopulationFile(Constants.POPULATION_FILE);
		List<ZipcodeRecord> zipcodes = zipcodeReader.readData();
		
		NameReader nameReader = new NameReader(Constants.NAMEDB_FILE);
		Names names = nameReader.readData();
		
		SeedFactory factory = new SeedFactory(1234);
		
		Sampler<Customer> sampler = new CustomerSampler(new SequenceSampler(),
				RouletteWheelSampler.createUniform(names.getFirstNames().keySet(), factory), 
				RouletteWheelSampler.createUniform(names.getLastNames().keySet(), factory), 
				RouletteWheelSampler.createUniform(zipcodes, factory));
		
		Customer customer = sampler.sample();
		
		assertNotNull(customer);
		assertTrue(customer.getId() >= 0);
		assertNotNull(customer.getName());
		assertNotNull(customer.getName().getFirst());
		assertNotNull(customer.getName().getSecond());
		assertNotNull(customer.getLocation());
		
	}

}

@@ -151,16 +151,41 @@
 tTrue;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -280,16 +280,90 @@
 stants;%0A
+import com.github.rnowling.bps.datagenerator.datamodels.inputs.InputData;%0A
 import c
@@ -572,24 +572,95 @@
 s.Customer;%0A
+import com.github.rnowling.bps.datagenerator.datamodels.outputs.Store;%0A
 import com.g
@@ -924,257 +924,8 @@
 ers.
-RouletteWheelSampler;%0Aimport com.github.rnowling.bps.datagenerator.framework.samplers.Sampler;%0Aimport com.github.rnowling.bps.datagenerator.framework.samplers.SequenceSampler;%0Aimport com.github.rnowling.bps.datagenerator.generators.customer.Customer
 Samp
@@ -1436,279 +1436,374 @@
 %09%0A%09%09
-SeedFactory factory = new SeedFactory(1234);%0A%09%09%0A%09%09Sampler%3CCustomer%3E sampler = new CustomerSampler(new SequenceSampler(),%0A%09%09%09%09RouletteWheelSampler.createUniform(names.getFirstNames().keySet(), factory), 
+InputData inputData = new InputData(zipcodes, names);%0A%09%09%0A%09%09List%3CStore%3E stores = Arrays.asList(new Store(0, %22Store_0%22, zipcodes.get(0)),%0A%09%09%09%09new Store(1, %22Store_1%22, zipcodes.get(1)),%0A%09%09%09%09new Store(2, %22Store_2%22, zipcodes.get(2))%0A%09%09%09%09);%0A%09%09%0A%09%09SeedFactory factory = new SeedFactory(1234);
 %0A%09%09
+%0A
 %09%09
-RouletteWheelSampler.createUniform(names.getLastNames().keySet()
+CustomerSamplerBuilder builder = new CustomerSamplerBuilder(stores, inputData
 , fa
@@ -1812,68 +1812,54 @@
 ory)
-, %0A%09%09%09%09RouletteWheelSampler.createUniform(zipcodes, factory)
+;%0A%09%09Sampler%3CCustomer%3E sampler = builder.build(
 );%0A%09

Fix customer sampler builder