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

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

import java.util.Arrays;
import java.util.List;

import org.junit.Test;

import com.github.rnowling.bps.datagenerator.Constants;
import com.github.rnowling.bps.datagenerator.datamodels.inputs.InputData;
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.datamodels.outputs.Store;
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.Sampler;

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();
		
		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().getFirst());
		assertNotNull(customer.getName().getSecond());
		assertNotNull(customer.getLocation());
		
	}

}

@@ -198,16 +198,38 @@
 il.List;
+%0Aimport java.util.Map;
 %0A%0Aimport
@@ -291,25 +291,31 @@
 nerator.
-Constants
+datamodels.Pair
 ;%0Aimport
@@ -679,149 +679,8 @@
 re;%0A
-import com.github.rnowling.bps.datagenerator.datareaders.NameReader;%0Aimport com.github.rnowling.bps.datagenerator.datareaders.ZipcodeReader;%0A
 impo
@@ -815,16 +815,63 @@
 Sampler;
+%0Aimport com.google.common.collect.ImmutableMap;
 %0A%0Apublic
@@ -963,407 +963,449 @@
 n%0A%09%7B
+%09
 %0A%09%09
-ZipcodeReader zipcodeReader = new ZipcodeReader();%0A%09%09zipcodeReader.setCoordinatesFile(Constants.COORDINATES_FILE);%0A%09%09zipcodeReader.setIncomesFile(Constants.INCOMES_FILE);%0A%09%09zipcodeReader.setPopulationFile(Constants.POPULATION_FILE);%0A%09%09List%3CZipcodeRecord%3E zipcodes = zipcodeReade
+Map%3CString, Double%3E nameList = ImmutableMap.of(%22Fred%22, 1.0, %22George%22, 1.0, %22Gary%22, 1.0, %22Fiona%22, 1.0);%0A%09%09List%3CZipcodeRecord%3E zipcodes = Arrays.asList(new ZipcodeRecord%5B%5D %7B%09%09%09%09%0A%09%09%09%09new ZipcodeRecord(%2211111%22, Pair.create(1.0, 1.0), 30000.0, 100),%0A%09%09%09%09new ZipcodeRecord(%2222222%22, Pair.create(2.0, 2.0), 45000.0, 200),%0A%09%09%09%09new ZipcodeRecord(%2233333%22, Pai
 r.
+c
 rea
-dData();%0A%09%09%0A%09%09NameReader nameReader = new NameReader(Constants.NAMEDB_FILE);%0A%09%09Names names = nameReader.readData(
+te(3.0, 3.0), 60000.0, 300)%0A%09%09%09%09%7D);%0A%09%09%0A%09%09Names names = new Names(nameList, nameList
 );%0A%09

remove dependency on data files form TestCustomerSamplerBuilder