<commit_before>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()); <commit_msg>Update junit test after the changes in the extract fund data, also improve the code in junit class.<commit_after>package cl.fatman.capital.fund;

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

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

public class ExtractFundDataTest {
	
	private ExtractFundData efData;
	private FundProperties fProperties;
	
	@Before
	public void setUp() {
		fProperties = new FundProperties("fund.properties");
		fProperties.readProperties();
		String userAgent = fProperties.getUserAgent();
		String link = fProperties.getFundLink();
		String baseQuery = fProperties.getFundQuery();
		efData = new ExtractFundData(link, userAgent, baseQuery);
	}
	
	@Test
	public void fundDataNotNullTest() {
		LocalDate queryDate = LocalDate.of(2016, 1, 1);
		assertNotNull("Fund map should not be null", efData.getFundData(queryDate, "Deuda < 90 días", 1));
	}
	
	@Test
	public void fundDataNotEmptyTest() {
		LocalDate queryDate = LocalDate.of(2016, 1, 1);
		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() {
		LocalDate queryDate = LocalDate.of(2016, 1, 1);
		efData.setLink("");
		efData.setUserAgent("");
		assertNull("Fund map should be null.", efData.getFundData(queryDate, "Deuda < 90 días", 1));
	}
	
	@Test
	public void fundDataEmptyTest() {
		LocalDate queryDate = LocalDate.of(1970, 1, 1);
		Map<Fund, Double>  tmpMap = efData.getFundData(queryDate, "Deuda < 90 días", 1);
		assertTrue("Fund map should be empty.", tmpMap.isEmpty()); 
{'fraction_non_alphanumeric': 0.1300386526780784, 'fraction_numerical': 0.04307012700165654, 'mean_word_length': 4.678683385579937, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3750697', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1219, 'n_words': 321}