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

import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.List;

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;

public class TestCustomerLocationPDF
{

	@Test
	public void testProbability() 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();
		
		List<Store> stores = new ArrayList<Store>();
		for(int i = 0; i < 10; i++)
		{
			Store store = new Store(i, "Store_" + i, zipcodes.get(i));
			stores.add(store);
		}
		
		CustomerLocationPDF customerLocationPDF = new CustomerLocationPDF(zipcodes, stores, 
					Constants.AVERAGE_CUSTOMER_STORE_DISTANCE);
		
		double prob = customerLocationPDF.probability(zipcodes.get(0));
		
		assertTrue(prob > 0.0);
	}

}

@@ -133,16 +133,41 @@
 ayList;%0A
+import java.util.Arrays;%0A
 import j
@@ -177,24 +177,24 @@
 .util.List;%0A
-
 %0Aimport org.
@@ -262,16 +262,78 @@
 stants;%0A
+import com.github.rnowling.bps.datagenerator.datamodels.Pair;%0A
 import c
@@ -476,80 +476,8 @@
 ore;
-%0Aimport com.github.rnowling.bps.datagenerator.datareaders.ZipcodeReader;
 %0A%0Apu
@@ -574,16 +574,21 @@
 on%0A%09%7B%0A%09%09
+List%3C
 ZipcodeR
@@ -592,20 +592,21 @@
 deRe
-ader
+cord%3E
  zipcode
 Read
@@ -605,276 +605,263 @@
 code
-Reader = 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
+s = 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(
+te(3.0, 3.0), 60000.0, 300)%0A%09%09%09%09%7D
 );%0A%09
@@ -930,18 +930,31 @@
  0; i %3C 
-10
+zipcodes.size()
 ; i++)%0A%09

remove file reader dependency from TestCustomerLocationPFD