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

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

import java.util.List;
import java.util.Map;

import org.junit.Test;

import com.github.rnowling.bps.datagenerator.Constants;
import com.github.rnowling.bps.datagenerator.datamodels.inputs.ZipcodeRecord;
import com.github.rnowling.bps.datagenerator.datamodels.outputs.Store;
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.store.StoreSampler;
import com.google.common.collect.Maps;

public class TestStoreSampler
{

	@Test
	public void testSampler() throws Exception
	{
		ZipcodeReader reader = new ZipcodeReader();
		reader.setCoordinatesFile(Constants.COORDINATES_FILE);
		reader.setIncomesFile(Constants.INCOMES_FILE);
		reader.setPopulationFile(Constants.POPULATION_FILE);
		
		List<ZipcodeRecord> zipcodes = reader.readData();
		
		assertTrue(zipcodes.size() > 0);
		
		SeedFactory factory = new SeedFactory(1234);
		
		Map<ZipcodeRecord, Double> zipcodePDF = Maps.newHashMap();
		for(ZipcodeRecord record : zipcodes)
		{
			zipcodePDF.put(record, 1.0);
		}
		
		Sampler<Store> sampler = new StoreSampler(new SequenceSampler(), 
				RouletteWheelSampler.create(zipcodePDF, factory));
		
		Store store = sampler.sample();
		assertNotNull(store);
		assertTrue(store.getId() >= 0);
		assertNotNull(store.getName());
		assertNotNull(store.getLocation());
		
	}

}

@@ -165,20 +165,22 @@
 va.util.
-List
+Arrays
 ;%0Aimport
@@ -190,19 +190,26 @@
 va.util.
-Map
+Collection
 ;%0A%0Aimpor
@@ -272,25 +272,31 @@
 nerator.
-Constants
+datamodels.Pair
 ;%0Aimport
@@ -442,80 +442,8 @@
 re;%0A
-import com.github.rnowling.bps.datagenerator.datareaders.ZipcodeReader;%0A
 impo
@@ -749,123 +749,8 @@
 ler;
-%0Aimport com.github.rnowling.bps.datagenerator.generators.store.StoreSampler;%0Aimport com.google.common.collect.Maps;
 %0A%0Apu
@@ -840,223 +840,231 @@
 %7B%0A%09%09
-ZipcodeReader reader = new ZipcodeReader();%0A%09%09reader.setCoordinatesFile(Constants.COORDINATES_FILE);%0A%09%09reader.setIncomesFile(Constants.INCOMES_FILE);%0A%09%09reader.setPopulationFile(Constants.POPULATION_FILE);
+Collection%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
-%0A
 %09%09
-List%3C
+new 
 Zipc
@@ -1076,75 +1076,60 @@
 cord
-%3E zipcodes = reade
+(%2233333%22, Pai
 r.
+c
 rea
-dData();%0A%09%09%0A%09%09assertTrue(zipcodes.size() %3E 0
+te(3.0, 3.0), 60000.0, 300)%0A%09%09%09%09%7D
 );%0A%09
@@ -1184,151 +1184,8 @@
 %0A%09%09%0A
-%09%09Map%3CZipcodeRecord, Double%3E zipcodePDF = Maps.newHashMap();%0A%09%09for(ZipcodeRecord record : zipcodes)%0A%09%09%7B%0A%09%09%09zipcodePDF.put(record, 1.0);%0A%09%09%7D%0A%09%09%0A
 %09%09Sa
@@ -1283,16 +1283,23 @@
 eate
+Uniform
 (zipcode
 PDF,
@@ -1298,11 +1298,9 @@
 code
-PDF
+s
 , fa

Remove file reader dependencies in TestStoreStampler