package cl.fatman.capital.fund;

import static org.junit.Assert.*;
import org.junit.Test;

import java.time.LocalDate;
import java.util.Map;

public class ExtractFundDataTest {	
	
	
	@Test
	public void fundDataNotNullTest() {
		String link = "http://www.aafm.cl/tecnoera/index.php";
		String userAgent = "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.108 Safari/537.36";
		LocalDate queryDate = LocalDate.of(2016, 1, 1);
		ExtractFundData efData = new ExtractFundData(link, userAgent);
		assertNotNull("Fund map should not be null", efData.getFundData(queryDate, "Deuda < 90 días", 1));
	}
	
	
	@Test
	public void fundDataNotEmptyTest() {
		String link = "http://www.aafm.cl/tecnoera/index.php";
		String userAgent = "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.108 Safari/537.36";
		LocalDate queryDate = LocalDate.of(2016, 1, 1);
		ExtractFundData efData = new ExtractFundData(link, userAgent);
		Map<Fund, Double>  tmpMap = efData.getFundData(queryDate, "Deuda < 90 días", 1);
		assertFalse("Fund map should not be empty.", tmpMap.isEmpty()); 
	}
	
	
	@Test
	public void fundDataNullTest() {
		String link = "";
		String userAgent = "";
		LocalDate queryDate = LocalDate.of(2016, 1, 1);
		ExtractFundData efData = new ExtractFundData(link, userAgent);
		assertNull("Fund map should be null.", efData.getFundData(queryDate, "Deuda < 90 días", 1));
	}
	
	
	@Test
	public void fundDataEmptyTest() {
		String link = "http://www.aafm.cl/tecnoera/index.php";
		String userAgent = "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.108 Safari/537.36";
		LocalDate queryDate = LocalDate.of(1970, 1, 1);
		ExtractFundData efData = new ExtractFundData(link, userAgent);
		Map<Fund, Double>  tmpMap = efData.getFundData(queryDate, "Deuda < 90 días", 1);
		assertTrue("Fund map should be empty.", tmpMap.isEmpty()); 
	}
}
@@ -60,16 +60,41 @@
 sert.*;%0A
+import org.junit.Before;%0A
 import o
@@ -198,365 +198,499 @@
 st %7B
-%09
 %0A%09%0A%09
-%0A%09@Test%0A%09public void fundDataNotNullTest() %7B%0A%09%09String link = %22http://www.aafm.cl/tecnoera/index.php%22;%0A%09%09String userAgent = %22Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.108 Safari/537.36%22;%0A%09%09LocalDate queryDate = LocalDate.of(2016, 1, 1);%0A%09%09ExtractFundData efData = new ExtractFundData(link, userAgent
+private ExtractFundData efData;%0A%09private FundProperties fProperties;%0A%09%0A%09@Before%0A%09public void setUp() %7B%0A%09%09fProperties = new FundProperties(%22fund.properties%22);%0A%09%09fProperties.readProperties();%0A%09%09String userAgent = fProperties.getUserAgent();%0A%09%09String link = fProperties.getFundLink();%0A%09%09String baseQuery = fProperties.getFundQuery();%0A%09%09efData = new ExtractFundData(link, userAgent, baseQuery);%0A%09%7D%0A%09%0A%09@Test%0A%09public void fundDataNotNullTest() %7B%0A%09%09LocalDate queryDate = LocalDate.of(2016, 1, 1
 );%0A%09
@@ -786,34 +786,32 @@
 %C3%ADas%22, 1));%0A%09%7D%0A%09%0A
-%09%0A
 %09@Test%0A%09public v
@@ -845,313 +845,53 @@
 %7B%0A%09%09
-String link = %22http://www.aafm.cl/tecnoera/index.php%22;%0A%09%09String userAgent = %22Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.108 Safari/537.36%22;%0A%09%09LocalDate queryDate = LocalDate.of(2016, 1, 1);%0A%09%09ExtractFundData efData = new ExtractFundData(link, userAgent
+LocalDate queryDate = LocalDate.of(2016, 1, 1
 );%0A%09
@@ -1040,26 +1040,24 @@
 y()); %0A%09%7D%0A%09%0A
-%09%0A
 %09@Test%0A%09publ
@@ -1089,53 +1089,8 @@
 ) %7B%0A
-%09%09String link = %22%22;%0A%09%09String userAgent = %22%22;%0A
 %09%09Lo
@@ -1141,68 +1141,49 @@
 ;%0A%09%09
-ExtractFundData efData = new ExtractFundData(link, u
+efData.setLink(%22%22);%0A%09%09efData.setU
 serAgent
 );%0A%09
@@ -1174,24 +1174,27 @@
 setUserAgent
+(%22%22
 );%0A%09%09assertN
@@ -1284,18 +1284,16 @@
 );%0A%09%7D%0A%09%0A
-%09%0A
 %09@Test%0A%09
@@ -1332,313 +1332,53 @@
 %7B%0A%09%09
-String link = %22http://www.aafm.cl/tecnoera/index.php%22;%0A%09%09String userAgent = %22Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.108 Safari/537.36%22;%0A%09%09LocalDate queryDate = LocalDate.of(1970, 1, 1);%0A%09%09ExtractFundData efData = new ExtractFundData(link, userAgent
+LocalDate queryDate = LocalDate.of(1970, 1, 1
 );%0A%09

Update junit test after the changes in the extract fund data, also improve the code in junit class.