// Path: src/main/java/com/jfcorugedo/rserver/common/collection/CollectionUtils.java
// @SafeVarargs
// public static <T> List<T> newList(T... values) {
// 	List<T> arrayList = new ArrayList<>(values.length);
// 	for(T element : values) {
// 		arrayList.add(element);
// 	}
// 		
// 	return arrayList;
// }


import static com.jfcorugedo.rserver.common.collection.CollectionUtils.newList;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.apache.commons.math3.distribution.EnumeratedDistribution;
import org.apache.commons.math3.util.Pair;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.rosuda.REngine.REXP;
import org.rosuda.REngine.REXPDouble;
import org.rosuda.REngine.REXPGenericVector;
import org.rosuda.REngine.REXPInteger;
import org.rosuda.REngine.REXPString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
		providerService = new JRIEngineProviderService();
		providerService.setBlockFunction("source(\"/Users/jfcorugedo/Documents/git/kmd/kmd-math/blockFunction.R\")");
		providerService.setUpR();
	}

	@Test
	public void testBlockFunction() throws Exception{
	
		for(int i = 0 ; i < 100 ; i++) {
			REXP result = providerService.blockFunction(new REXPInteger(generateIds(200)), new REXPDouble(TEST_BIG_POPULATION));
			if(LOGGER.isInfoEnabled()) {
				LOGGER.info(blockResultToString(result));
			}
		}
	}
	
	@Test
	@Ignore
	public void testBlockDiscreteFunction() {
	
		REXP result = providerService.blockDiscreteFunction(new REXPInteger(generateIds(200)), new REXPString(generateRandomCities(200)));
		
		if(LOGGER.isInfoEnabled()) {
			LOGGER.info(blockResultToString(result));
		}
	}
	
	private String[] generateRandomCities(int sampleSize) {
		EnumeratedDistribution<String> cityDistribution = 
				new EnumeratedDistribution<String>(
// Path: src/main/java/com/jfcorugedo/rserver/common/collection/CollectionUtils.java
// @SafeVarargs
// public static <T> List<T> newList(T... values) {
// 	List<T> arrayList = new ArrayList<>(values.length);
// 	for(T element : values) {
// 		arrayList.add(element);
// 	}
// 		
// 	return arrayList;
// }


// Path: src/test/java/com/jfcorugedo/rserver/engine/JRIEngineProviderServiceIT.java
import static com.jfcorugedo.rserver.common.collection.CollectionUtils.newList;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.apache.commons.math3.distribution.EnumeratedDistribution;
import org.apache.commons.math3.util.Pair;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.rosuda.REngine.REXP;
import org.rosuda.REngine.REXPDouble;
import org.rosuda.REngine.REXPGenericVector;
import org.rosuda.REngine.REXPInteger;
import org.rosuda.REngine.REXPString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

		providerService = new JRIEngineProviderService();
		providerService.setBlockFunction("source(\"/Users/jfcorugedo/Documents/git/kmd/kmd-math/blockFunction.R\")");
		providerService.setUpR();
	}

	@Test
	public void testBlockFunction() throws Exception{
	
		for(int i = 0 ; i < 100 ; i++) {
			REXP result = providerService.blockFunction(new REXPInteger(generateIds(200)), new REXPDouble(TEST_BIG_POPULATION));
			if(LOGGER.isInfoEnabled()) {
				LOGGER.info(blockResultToString(result));
			}
		}
	}
	
	@Test
	@Ignore
	public void testBlockDiscreteFunction() {
	
		REXP result = providerService.blockDiscreteFunction(new REXPInteger(generateIds(200)), new REXPString(generateRandomCities(200)));
		
		if(LOGGER.isInfoEnabled()) {
			LOGGER.info(blockResultToString(result));
		}
	}
	
	private String[] generateRandomCities(int sampleSize) {
		EnumeratedDistribution<String> cityDistribution = 
				new EnumeratedDistribution<String>(
													newList(