<commit_before>package support;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import org.apache.commons.lang.StringUtils;

import eu.choreos.vv.increasefunctions.ExponentialIncrease;
import eu.choreos.vv.increasefunctions.LinearIncrease;
import eu.choreos.vv.increasefunctions.QuadraticIncrease;
import eu.choreos.vv.increasefunctions.ScalabilityFunction;

public class TestConfiguration {
	private static final String TEST_CONFIG_YML = "test_configuration.yml";
	public static int requestsPerStep, numberOfSteps, initialCapacityValue, increaseCapacityFunctionParameter, initialWorkloadValue, increaseWorkloadFunctionParameter;
	public static ScalabilityFunction increaseCapacityFunctionObject, increaseWorkloadFunctionObject;
	public static String subjectName, increaseWorkloadFunction, increaseCapacityFunction;
	public static String metric;
	public static boolean plotGraph;
	
	public TestConfiguration(String filename) throws FileNotFoundException, InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
		readParameters(filename);
	}

	private static void readParameters(String filename)
			throws FileNotFoundException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
		BufferedReader bufferedReader = new BufferedReader(new FileReader(filename));
		metric = bufferedReader.readLine();
		requestsPerStep = readInteger(bufferedReader);
		numberOfSteps = readInteger(bufferedReader);

		initialCapacityValue = readInteger(bufferedReader);
		increaseCapacityFunction = bufferedReader.readLine().toLowerCase();
		increaseCapacityFunctionParameter = readInteger(bufferedReader);

		initialWorkloadValue = readInteger(bufferedReader);
		increaseWorkloadFunction = bufferedReader.readLine().toLowerCase();
		increaseWorkloadFunctionParameter = readInteger(bufferedReader);
				
		increaseCapacityFunctionObject = getIncreaseFunction(increaseCapacityFunction, increaseCapacityFunctionParameter);
		increaseWorkloadFunctionObject = getIncreaseFunction(increaseWorkloadFunction, increaseWorkloadFunctionParameter);
		
		plotGraph = Boolean.parseBoolean(bufferedReader.readLine());
		subjectName = bufferedReader.readLine();
		
		bufferedReader.close();
	}
	
	private static ScalabilityFunction getIncreaseFunction(String increaseFunction, int increaseFunctionParameter) {
		ScalabilityFunction increaseFunctionObject = null;
		if (increaseFunction.startsWith("linear")) {
			increaseFunctionObject = new LinearIncrease(increaseFunctionParameter);
		} else if (increaseFunction.startsWith("exponential")) {
			increaseFunctionObject = new ExponentialIncrease(increaseFunctionParameter);
		} else if (increaseFunction.startsWith("quadratic")) {
			increaseFunctionObject = new QuadraticIncrease(increaseFunctionParameter);
		} else {
			System.out.println("Wrong argument for increase function: " + increaseFunction + "\nExpected: linear, exponential or quadratic");
		}
		return increaseFunctionObject;
	}
	
	private static int readInteger(BufferedReader bufferedReader) throws IOException {
		return Integer.parseInt(bufferedReader.readLine());
	}
}<commit_msg>Changed test configuration reader to YAML instead of a text file<commit_after>package support;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;

import org.yaml.snakeyaml.Yaml;

import eu.choreos.vv.increasefunctions.ExponentialIncrease;
import eu.choreos.vv.increasefunctions.LinearIncrease;
import eu.choreos.vv.increasefunctions.QuadraticIncrease;
import eu.choreos.vv.increasefunctions.ScalabilityFunction;

public class TestConfiguration {
	public static int requestsPerStep, numberOfSteps, initialCapacityValue, increaseCapacityFunctionParameter, initialWorkloadValue, increaseWorkloadFunctionParameter;
	public static ScalabilityFunction increaseCapacityFunctionObject, increaseWorkloadFunctionObject;
	public static String subjectName, increaseWorkloadFunction, increaseCapacityFunction;
	public static String metric;
	public static boolean plotGraph;
	
	public TestConfiguration(String filename) throws FileNotFoundException, InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
		readParameters(filename);
	}

	private static void readParameters(String filename)
			throws FileNotFoundException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
		Map<Object, Object> parameters = (Map<Object, Object>) new Yaml().load(new FileInputStream(new File(filename)));
		metric = (String) parameters.get("type");
		requestsPerStep = (Integer) parameters.get("requestsPerStep");
		numberOfSteps = (Integer) parameters.get("numberOfSteps");

		initialCapacityValue = (Integer) parameters.get("initialCapacityValue");
		increaseCapacityFunction = ((String) parameters.get("increaseCapacityFunction")).toLowerCase();
		increaseCapacityFunctionParameter = (Integer) parameters.get("increaseCapacityFunctionParameter");

		initialWorkloadValue = (Integer) parameters.get("initialWorkloadValue");
		increaseWorkloadFunction = ((String) parameters.get("increaseWorkloadFunction")).toLowerCase();
		increaseWorkloadFunctionParameter = (Integer) parameters.get("increaseWorkloadFunctionParameter");
				
		increaseCapacityFunctionObject = getIncreaseFunction(increaseCapacityFunction, increaseCapacityFunctionParameter);
		increaseWorkloadFunctionObject = getIncreaseFunction(increaseWorkloadFunction, increaseWorkloadFunctionParameter);
		
		plotGraph = (Boolean) parameters.get("plotGraph");
		subjectName = (String) parameters.get("experientName");
	}
	
	private static ScalabilityFunction getIncreaseFunction(String increaseFunction, int increaseFunctionParameter) {
		ScalabilityFunction increaseFunctionObject = null;
		if (increaseFunction.startsWith("linear")) {
			increaseFunctionObject = new LinearIncrease(increaseFunctionParameter);
		} else if (increaseFunction.startsWith("exponential")) {
			increaseFunctionObject = new ExponentialIncrease(increaseFunctionParameter);
		} else if (increaseFunction.startsWith("quadratic")) {
			increaseFunctionObject = new QuadraticIncrease(increaseFunctionParameter);
		} else {
			System.out.println("Wrong argument for increase function: " + increaseFunction + "\nExpected: linear, exponential or quadratic");
		}
		return increaseFunctionObject;
	}
}
{'fraction_non_alphanumeric': 0.07919566898685228, 'fraction_numerical': 0.0, 'mean_word_length': 8.290229885057471, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6521298', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1573, 'n_words': 335}