diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNIOParameters.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNIOParameters.java
index c94126cd934259e488ae7936dc57499eae43de4f..b6974f147d7432d4f19008f8ce04f45712753332 100644
--- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNIOParameters.java
+++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/data/BPMNIOParameters.java
@@ -1,173 +1,199 @@
-package de.fhmuenster.masterthesis.Testgenerator.bpmn.data;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-public class BPMNIOParameters {
-
-	private HashMap<String, List<String>> inputVariables = new HashMap<String, List<String>>();
-	private HashMap<String, List<String>> outputVariables = new HashMap<String, List<String>>();
-	private HashMap<String, List<String>> innerOutputVariables = new HashMap<String, List<String>>();
-	
-	private HashMap<String, HashMap<String, String>> hardcodedInputParametersString = new HashMap<String, HashMap<String, String>>();
-	private HashMap<String, HashMap<String, Long>> hardcodedInputParametersLong = new HashMap<String, HashMap<String, Long>>();
-	private HashMap<String, HashMap<String, Boolean>> hardcodedInputParametersBoolean = new HashMap<String, HashMap<String, Boolean>>();
-
-	public BPMNIOParameters() {
-	}
-
-	public HashMap<String, List<String>> getInputParameters() {
-		return inputVariables;
-	}
-	
-	public List<String> getInputVariables(String taskId) {
-		return inputVariables.entrySet().stream() //
-			.filter(entry -> entry.getKey().equals(taskId)) //
-			.flatMap(entry -> entry.getValue().stream()) //
-			.distinct() //
-			.collect(Collectors.toList()); //
-	}
-	
-	public List<String> getOutputVariables(String taskId) {
-		return outputVariables.entrySet().stream() //
-			.filter(entry -> entry.getKey().equals(taskId)) //
-			.flatMap(entry -> entry.getValue().stream()) //
-			.distinct() //
-			.collect(Collectors.toList()); //
-	}
-
-	public HashMap<String, List<String>> getOutputParameters() {
-		return outputVariables;
-	}
-
-	public void addInputVariable(String flowElementId, String inputVariableName) {
-		List<String> existingVariables = this.inputVariables.get(flowElementId);
-		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
-		variables.add(inputVariableName);
-		
-		this.inputVariables.put(flowElementId, variables);
-	}
-	
-	public void addInputVariables(String flowElementId, List<String> inputVariables) {
-		List<String> existingVariables = this.inputVariables.get(flowElementId);
-		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
-		variables.addAll(inputVariables);
-		
-		this.inputVariables.put(flowElementId, variables);
-	}
-
-	public void addOutputVariable(String flowElementId, String outputVariable) {
-		List<String> existingVariables = this.outputVariables.get(flowElementId);
-		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
-		variables.add(outputVariable);
-		
-		this.outputVariables.put(flowElementId, variables);
-	}
-	
-	public void addInnerOutputVariable(String flowElementId, String outputVariable) {
-		List<String> existingVariables = this.innerOutputVariables.get(flowElementId);
-		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
-		variables.add(outputVariable);
-		
-		this.innerOutputVariables.put(flowElementId, variables);
-	}
-	
-	public void addOutputVariables(String flowElementId, List<String> outputVariables) {
-		List<String> existingVariables = this.outputVariables.get(flowElementId);
-		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
-		variables.addAll(outputVariables);
-		
-		this.outputVariables.put(flowElementId, variables);
-	}
-
-	public void addHardcodedInputParameterString(String flowElementId, String inputVariable, String value) {
-		HashMap<String, String> existingVariables = this.hardcodedInputParametersString.get(flowElementId);
-		HashMap<String, String> variables = existingVariables != null ? existingVariables : new HashMap<>();
-		variables.put(inputVariable, value);
-		
-		this.hardcodedInputParametersString.put(flowElementId, variables);
-	}
-	
-	public void addHardcodedInputParameterLong(String flowElementId, String inputVariable, Long value) {
-		HashMap<String, Long> existingVariables = this.hardcodedInputParametersLong.get(flowElementId);
-		HashMap<String, Long> variables = existingVariables != null ? existingVariables : new HashMap<>();
-		variables.put(inputVariable, value);
-		
-		this.hardcodedInputParametersLong.put(flowElementId, variables);
-	}
-	
-	public void addHardcodedInputParameterBoolean(String flowElementId, String inputVariable, Boolean value) {
-		HashMap<String, Boolean> existingVariables = this.hardcodedInputParametersBoolean.get(flowElementId);
-		HashMap<String, Boolean> variables = existingVariables != null ? existingVariables : new HashMap<>();
-		variables.put(inputVariable, value);
-		
-		this.hardcodedInputParametersBoolean.put(flowElementId, variables);
-	}
-	
-	public List<String> getVariables() {
-		return Stream.concat(Stream.concat(inputVariables.values().stream(), outputVariables.values().stream()), innerOutputVariables.values().stream()) //
-				.flatMap(variableList -> variableList.stream()) //
-				.distinct() //
-				.collect(Collectors.toList()); //
-	}
-	
-	public HashMap<String, String> getHardcodedInputParametersString(String flowElementId) {
-		return hardcodedInputParametersString.get(flowElementId);
-	}
-	
-	public HashMap<String, Long> getHardcodedInputParametersLong(String flowElementId) {
-		return hardcodedInputParametersLong.get(flowElementId);
-	}
-	
-	public HashMap<String, Boolean> getHardcodedInputParametersBoolean(String flowElementId) {
-		return hardcodedInputParametersBoolean.get(flowElementId);
-	}
-	
-	public List<String> getHardcodedInputParametersString() {
-		return hardcodedInputParametersString.values().stream() //
-			.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
-			.distinct() //
-			.collect(Collectors.toList()); //
-	}
-	
-	public List<String> getHardcodedInputParametersLong() {
-		return hardcodedInputParametersLong.values().stream() //
-			.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
-			.distinct() //
-			.collect(Collectors.toList()); //
-	}
-	
-	public List<String> getHardcodedInputParametersBoolean() {
-		return hardcodedInputParametersBoolean.values().stream() //
-			.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
-			.distinct() //
-			.collect(Collectors.toList()); //
-	}
-	
-	public List<String> getHardcodedInputParameters() {
-		List<String> hardcodedInputParameters = new ArrayList<>();
-		hardcodedInputParameters.addAll(getHardcodedInputParametersString());
-		hardcodedInputParameters.addAll(getHardcodedInputParametersLong());
-		hardcodedInputParameters.addAll(getHardcodedInputParametersBoolean());
-		
-		return hardcodedInputParameters;
-	}
-	
-	public List<String> getHardcodedInputParameterValuesString(String parameter) {
-		return hardcodedInputParametersString.values().stream() //
-			.map(parameterValueMap -> parameterValueMap.get(parameter)) //
-			.filter(value -> value != null) //
-			.distinct() //
-			.collect(Collectors.toList()); //
-	}
-	
-	public List<Long> getHardcodedInputParameterValuesLong(String parameter) {
-		return hardcodedInputParametersLong.values().stream() //
-			.map(parameterValueMap -> parameterValueMap.get(parameter)) //
-			.distinct() //
-			.collect(Collectors.toList()); //
-	}
-}
+package de.fhmuenster.masterthesis.Testgenerator.bpmn.data;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class BPMNIOParameters {
+
+	private HashMap<String, List<String>> inputVariables = new HashMap<String, List<String>>();
+	private HashMap<String, List<String>> outputVariables = new HashMap<String, List<String>>();
+	private HashMap<String, List<String>> innerOutputVariables = new HashMap<String, List<String>>();
+	private HashMap<String, List<String>> removeVariables = new HashMap<String, List<String>>();
+	
+	private HashMap<String, HashMap<String, String>> hardcodedInputParametersString = new HashMap<String, HashMap<String, String>>();
+	private HashMap<String, HashMap<String, Long>> hardcodedInputParametersLong = new HashMap<String, HashMap<String, Long>>();
+	private HashMap<String, HashMap<String, Boolean>> hardcodedInputParametersBoolean = new HashMap<String, HashMap<String, Boolean>>();
+
+	public BPMNIOParameters() {
+	}
+
+	public HashMap<String, List<String>> getInputParameters() {
+		return inputVariables;
+	}
+	
+	public List<String> getInputVariables(String taskId) {
+		return inputVariables.entrySet().stream() //
+			.filter(entry -> entry.getKey().equals(taskId)) //
+			.flatMap(entry -> entry.getValue().stream()) //
+			.distinct() //
+			.collect(Collectors.toList()); //
+	}
+	
+	public List<String> getOutputVariables(String taskId) {
+		return outputVariables.entrySet().stream() //
+			.filter(entry -> entry.getKey().equals(taskId)) //
+			.flatMap(entry -> entry.getValue().stream()) //
+			.distinct() //
+			.collect(Collectors.toList()); //
+	}
+
+	public HashMap<String, List<String>> getOutputParameters() {
+		return outputVariables;
+	}
+	
+	/**
+	 * 15.12.2021
+	 * getRemoveVariables on BPMNIOParameters
+	 * @param taskId
+	 */
+	public List<String> getRemoveVariables(String taskId) {
+		return removeVariables.entrySet().stream() //
+			.filter(entry -> entry.getKey().equals(taskId)) //
+			.flatMap(entry -> entry.getValue().stream()) //
+			.distinct() //
+			.collect(Collectors.toList()); //
+	}
+		
+	/**
+	 * 15.12.2021
+	 * addRemoveVariable add removeVariable to HashMap removeVariables to use it on BPMNIOParameters
+	 * @param taskId
+	 */
+	public void addRemoveVariable(String flowElementId, String removeVariable) {
+		List<String> existingVariables = this.removeVariables.get(flowElementId);
+		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
+		variables.add(removeVariable);
+		this.removeVariables.put(flowElementId, variables);
+	}
+
+	public void addInputVariable(String flowElementId, String inputVariableName) {
+		List<String> existingVariables = this.inputVariables.get(flowElementId);
+		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
+		variables.add(inputVariableName);
+		
+		this.inputVariables.put(flowElementId, variables);
+	}
+	
+	public void addInputVariables(String flowElementId, List<String> inputVariables) {
+		List<String> existingVariables = this.inputVariables.get(flowElementId);
+		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
+		variables.addAll(inputVariables);
+		
+		this.inputVariables.put(flowElementId, variables);
+	}
+
+	public void addOutputVariable(String flowElementId, String outputVariable) {
+		List<String> existingVariables = this.outputVariables.get(flowElementId);
+		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
+		variables.add(outputVariable);
+		
+		this.outputVariables.put(flowElementId, variables);
+	}
+	
+	public void addInnerOutputVariable(String flowElementId, String outputVariable) {
+		List<String> existingVariables = this.innerOutputVariables.get(flowElementId);
+		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
+		variables.add(outputVariable);
+		
+		this.innerOutputVariables.put(flowElementId, variables);
+	}
+	
+	public void addOutputVariables(String flowElementId, List<String> outputVariables) {
+		List<String> existingVariables = this.outputVariables.get(flowElementId);
+		List<String> variables = existingVariables != null ? existingVariables : new ArrayList<>();
+		variables.addAll(outputVariables);
+		
+		this.outputVariables.put(flowElementId, variables);
+	}
+
+	public void addHardcodedInputParameterString(String flowElementId, String inputVariable, String value) {
+		HashMap<String, String> existingVariables = this.hardcodedInputParametersString.get(flowElementId);
+		HashMap<String, String> variables = existingVariables != null ? existingVariables : new HashMap<>();
+		variables.put(inputVariable, value);
+		
+		this.hardcodedInputParametersString.put(flowElementId, variables);
+	}
+	
+	public void addHardcodedInputParameterLong(String flowElementId, String inputVariable, Long value) {
+		HashMap<String, Long> existingVariables = this.hardcodedInputParametersLong.get(flowElementId);
+		HashMap<String, Long> variables = existingVariables != null ? existingVariables : new HashMap<>();
+		variables.put(inputVariable, value);
+		
+		this.hardcodedInputParametersLong.put(flowElementId, variables);
+	}
+	
+	public void addHardcodedInputParameterBoolean(String flowElementId, String inputVariable, Boolean value) {
+		HashMap<String, Boolean> existingVariables = this.hardcodedInputParametersBoolean.get(flowElementId);
+		HashMap<String, Boolean> variables = existingVariables != null ? existingVariables : new HashMap<>();
+		variables.put(inputVariable, value);
+		
+		this.hardcodedInputParametersBoolean.put(flowElementId, variables);
+	}
+	
+	public List<String> getVariables() {
+		return Stream.concat(Stream.concat(inputVariables.values().stream(), outputVariables.values().stream()), innerOutputVariables.values().stream()) //
+				.flatMap(variableList -> variableList.stream()) //
+				.distinct() //
+				.collect(Collectors.toList()); //
+	}
+	
+	public HashMap<String, String> getHardcodedInputParametersString(String flowElementId) {
+		return hardcodedInputParametersString.get(flowElementId);
+	}
+	
+	public HashMap<String, Long> getHardcodedInputParametersLong(String flowElementId) {
+		return hardcodedInputParametersLong.get(flowElementId);
+	}
+	
+	public HashMap<String, Boolean> getHardcodedInputParametersBoolean(String flowElementId) {
+		return hardcodedInputParametersBoolean.get(flowElementId);
+	}
+	
+	public List<String> getHardcodedInputParametersString() {
+		return hardcodedInputParametersString.values().stream() //
+			.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
+			.distinct() //
+			.collect(Collectors.toList()); //
+	}
+	
+	public List<String> getHardcodedInputParametersLong() {
+		return hardcodedInputParametersLong.values().stream() //
+			.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
+			.distinct() //
+			.collect(Collectors.toList()); //
+	}
+	
+	public List<String> getHardcodedInputParametersBoolean() {
+		return hardcodedInputParametersBoolean.values().stream() //
+			.flatMap(parameterValueMap -> parameterValueMap.keySet().stream()) //
+			.distinct() //
+			.collect(Collectors.toList()); //
+	}
+	
+	public List<String> getHardcodedInputParameters() {
+		List<String> hardcodedInputParameters = new ArrayList<>();
+		hardcodedInputParameters.addAll(getHardcodedInputParametersString());
+		hardcodedInputParameters.addAll(getHardcodedInputParametersLong());
+		hardcodedInputParameters.addAll(getHardcodedInputParametersBoolean());
+		
+		return hardcodedInputParameters;
+	}
+	
+	public List<String> getHardcodedInputParameterValuesString(String parameter) {
+		return hardcodedInputParametersString.values().stream() //
+			.map(parameterValueMap -> parameterValueMap.get(parameter)) //
+			.filter(value -> value != null) //
+			.distinct() //
+			.collect(Collectors.toList()); //
+	}
+	
+	public List<Long> getHardcodedInputParameterValuesLong(String parameter) {
+		return hardcodedInputParametersLong.values().stream() //
+			.map(parameterValueMap -> parameterValueMap.get(parameter)) //
+			.distinct() //
+			.collect(Collectors.toList()); //
+	}
+}
diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/processfragmentation/BPMNVariableIOScanner.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/processfragmentation/BPMNVariableIOScanner.java
index 0758bf307329771759e4ee8be0c8d2235f074c05..728ac168f36b856db6ac3574a0931e0c3e7dff4f 100644
--- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/processfragmentation/BPMNVariableIOScanner.java
+++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/bpmn/processfragmentation/BPMNVariableIOScanner.java
@@ -1,125 +1,204 @@
-package de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-import org.camunda.bpm.model.bpmn.instance.BaseElement;
-import org.camunda.bpm.model.bpmn.instance.FlowElement;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaOutputParameter;
-
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlowSet;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNIOParameters;
-
-public class BPMNVariableIOScanner {
-
-	private static final String VARIABLE_MATCH_REGEX = "\\$\\{(.*?)\\}";
-	private static final String INT_MATCH_REGEX = "[0-9]+";
-	private static final String BOOLEAN_MATCH_REGEX = "true|false";
-	
-	private static final String NAMESPACE_URI_BPMN = "http://camunda.org/schema/1.0/bpmn";
-	private static final String INPUT_OUTPUT_NAME = "inputOutput";
-	
-	private BPMNFlowSet flowSet;
-	private BPMNIOParameters bpmnIOParameters;
-	
-	public BPMNVariableIOScanner(BPMNFlowSet flowSet) {
-		this.flowSet = flowSet;
-		this.bpmnIOParameters = new BPMNIOParameters();
-	}
-	
-	public void doScan() {
-		List<FlowElement> extensionElements = flowSet.getFlowElements().stream() //
-			.filter(baseElement -> ((BaseElement) baseElement).getExtensionElements() != null) //
-			.collect(Collectors.toList()); //
-		
-		extensionElements
-			.forEach(baseElement -> scanInputs(baseElement)); //
-
-		extensionElements
-			.forEach(baseElement -> scanOutputs(baseElement)); //
-	}
-	
-	private void scanInputs(FlowElement baseElement) {
-		baseElement.getExtensionElements().getElements().stream() //
-			.filter(extensionElement -> extensionElement.getElementType().getTypeName().equals(INPUT_OUTPUT_NAME)) //
-			.flatMap(formData -> formData.getChildElementsByType(CamundaInputParameter.class).stream()) //
-			.map(inputParameter -> ((CamundaInputParameter) inputParameter)) //
-			.forEach(inputParameter -> insertInputParameter(baseElement, inputParameter)); //
-	}
-	
-	private void insertInputParameter(FlowElement baseElement, CamundaInputParameter inputParameter) {
-		//Input-Format --> Text muss verwendet werden
-		//<camunda:inputParameter name="ExternalServiceVariable">${ProcessVariable}</camunda:inputParameter>
-		String textContent = inputParameter.getTextContent();
-		List<String> variables = extractVariables(textContent);
-		
-		if(!variables.isEmpty()) {
-			bpmnIOParameters.addInputVariables(baseElement.getId(), variables);
-		} else {
-			//If no variables extracted --> it seems to be a hard set value
-			//Examples for hardcoded values: ${5}, ${true}, Teststring
-			addHardcodedInputVariable(baseElement.getId(), inputParameter.getCamundaName(), textContent);
-		}
-	}
-
-	private void addHardcodedInputVariable(String flowElementId, String inputParameter, String textContent) {
-		Pattern patternVariableMatch = Pattern.compile(VARIABLE_MATCH_REGEX);
-		Matcher matcherValue = patternVariableMatch.matcher(textContent);
-		
-		if(matcherValue.find()) {
-			String extractedValue = matcherValue.group(1);
-			
-			if(extractedValue.matches(INT_MATCH_REGEX)) {
-				bpmnIOParameters.addHardcodedInputParameterLong(flowElementId, inputParameter, Long.valueOf(extractedValue));
-			} else if(extractedValue.matches(BOOLEAN_MATCH_REGEX)) {
-				bpmnIOParameters.addHardcodedInputParameterBoolean(flowElementId, inputParameter, Boolean.valueOf(extractedValue));
-			}
-		} else {
-			bpmnIOParameters.addHardcodedInputParameterString(flowElementId, inputParameter, textContent);		
-		}
-	}
-
-	private void scanOutputs(FlowElement baseElement) {
-		baseElement.getExtensionElements().getElements().stream() //
-			.filter(extensionElement -> extensionElement.getElementType().getTypeName().equals(INPUT_OUTPUT_NAME)) //
-			.flatMap(formData -> formData.getChildElementsByType(CamundaOutputParameter.class).stream()) //
-			.map(outputParameter -> ((CamundaOutputParameter) outputParameter)) //
-			.forEach(outputParameter -> insertOutputParameter(baseElement, outputParameter)); //
-	}
-
-	private void insertOutputParameter(FlowElement baseElement, CamundaOutputParameter outputParameter) {
-		//Output-Format --> Name muss verwendet werden
-		//<camunda:outputParameter name="ProcessVariable">${ExternalServiceVariable}</camunda:outputParameter>
-		String textContent = outputParameter.getCamundaName();
-		bpmnIOParameters.addOutputVariable(baseElement.getId(), textContent);
-		
-		//Auf API-Seite wird der TextContent genutzt - für die Mocks relevant
-		String innerAPIParameter = outputParameter.getTextContent();
-		List<String> innerAPIVariables = extractVariables(innerAPIParameter);
-		innerAPIVariables.forEach(innerAPIVariable -> bpmnIOParameters.addInnerOutputVariable(baseElement.getId(), innerAPIVariable));
-	}
-	
-	public BPMNIOParameters getBpmnIOParameters() {
-		return bpmnIOParameters;
-	}
-	
-	private List<String> extractVariables(String ioParameter) {
-		List<String> variableMatches = new ArrayList<>();
-		
-		Pattern patternVariableMatch = Pattern.compile(VARIABLE_MATCH_REGEX);
-		Matcher matcherVariable = patternVariableMatch.matcher(ioParameter);
-		
-		while (matcherVariable.find()) {
-			String extractedVariable = matcherVariable.group(1);
-			if(!extractedVariable.matches(INT_MATCH_REGEX) && !extractedVariable.matches(BOOLEAN_MATCH_REGEX)) {
-				variableMatches.add(extractedVariable);
-			}
-		}
-		
-		return variableMatches;
-	}
-}
+package de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.camunda.bpm.model.bpmn.instance.BaseElement;
+import org.camunda.bpm.model.bpmn.instance.FlowElement;
+import org.camunda.bpm.model.bpmn.instance.camunda.CamundaInputParameter;
+import org.camunda.bpm.model.bpmn.instance.camunda.CamundaOutputParameter;
+import org.camunda.bpm.model.xml.instance.ModelElementInstance;
+
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlowSet;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNIOParameters;
+import de.fhmuenster.masterthesis.testgeneratorDSL.Variable;
+
+public class BPMNVariableIOScanner {
+
+	private static final String VARIABLE_MATCH_REGEX = "\\$\\{(.*?)\\}";
+	private static final String INT_MATCH_REGEX = "[0-9]+";
+	private static final String BOOLEAN_MATCH_REGEX = "true|false";
+	
+	private static final String NAMESPACE_URI_BPMN = "http://camunda.org/schema/1.0/bpmn";
+	private static final String INPUT_OUTPUT_NAME = "inputOutput";
+	private static final String EXECUTION_LISTENER = "executionListener";
+	
+	private BPMNFlowSet flowSet;
+	private BPMNIOParameters bpmnIOParameters;
+	
+	public BPMNVariableIOScanner(BPMNFlowSet flowSet) {
+		this.flowSet = flowSet;
+		this.bpmnIOParameters = new BPMNIOParameters();
+	}
+	
+	public void doScan() {
+		List<FlowElement> extensionElements = flowSet.getFlowElements().stream() //
+			.filter(baseElement -> ((BaseElement) baseElement).getExtensionElements() != null) //
+			.collect(Collectors.toList()); //
+		
+		extensionElements
+			.forEach(baseElement -> scanInputs(baseElement)); //
+
+		extensionElements
+			.forEach(baseElement -> scanOutputs(baseElement)); //
+		
+		/*
+		 * @Tim @Henning 
+		 * added routine to scan in Camunda the removeExpressions
+		 */
+		extensionElements
+		.forEach(baseElement -> scanRemoveExpressions(baseElement)); //
+		
+	}
+	
+	private void scanInputs(FlowElement baseElement) {
+		baseElement.getExtensionElements().getElements().stream() //
+			.filter(extensionElement -> extensionElement.getElementType().getTypeName().equals(INPUT_OUTPUT_NAME)) //
+			.flatMap(formData -> formData.getChildElementsByType(CamundaInputParameter.class).stream()) //
+			.map(inputParameter -> ((CamundaInputParameter) inputParameter)) //
+			.forEach(inputParameter -> insertInputParameter(baseElement, inputParameter)); //	
+	}
+	
+	private void insertInputParameter(FlowElement baseElement, CamundaInputParameter inputParameter) {
+		//Input-Format --> Text muss verwendet werden
+		//<camunda:inputParameter name="ExternalServiceVariable">${ProcessVariable}</camunda:inputParameter>
+		String textContent = inputParameter.getTextContent();
+		List<String> variables = extractVariables(textContent);
+		
+		if(!variables.isEmpty()) {
+			bpmnIOParameters.addInputVariables(baseElement.getId(), variables);
+		} else {
+			//If no variables extracted --> it seems to be a hard set value
+			//Examples for hardcoded values: ${5}, ${true}, Teststring
+			addHardcodedInputVariable(baseElement.getId(), inputParameter.getCamundaName(), textContent);
+		}
+	}
+
+	private void addHardcodedInputVariable(String flowElementId, String inputParameter, String textContent) {
+		Pattern patternVariableMatch = Pattern.compile(VARIABLE_MATCH_REGEX);
+		Matcher matcherValue = patternVariableMatch.matcher(textContent);
+		
+		if(matcherValue.find()) {
+			String extractedValue = matcherValue.group(1);
+			
+			if(extractedValue.matches(INT_MATCH_REGEX)) {
+				bpmnIOParameters.addHardcodedInputParameterLong(flowElementId, inputParameter, Long.valueOf(extractedValue));
+			} else if(extractedValue.matches(BOOLEAN_MATCH_REGEX)) {
+				bpmnIOParameters.addHardcodedInputParameterBoolean(flowElementId, inputParameter, Boolean.valueOf(extractedValue));
+			}
+		} else {
+			bpmnIOParameters.addHardcodedInputParameterString(flowElementId, inputParameter, textContent);		
+		}
+	}
+
+	private void scanOutputs(FlowElement baseElement) {
+		baseElement.getExtensionElements().getElements().stream() //
+			.filter(extensionElement -> extensionElement.getElementType().getTypeName().equals(INPUT_OUTPUT_NAME)) //
+			.flatMap(formData -> formData.getChildElementsByType(CamundaOutputParameter.class).stream()) //
+			.map(outputParameter -> ((CamundaOutputParameter) outputParameter)) //
+			.forEach(outputParameter -> insertOutputParameter(baseElement, outputParameter)); //
+	}
+
+	private void insertOutputParameter(FlowElement baseElement, CamundaOutputParameter outputParameter) {
+		//Output-Format --> Name muss verwendet werden
+		//<camunda:outputParameter name="ProcessVariable">${ExternalServiceVariable}</camunda:outputParameter>
+		String textContent = outputParameter.getCamundaName();
+		bpmnIOParameters.addOutputVariable(baseElement.getId(), textContent);
+		
+		//Auf API-Seite wird der TextContent genutzt - für die Mocks relevant
+		String innerAPIParameter = outputParameter.getTextContent();
+		List<String> innerAPIVariables = extractVariables(innerAPIParameter);
+		innerAPIVariables.forEach(innerAPIVariable -> bpmnIOParameters.addInnerOutputVariable(baseElement.getId(), innerAPIVariable));
+	}
+	
+	public BPMNIOParameters getBpmnIOParameters() {
+		return bpmnIOParameters;
+	}
+	
+	private List<String> extractVariables(String ioParameter) {
+		List<String> variableMatches = new ArrayList<>();
+		
+		Pattern patternVariableMatch = Pattern.compile(VARIABLE_MATCH_REGEX);
+		Matcher matcherVariable = patternVariableMatch.matcher(ioParameter);
+		
+		while (matcherVariable.find()) {
+			String extractedVariable = matcherVariable.group(1);
+			if(!extractedVariable.matches(INT_MATCH_REGEX) && !extractedVariable.matches(BOOLEAN_MATCH_REGEX)) {
+				variableMatches.add(extractedVariable);
+			}
+		}
+		
+		return variableMatches;
+	}
+	
+	
+	/**
+	 * 15.12.2021
+	 * insert removeVariables to BPMNIOParameters
+	 * @param baseElement
+	 */
+	private void insertRemoveVariable(FlowElement baseElement, String removeVar)
+	{
+		bpmnIOParameters.addRemoveVariable(baseElement.getId(), removeVar);
+	}
+	
+	/**
+	 * 15.12.2021
+	 * Scan for removeExpressions
+	 * @param baseElement
+	 */
+	private void scanRemoveExpressions(FlowElement baseElement) {	
+		
+		Collection<ModelElementInstance> elements = baseElement.getExtensionElements().getElements();
+		
+		for(ModelElementInstance currentElement : elements)
+		{
+			if(currentElement.getElementType().getTypeName().equals(EXECUTION_LISTENER))
+			{
+				List<org.camunda.bpm.model.xml.type.attribute.Attribute<?>> expressionList = currentElement.getElementType().getAttributes();
+							
+				for(org.camunda.bpm.model.xml.type.attribute.Attribute expression : expressionList)
+				{
+					try
+					{
+						List<String> removeVars = new ArrayList<String>();
+						
+						switch(expression.getAttributeName())
+						{						
+							case "delegateExpression":
+								String strExpression = expression.getValue(currentElement).toString();
+								Pattern pattern = Pattern.compile("\"(.*?)\"", Pattern.DOTALL);
+								Matcher matcher = pattern.matcher(strExpression);
+								while (matcher.find()) {
+									removeVars.add(matcher.group(1));	// Contains String with all variables from removeVar Expression
+								}
+								break;
+							default:
+								break;
+						}
+						
+						if(!removeVars.isEmpty() && removeVars!=null)
+						{					
+							// add the removeVariables to BPMNIOParameters via. insertRemoveVariables
+							removeVars.forEach(var -> this.insertRemoveVariable(baseElement, var));
+						}
+					}
+					catch(Exception e)
+					{
+						System.out.println("[ERROR] " +  e.getMessage());
+					}
+				}
+				
+				
+			}
+		}
+
+		
+	}
+}
diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationService.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationService.java
index c4594bf965443350c0fc82f51182ea7de22603a3..bc972b1d98978905f23e0eebceabae364f558dde 100644
--- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationService.java
+++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationService.java
@@ -1,412 +1,413 @@
-package de.fhmuenster.masterthesis.Testgenerator.prioritization;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
-import de.fhmuenster.masterthesis.testgeneratorDSL.BusinessRuleTaskFlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.DelegateServiceTaskFlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.ExternalServiceTaskFlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.Flow;
-import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference;
-import de.fhmuenster.masterthesis.testgeneratorDSL.ManualTaskFlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.ScriptTaskFlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.VariableReference;
-
-public class PrioritizationService {
-
-	private TestgeneratorDSLSerializer oldDSL;
-	private TestgeneratorDSLSerializer newDSL;
-	
-	private Map<String, List<VariableReference>> readVariables;
-	private Map<String, List<VariableReference>> writeVariables;
-	
-	public HashMap<String, Integer> dependencyList = new HashMap<>();
-	
-	public PrioritizationService(TestgeneratorDSLSerializer oldDSL, TestgeneratorDSLSerializer newDSL) {
-		this.oldDSL = oldDSL;
-		this.newDSL = newDSL;
-	}
-
-	public void prioritize() {
-		Map<String, List<VariableReference>> readVariablesOldDSL, writeVariablesOldDSL, readVariablesNewDSL, writeVariablesNewDSL;
-		HashMap<String, Integer> dependenciesNew = new HashMap<>();
-		HashMap<String, Integer> dependenciesOld = new HashMap<>();
-		
-		readVariablesOldDSL = this.getReadVariables(this.oldDSL);
-		writeVariablesOldDSL = this.getWriteVariables(this.oldDSL);
-				
-		readVariablesNewDSL = this.getReadVariables(this.newDSL);
-		writeVariablesNewDSL = this.getWriteVariables(this.newDSL);
-		
-		this.readVariables = readVariablesNewDSL;
-		this.writeVariables = writeVariablesNewDSL;		
-				
-		HashMap<String, List<String>> changesReadVariables	= this.checkVariables(readVariablesOldDSL, readVariablesNewDSL);
-		HashMap<String, List<String>> changesWriteVariables	= this.checkVariables(writeVariablesOldDSL, writeVariablesNewDSL);
-		System.out.println("================================================");
-
-		System.out.println("PRIORIZTION => OLD TO NEW");
-		System.out.println("Changes ReadVariables");
-		System.out.println(changesReadVariables);
-		System.out.println("Changes WriteVariables");
-		System.out.println(changesWriteVariables);
-		
-		System.out.println("================================================");
-		
-		System.out.println("PRIORIZTION => NEW TO OLD");
-		HashMap<String, List<String>> changesReadVariablesOLD	= this.checkVariables(readVariablesNewDSL, readVariablesOldDSL);
-		HashMap<String, List<String>> changesWriteVariablesOLD	= this.checkVariables(writeVariablesNewDSL, writeVariablesOldDSL);
-		
-		System.out.println("Changes ReadVariables");
-		System.out.println(changesReadVariablesOLD);
-		System.out.println("Changes WriteVariables");
-		System.out.println(changesWriteVariablesOLD);
-		
-		System.out.println("================================================");
-		HashMap<String, List<String>> differentReadVariables = this.checkDifferences(changesReadVariablesOLD, changesReadVariables);
-		HashMap<String, List<String>> differentWriteVariables = this.checkDifferences(changesWriteVariablesOLD, changesWriteVariables);
-
-		HashMap<String, Integer> dependenciesRead = this.checkFlowsWhereVariableExists(differentReadVariables);
-		HashMap<String, Integer> dependenciesWrite = this.checkFlowsWhereVariableExists(differentWriteVariables);
-		
-		this.sumDependencies(dependenciesRead, dependenciesWrite);
-		
-		this.dumpDependencyList(this.newDSL.getFlows());		
-		try {
-			this.newDSL.serialize();
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-	
-	// Here, the changes of the variables are compared to the flowelements
-	
-	private HashMap<String, Integer> checkFlowsWhereVariableExists(HashMap<String, List<String>> differentVariables) {
-		HashMap<String, Integer> dependencyList = new HashMap<>();
-		if(differentVariables != null) {
-			List<Flow> flows = this.newDSL.getFlows();
-			for(Flow f: flows)
-			{
-				int countDependency = 0;
-				List<FlowElementReference> fer = f.getInclElements();
-				for(int i = 0; i < fer.size(); i++)
-				{
-					String currentFlowElement = fer.get(i).getRef().getName(); 
-					for (Entry<String, List<String>> differentVariableMap : differentVariables.entrySet()) {
-						String variableEntry = differentVariableMap.getKey(); // Since the variableentrys are called the same as the flowelements, you can compare those
-						if(variableEntry.equals(currentFlowElement)) { 
-							countDependency++;
-						}
-					}
-				}
-				dependencyList.put(f.getName(), countDependency); // Put the flowname and the dependency into the returned map
-			}
-		}
-		return dependencyList;
-	}
-
-	private HashMap<String, List<String>> checkDifferences(HashMap<String, List<String>> changeVariablesOLD,
-			HashMap<String, List<String>> changesVariablesNEW) {
-		HashMap<String, List<String>> differentVariables = new HashMap<>();
-		if(changeVariablesOLD != null && changesVariablesNEW != null) {
-			for (Entry<String, List<String>> oldVariableMap : changeVariablesOLD.entrySet()) {
-			    String oldVariablesKey = oldVariableMap.getKey();
-			    List<String> oldVariablesValue = oldVariableMap.getValue();
-			    for (Entry<String, List<String>> newVariableMap : changesVariablesNEW.entrySet()) {
-				    String newVariablesKey = newVariableMap.getKey();
-				    List<String> newVariablesValue = newVariableMap.getValue();
-				    if(oldVariablesKey.equals(newVariablesKey)) {
-				    	if(oldVariablesValue.equals(newVariablesValue) == false) {
-				    		differentVariables.put(oldVariablesKey, oldVariablesValue);
-				    	}
-				    }
-				}
-			}
-		}
-		return differentVariables;
-	}
-
-	
-
-	private void dumpDependencyList(List<Flow> flows)
-	{
-		for(Flow f: flows) {
-			for (Entry<String, Integer> entry : this.dependencyList.entrySet()) {
-				
-			    String 	flowName 	= entry.getKey();
-			    Integer weight 		= entry.getValue();
-
-				if(f.getName().equals(flowName)) {
-					f.setDependency(weight);
-				    System.out.println("Flow " + flowName + " with Dependency " + f.getDependency());
-				} 
-			}
-			if(this.dependencyList.entrySet().isEmpty()) {
-				f.setDependency(0);
-			}
-		}
-		
-	}
-	
-	private void sumDependencies(HashMap<String, Integer> firstList, HashMap<String, Integer> secondList)
-	{
-		for(Map.Entry<String, Integer> elem1 : firstList.entrySet())
-		{
-			String currentFlowElement 	= elem1.getKey();
-			Integer dependencyFlow		= elem1.getValue();
-			
-			for(Map.Entry<String, Integer> elem2 : secondList.entrySet())
-			{
-				String flowElement		= elem2.getKey();
-				Integer flowDependency	= elem2.getValue();
-				
-				if(currentFlowElement.equals(flowElement))
-				{
-					// Sum the dependencies
-					int sum = dependencyFlow + flowDependency;
-					this.dependencyList.put(currentFlowElement, sum);
-				}
-			}
-		}
-	}
-	
-	/**
-	 * Function to check VariableChanges in DSL
-	 * @param oldDSL
-	 * @param newDSL
-	 * @return HashMap<String, String> contains all FlowElementNames with the Variables
-	 */
-	private HashMap<String, List<String>> checkVariables(Map<String, List<VariableReference>> oldDSL, Map<String, List<VariableReference>> newDSL) {
-		
-		HashMap<String, List<String>> mapOLD = new HashMap<>();
-		HashMap<String, List<String>> mapNEW = new HashMap<>();		
-		for(Map.Entry<String, List<VariableReference>> entry : newDSL.entrySet())
-		{
-			String key = entry.getKey();
-			List<VariableReference> vars = entry.getValue();	
-			List<String> list = new ArrayList<String>();
-			
-		    for(VariableReference var : vars) 
-		    {
-		    	if(var != null)
-		    		list.add(var.getRef().getName());
-		    }		    
-		    mapNEW.put(key, list);
-		}
-		
-		for(Map.Entry<String, List<VariableReference>> entry : oldDSL.entrySet())
-		{
-			String key = entry.getKey();
-			List<VariableReference> vars = entry.getValue();	
-			List<String> list = new ArrayList<>();
-			
-		    for(VariableReference var : vars) 
-		    {
-		    	if(var != null) {
-		    		list.add(var.getRef().getName());
-
-		    	}
-
-		    }		
-	    	mapOLD.put(key, list);
-		}
-		
-				
-		HashMap<String, List<String>> returnMap = new HashMap<>();
-		List<String> listOldVars = new ArrayList<String>();
-		for(Map.Entry<String, List<String>> entry : mapNEW.entrySet())
-		{	
-			listOldVars.addAll(entry.getValue());
-		}
-		
-		List<String> listNewVars = new ArrayList<String>();
-		for(Map.Entry<String, List<String>> entry : mapOLD.entrySet())
-		{	
-			listNewVars.addAll(entry.getValue());
-		}
-		
-		if(mapNEW.equals(mapOLD) == false)
-		{		
-			for(Map.Entry<String, List<String>> entry : mapNEW.entrySet())
-			{							
-				String flowElementNew		= entry.getKey();
-				if(mapOLD.containsKey(flowElementNew))
-				{
-					for(int i = 0; i < listOldVars.size(); i++)
-					{
-						String varNEW = listOldVars.get(i);
-
-						for(Map.Entry<String, List<String>> entryOld : mapOLD.entrySet())
-						{
-							if(entryOld.getKey().equals(flowElementNew))
-							{								
-								for(int j = 0; j < listNewVars.size(); j++)
-									
-								{
-
-									String varOLD = listNewVars.get(j);
-
-									if(varOLD.equals(varNEW))
-									{
-										listOldVars.remove(varOLD);
-										listNewVars.remove(varNEW);
-									}
-								}
-							}
-						}
-					}
-				}	
-			}
-			returnMap.putAll(mapOLD);
-			returnMap.putAll(mapNEW);
-		}
-		else
-		{
-			return null;
-		}
-		return returnMap;
-	}
-	
-	/**	
-	 * Function to get the WriteVariables from the DSL
-	 * @param dsl
-	 * @return Map<String, List<VariableReference>>
-	 */
-	private Map<String, List<VariableReference>> getWriteVariables(TestgeneratorDSLSerializer dsl) {
-		
-		Map<String, List<VariableReference>> mapFlowToWriteVariables = new HashMap<String, List<VariableReference>>();
-		
-		try {
-			List<Flow> flows 		= dsl.getFlows();
-			for(Flow f: flows) 
-			{
-				List<FlowElementReference> fer = f.getInclElements();
-				
-				for(FlowElementReference flowElementReference: fer)
-				{
-					FlowElement flowElement = flowElementReference.getRef();
-	
-					if(flowElementReference.getRef() instanceof ManualTaskFlowElement) 
-					{
-						ManualTaskFlowElement manualTask = (ManualTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> writeVariables = manualTask.getOutputVariables();
-						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
-					}
-					else if(flowElementReference.getRef() instanceof UserTaskFlowElement) 
-					{
-						UserTaskFlowElement userTask = (UserTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> writeVariables = userTask.getOutputVariables();
-						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
-					}
-					else if(flowElementReference.getRef() instanceof ScriptTaskFlowElement) 
-					{
-						ScriptTaskFlowElement scriptTask = (ScriptTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> writeVariables = scriptTask.getOutputVariables();
-						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
-					}
-					else if(flowElementReference.getRef() instanceof DelegateServiceTaskFlowElement) 
-					{
-						DelegateServiceTaskFlowElement delegateTask = (DelegateServiceTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> writeVariables = delegateTask.getOutputVariables();
-						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
-					}
-					else if(flowElementReference.getRef() instanceof ExternalServiceTaskFlowElement) 
-					{
-						ExternalServiceTaskFlowElement externalTask = (ExternalServiceTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> writeVariables = externalTask.getOutputVariables();
-						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
-					}
-					else if(flowElementReference.getRef() instanceof BusinessRuleTaskFlowElement) 
-					{
-						BusinessRuleTaskFlowElement  businessTask = (BusinessRuleTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> writeVariables = businessTask.getOutputVariables();
-						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
-					}
-				}
-			}
-		}
-		catch(Exception e) {
-			
-		}
-		
-		return mapFlowToWriteVariables;
-	}
-	
-	/**	
-	 * Function to get the readVariables from the DSL
-	 * @param dsl
-	 * @return Map<String, List<VariableReference>>
-	 */
-	private Map<String, List<VariableReference>> getReadVariables(TestgeneratorDSLSerializer dsl) {
-		
-		Map<String, List<VariableReference>> mapFlowToReadVariables = new HashMap<String, List<VariableReference>>();		
-		
-		try {
-			List<Flow> flows 		= dsl.getFlows();
-			for(Flow f: flows) 
-			{
-				List<FlowElementReference> fer = f.getInclElements();
-	
-				for(FlowElementReference flowElementReference: fer)
-				{
-					FlowElement flowElement = flowElementReference.getRef();
-	
-					if(flowElementReference.getRef() instanceof ManualTaskFlowElement) 
-					{
-						ManualTaskFlowElement manualTask = (ManualTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> readVariables = manualTask.getInputVariables();
-						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
-					}
-					else if(flowElementReference.getRef() instanceof UserTaskFlowElement) 
-					{
-						UserTaskFlowElement userTask = (UserTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> readVariables = userTask.getInputVariables();
-						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
-					}
-					else if(flowElementReference.getRef() instanceof ScriptTaskFlowElement) 
-					{
-						ScriptTaskFlowElement scriptTask = (ScriptTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> readVariables = scriptTask.getInputVariables();
-						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
-					}
-					else if(flowElementReference.getRef() instanceof DelegateServiceTaskFlowElement) 
-					{
-						DelegateServiceTaskFlowElement delegateTask = (DelegateServiceTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> readVariables = delegateTask.getInputVariables();
-						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
-					}
-					else if(flowElementReference.getRef() instanceof ExternalServiceTaskFlowElement) 
-					{
-						ExternalServiceTaskFlowElement externalTask = (ExternalServiceTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> readVariables = externalTask.getInputVariables();
-						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
-					}
-					else if(flowElementReference.getRef() instanceof BusinessRuleTaskFlowElement) 
-					{
-						BusinessRuleTaskFlowElement  businessTask = (BusinessRuleTaskFlowElement) flowElementReference.getRef();
-						List<VariableReference> readVariables = businessTask.getInputVariables();	
-						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
-					}
-				}
-			}
-		}
-		catch(Exception e) {
-			
-		}
-		
-		return mapFlowToReadVariables;
-	}
-		
-}
+package de.fhmuenster.masterthesis.Testgenerator.prioritization;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
+import de.fhmuenster.masterthesis.testgeneratorDSL.BusinessRuleTaskFlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.DelegateServiceTaskFlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.ExternalServiceTaskFlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.Flow;
+import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference;
+import de.fhmuenster.masterthesis.testgeneratorDSL.ManualTaskFlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.ScriptTaskFlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.VariableReference;
+
+public class PrioritizationService {
+
+	private TestgeneratorDSLSerializer oldDSL;
+	private TestgeneratorDSLSerializer newDSL;
+	
+	private Map<String, List<VariableReference>> readVariables;
+	private Map<String, List<VariableReference>> writeVariables;
+	
+	public HashMap<String, Integer> dependencyList = new HashMap<>();
+	
+	public PrioritizationService(TestgeneratorDSLSerializer oldDSL, TestgeneratorDSLSerializer newDSL) {
+		this.oldDSL = oldDSL;
+		this.newDSL = newDSL;
+	}
+
+	public void prioritize() {
+		Map<String, List<VariableReference>> readVariablesOldDSL, writeVariablesOldDSL, readVariablesNewDSL, writeVariablesNewDSL;
+		
+		readVariablesOldDSL = this.getReadVariables(this.oldDSL);
+		writeVariablesOldDSL = this.getWriteVariables(this.oldDSL);
+				
+		readVariablesNewDSL = this.getReadVariables(this.newDSL);
+		writeVariablesNewDSL = this.getWriteVariables(this.newDSL);
+		
+		this.readVariables = readVariablesNewDSL;
+		this.writeVariables = writeVariablesNewDSL;		
+				
+		HashMap<String, List<String>> changesReadVariables	= this.checkVariables(readVariablesOldDSL, readVariablesNewDSL);
+		HashMap<String, List<String>> changesWriteVariables	= this.checkVariables(writeVariablesOldDSL, writeVariablesNewDSL);
+		
+		HashMap<String, List<String>> changesReadVariablesOLD	= this.checkVariables(readVariablesNewDSL, readVariablesOldDSL);
+		HashMap<String, List<String>> changesWriteVariablesOLD	= this.checkVariables(writeVariablesNewDSL, writeVariablesOldDSL);
+		
+		HashMap<String, List<String>> differentReadVariables = this.checkDifferences(changesReadVariablesOLD, changesReadVariables);
+		HashMap<String, List<String>> differentWriteVariables = this.checkDifferences(changesWriteVariablesOLD, changesWriteVariables);
+
+		HashMap<String, Integer> dependenciesRead = this.checkFlowsWhereVariableExists(differentReadVariables);
+		HashMap<String, Integer> dependenciesWrite = this.checkFlowsWhereVariableExists(differentWriteVariables);
+		
+		this.sumDependencies(dependenciesRead, dependenciesWrite);
+		
+		this.dumpDependencyList(this.newDSL.getFlows());		
+		try {
+			this.newDSL.serialize();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	
+	/**
+	 * Here, the changes of the variables are compared to the flowelements
+	 * @param differentVariables
+	 * @return
+	 */
+	private HashMap<String, Integer> checkFlowsWhereVariableExists(HashMap<String, List<String>> differentVariables) {
+		HashMap<String, Integer> dependencyList = new HashMap<>();
+		if(differentVariables != null) {
+			List<Flow> flows = this.newDSL.getFlows();
+			for(Flow f: flows)
+			{
+				int countDependency = 0;
+				List<FlowElementReference> fer = f.getInclElements();
+				for(int i = 0; i < fer.size(); i++)
+				{
+					String currentFlowElement = fer.get(i).getRef().getName(); 
+					for (Entry<String, List<String>> differentVariableMap : differentVariables.entrySet()) {
+						String variableEntry = differentVariableMap.getKey(); // Since the variableentrys are called the same as the flowelements, you can compare those
+						if(variableEntry.equals(currentFlowElement)) { 
+							countDependency++;
+						}
+					}
+				}
+				dependencyList.put(f.getName(), countDependency); // Put the flowname and the dependency into the returned map
+			}
+		}
+		return dependencyList;
+	}
+
+	/**
+	 * Function to analayse the differneces between the old & new DSL-File
+	 * @param changeVariablesOLD
+	 * @param changesVariablesNEW
+	 * @return
+	 */
+	private HashMap<String, List<String>> checkDifferences(HashMap<String, List<String>> changeVariablesOLD, HashMap<String, List<String>> changesVariablesNEW) 
+	{
+		HashMap<String, List<String>> differentVariables = new HashMap<>();	
+		if(changeVariablesOLD != null && changesVariablesNEW != null) 
+		{
+			for (Entry<String, List<String>> oldVariableMap : changeVariablesOLD.entrySet()) 
+			{
+			    String oldVariablesKey = oldVariableMap.getKey();
+			    List<String> oldVariablesValue = oldVariableMap.getValue();
+			    for (Entry<String, List<String>> newVariableMap : changesVariablesNEW.entrySet()) 
+			    {
+				    String newVariablesKey = newVariableMap.getKey();
+				    List<String> newVariablesValue = newVariableMap.getValue();
+				    
+				    if(oldVariablesKey.equals(newVariablesKey)) {
+				    	if(oldVariablesValue.equals(newVariablesValue) == false) 
+				    	{
+				    		differentVariables.put(oldVariablesKey, oldVariablesValue);
+				    	}
+				    }
+				}
+			}
+		}
+		
+		return differentVariables;
+	}
+
+	/**
+	 * dump functions 
+	 * @param flows
+	 */
+	private void dumpDependencyList(List<Flow> flows)
+	{
+		for(Flow f: flows) {
+			for (Entry<String, Integer> entry : this.dependencyList.entrySet())
+			{
+			    String 	flowName 	= entry.getKey();
+			    Integer weight 		= entry.getValue();
+
+				if(f.getName().equals(flowName)) 
+				{
+					f.setDependency(weight);
+				    System.out.println("Flow " + flowName + " with Dependency " + f.getDependency());
+				} 
+			}
+			if(this.dependencyList.entrySet().isEmpty()) 
+			{
+				f.setDependency(0);
+			}
+		}
+		
+	}
+	
+	private void sumDependencies(HashMap<String, Integer> firstList, HashMap<String, Integer> secondList)
+	{
+		for(Map.Entry<String, Integer> elem1 : firstList.entrySet())
+		{
+			String currentFlowElement 	= elem1.getKey();
+			Integer dependencyFlow		= elem1.getValue();
+			
+			for(Map.Entry<String, Integer> elem2 : secondList.entrySet())
+			{
+				String flowElement		= elem2.getKey();
+				Integer flowDependency	= elem2.getValue();
+				
+				if(currentFlowElement.equals(flowElement)) {
+					// Sum the dependencies
+					int sum = dependencyFlow + flowDependency;
+					this.dependencyList.put(currentFlowElement, sum);
+				}
+			}
+		}
+	}
+	
+	/**
+	 * Function to check VariableChanges in DSL
+	 * @param oldDSL
+	 * @param newDSL
+	 * @return HashMap<String, String> contains all FlowElementNames with the Variables
+	 */
+	private HashMap<String, List<String>> checkVariables(Map<String, List<VariableReference>> oldDSL, Map<String, List<VariableReference>> newDSL) {
+		
+		HashMap<String, List<String>> mapOLD = new HashMap<>();
+		HashMap<String, List<String>> mapNEW = new HashMap<>();		
+		for(Map.Entry<String, List<VariableReference>> entry : newDSL.entrySet())
+		{
+			String key = entry.getKey();
+			List<VariableReference> vars = entry.getValue();	
+			List<String> list = new ArrayList<String>();
+			
+		    for(VariableReference var : vars) 
+		    {
+		    	if(var != null)
+		    		list.add(var.getRef().getName());
+		    }		    
+		    mapNEW.put(key, list);
+		}
+		
+		for(Map.Entry<String, List<VariableReference>> entry : oldDSL.entrySet())
+		{
+			String key = entry.getKey();
+			List<VariableReference> vars = entry.getValue();	
+			List<String> list = new ArrayList<>();
+			
+		    for(VariableReference var : vars) 
+		    {
+		    	if(var != null) {
+		    		list.add(var.getRef().getName());
+
+		    	}
+
+		    }		
+	    	mapOLD.put(key, list);
+		}
+		
+				
+		HashMap<String, List<String>> returnMap = new HashMap<>();
+		List<String> listOldVars = new ArrayList<String>();
+		for(Map.Entry<String, List<String>> entry : mapNEW.entrySet())
+		{	
+			listOldVars.addAll(entry.getValue());
+		}
+		
+		List<String> listNewVars = new ArrayList<String>();
+		for(Map.Entry<String, List<String>> entry : mapOLD.entrySet())
+		{	
+			listNewVars.addAll(entry.getValue());
+		}
+		
+		if(mapNEW.equals(mapOLD) == false)
+		{		
+			for(Map.Entry<String, List<String>> entry : mapNEW.entrySet())
+			{							
+				String flowElementNew		= entry.getKey();
+				if(mapOLD.containsKey(flowElementNew))
+				{
+					for(int i = 0; i < listOldVars.size(); i++)
+					{
+						String varNEW = listOldVars.get(i);
+
+						for(Map.Entry<String, List<String>> entryOld : mapOLD.entrySet())
+						{
+							if(entryOld.getKey().equals(flowElementNew))
+							{								
+								for(int j = 0; j < listNewVars.size(); j++)
+									
+								{
+
+									String varOLD = listNewVars.get(j);
+
+									if(varOLD.equals(varNEW))
+									{
+										listOldVars.remove(varOLD);
+										listNewVars.remove(varNEW);
+									}
+								}
+							}
+						}
+					}
+				}	
+			}
+			returnMap.putAll(mapOLD);
+			returnMap.putAll(mapNEW);
+		}
+		else
+		{
+			return null;
+		}
+		return returnMap;
+	}
+	
+	/**	
+	 * Function to get the WriteVariables from the DSL
+	 * @param dsl
+	 * @return Map<String, List<VariableReference>>
+	 */
+	private Map<String, List<VariableReference>> getWriteVariables(TestgeneratorDSLSerializer dsl) {
+		
+		Map<String, List<VariableReference>> mapFlowToWriteVariables = new HashMap<String, List<VariableReference>>();
+		
+		try {
+			List<Flow> flows 		= dsl.getFlows();
+			for(Flow f: flows) 
+			{
+				List<FlowElementReference> fer = f.getInclElements();
+				
+				for(FlowElementReference flowElementReference: fer)
+				{
+					FlowElement flowElement = flowElementReference.getRef();
+	
+					if(flowElementReference.getRef() instanceof ManualTaskFlowElement) 
+					{
+						ManualTaskFlowElement manualTask = (ManualTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> writeVariables = manualTask.getOutputVariables();
+						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
+					}
+					else if(flowElementReference.getRef() instanceof UserTaskFlowElement) 
+					{
+						UserTaskFlowElement userTask = (UserTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> writeVariables = userTask.getOutputVariables();
+						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
+					}
+					else if(flowElementReference.getRef() instanceof ScriptTaskFlowElement) 
+					{
+						ScriptTaskFlowElement scriptTask = (ScriptTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> writeVariables = scriptTask.getOutputVariables();
+						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
+					}
+					else if(flowElementReference.getRef() instanceof DelegateServiceTaskFlowElement) 
+					{
+						DelegateServiceTaskFlowElement delegateTask = (DelegateServiceTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> writeVariables = delegateTask.getOutputVariables();
+						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
+					}
+					else if(flowElementReference.getRef() instanceof ExternalServiceTaskFlowElement) 
+					{
+						ExternalServiceTaskFlowElement externalTask = (ExternalServiceTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> writeVariables = externalTask.getOutputVariables();
+						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
+					}
+					else if(flowElementReference.getRef() instanceof BusinessRuleTaskFlowElement) 
+					{
+						BusinessRuleTaskFlowElement  businessTask = (BusinessRuleTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> writeVariables = businessTask.getOutputVariables();
+						mapFlowToWriteVariables.put(flowElement.getName(), writeVariables);
+					}
+				}
+			}
+		}
+		catch(Exception e) {
+			
+		}
+		
+		return mapFlowToWriteVariables;
+	}
+	
+	/**	
+	 * Function to get the readVariables from the DSL
+	 * @param dsl
+	 * @return Map<String, List<VariableReference>>
+	 */
+	private Map<String, List<VariableReference>> getReadVariables(TestgeneratorDSLSerializer dsl) {
+		
+		Map<String, List<VariableReference>> mapFlowToReadVariables = new HashMap<String, List<VariableReference>>();		
+		
+		try {
+			List<Flow> flows 		= dsl.getFlows();
+			for(Flow f: flows) 
+			{
+				List<FlowElementReference> fer = f.getInclElements();
+	
+				for(FlowElementReference flowElementReference: fer)
+				{
+					FlowElement flowElement = flowElementReference.getRef();
+	
+					if(flowElementReference.getRef() instanceof ManualTaskFlowElement) 
+					{
+						ManualTaskFlowElement manualTask = (ManualTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> readVariables = manualTask.getInputVariables();
+						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
+					}
+					else if(flowElementReference.getRef() instanceof UserTaskFlowElement) 
+					{
+						UserTaskFlowElement userTask = (UserTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> readVariables = userTask.getInputVariables();
+						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
+					}
+					else if(flowElementReference.getRef() instanceof ScriptTaskFlowElement) 
+					{
+						ScriptTaskFlowElement scriptTask = (ScriptTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> readVariables = scriptTask.getInputVariables();
+						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
+					}
+					else if(flowElementReference.getRef() instanceof DelegateServiceTaskFlowElement) 
+					{
+						DelegateServiceTaskFlowElement delegateTask = (DelegateServiceTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> readVariables = delegateTask.getInputVariables();
+						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
+					}
+					else if(flowElementReference.getRef() instanceof ExternalServiceTaskFlowElement) 
+					{
+						ExternalServiceTaskFlowElement externalTask = (ExternalServiceTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> readVariables = externalTask.getInputVariables();
+						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
+					}
+					else if(flowElementReference.getRef() instanceof BusinessRuleTaskFlowElement) 
+					{
+						BusinessRuleTaskFlowElement  businessTask = (BusinessRuleTaskFlowElement) flowElementReference.getRef();
+						List<VariableReference> readVariables = businessTask.getInputVariables();	
+						mapFlowToReadVariables.put(flowElement.getName(), readVariables);
+					}
+				}
+			}
+		}
+		catch(Exception e) {
+			
+		}
+		
+		return mapFlowToReadVariables;
+	}
+		
+}
diff --git a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/test/TestService.java b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/test/TestService.java
index 1e1e418bb8b483983748113d2ba0efb1dd58332c..1b7d236fcdd41ce54e11c222f58f0daa63a57e74 100644
--- a/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/test/TestService.java
+++ b/Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/test/TestService.java
@@ -1,873 +1,911 @@
-package de.fhmuenster.masterthesis.Testgenerator.rest.service.test;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import org.camunda.bpm.model.bpmn.instance.BusinessRuleTask;
-import org.camunda.bpm.model.bpmn.instance.EndEvent;
-import org.camunda.bpm.model.bpmn.instance.Gateway;
-import org.camunda.bpm.model.bpmn.instance.ManualTask;
-import org.camunda.bpm.model.bpmn.instance.ScriptTask;
-import org.camunda.bpm.model.bpmn.instance.SequenceFlow;
-import org.camunda.bpm.model.bpmn.instance.ServiceTask;
-import org.camunda.bpm.model.bpmn.instance.StartEvent;
-import org.camunda.bpm.model.bpmn.instance.UserTask;
-import org.eclipse.emf.common.util.BasicEList;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNBooleanConstraint;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNBundle;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNExpressions;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFieldConstraint;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlow;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlowSet;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFormFields;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNIOParameters;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNNumericConstraint;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNTestcase;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNTestdata;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.TaskVariables;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.VariableValue;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNExpressionScanner;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNFlowScanner;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNVariableBoundaryScanner;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNVariableFormFieldScanner;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNVariableIOScanner;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.loop.Loop;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.loop.LoopFrequencyAssigner;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.loop.LoopScanner;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.sese.IsElement;
-import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.sese.SESEBuilder;
-import de.fhmuenster.masterthesis.Testgenerator.dmn.data.DMNBundle;
-import de.fhmuenster.masterthesis.Testgenerator.dmn.data.DMNDecisionModel;
-import de.fhmuenster.masterthesis.Testgenerator.dmn.data.DMNVariables;
-import de.fhmuenster.masterthesis.Testgenerator.embeddedform.data.EmbeddedFormDocument;
-import de.fhmuenster.masterthesis.Testgenerator.logging.LoggerProvider;
-import de.fhmuenster.masterthesis.Testgenerator.logging.TestgeneratorLogger;
-import de.fhmuenster.masterthesis.Testgenerator.migration.MigrationService;
-import de.fhmuenster.masterthesis.Testgenerator.rest.service.converters.TestConverter;
-import de.fhmuenster.masterthesis.Testgenerator.rest.service.flow.FlowService;
-import de.fhmuenster.masterthesis.Testgenerator.rest.service.mock.MockService;
-import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.Project;
-import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.ProjectDirectories;
-import de.fhmuenster.masterthesis.Testgenerator.utils.BPMNParseUtils;
-import de.fhmuenster.masterthesis.Testgenerator.utils.ProjectDirectoryUtils;
-import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLObjectCreator;
-import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
-import de.fhmuenster.masterthesis.serialization.VariableProposal;
-import de.fhmuenster.masterthesis.testgeneratorDSL.BPMNDiagram;
-import de.fhmuenster.masterthesis.testgeneratorDSL.Constraint;
-import de.fhmuenster.masterthesis.testgeneratorDSL.ExternalTopic;
-import de.fhmuenster.masterthesis.testgeneratorDSL.Flag;
-import de.fhmuenster.masterthesis.testgeneratorDSL.Flow;
-import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference;
-import de.fhmuenster.masterthesis.testgeneratorDSL.Mock;
-import de.fhmuenster.masterthesis.testgeneratorDSL.StartFlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.Test;
-import de.fhmuenster.masterthesis.testgeneratorDSL.TestgeneratorDSLFactory;
-import de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement;
-import de.fhmuenster.masterthesis.testgeneratorDSL.ValidationState;
-import de.fhmuenster.masterthesis.testgeneratorDSL.Variable;
-import de.fhmuenster.masterthesis.testgeneratorDSL.VariableDeclaration;
-import de.fhmuenster.masterthesis.testgeneratorDSL.VariableDeclarations;
-import de.fhmuenster.masterthesis.testgeneratorDSL.VariableReference;
-import de.fhmuenster.masterthesis.utils.TestgeneratorDSLUtils;
-
-@Service
-public class TestService {
-
-	private static final TestgeneratorLogger LOGGER = LoggerProvider.getLogger(TestService.class);
-	private static final String NAMESPACE_URI_BPMN = "http://camunda.org/schema/1.0/bpmn";
-
-	private long millisDataStart;
-	private long millisDataEnd;
-	
-	private List<String> taskIds = new ArrayList<String>();
-	
-	@Autowired
-	private FlowService flowService;
-	@Autowired
-	private MockService mockService;
-	
-	@Autowired
-	private MigrationService migrationService;
-
-	public TestService() {
-	}
-
-	public List<de.fhmuenster.masterthesis.testgeneratorDSL.Loop> initLoops(Project project) {
-		Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
-		String testpackage = project.getProjectDirectories().getTestPackage();
-		List<de.fhmuenster.masterthesis.testgeneratorDSL.Loop> dslLoops = null;
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testFilePath.toString());
-
-			BPMNDiagram bpmnDiagram = serializer.getBPMNDiagram("process");
-			if (bpmnDiagram == null) {
-				BPMNBundle bpmnBundle = BPMNParseUtils.readBPMNBundle(project);
-				List<DMNBundle> dmnBundles = BPMNParseUtils.readDMNBundles(project);
-				List<EmbeddedFormDocument> embeddedFormDocuments = BPMNParseUtils.readEmbeddedFormDocuments(project);
-				List<DMNDecisionModel> decisionModels = BPMNParseUtils.getDecisionModels(dmnBundles);
-				bpmnDiagram = BPMNParseUtils.getBPMNDiagram(bpmnBundle.getProcessModel(), testpackage, decisionModels,
-						embeddedFormDocuments);
-
-				// Build Single-Entry-Single-Exit-Graph
-				SESEBuilder seseBuilder = new SESEBuilder(bpmnBundle.getModelInstance());
-				seseBuilder.buildSingleEntrySingleExit();
-				List<IsElement> seseTransform = seseBuilder.getSeseTransform();
-
-				// Scan for loops
-				LoopScanner loopScanner = new LoopScanner(seseTransform);
-				List<Loop> loops = loopScanner.scanLoops();
-
-				// Set frequency for loops
-				LoopFrequencyAssigner frequencyAssigner = new LoopFrequencyAssigner(loops);
-				frequencyAssigner.assign();
-
-				serializer.addBPMNDiagram(bpmnDiagram);
-				dslLoops = flowService.getDSLLoops(loops);
-				dslLoops.forEach(dslLoop -> serializer.addLoop(dslLoop));
-
-				serializer.serialize();
-			}
-
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-
-		if (dslLoops == null) {
-			return flowService.getLoops(project.getProjectDirectories());
-		}
-
-		return dslLoops;
-	}
-
-	public void initTestcollection(Project project) {
-		Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
-		String testpackage = project.getProjectDirectories().getTestPackage();
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testFilePath.toString());
-
-			BPMNDiagram bpmnDiagram = serializer.getBPMNDiagram("process");
-			List<FlowElement> flowElementsCheck = serializer.getFlowElements();
-			
-			if (bpmnDiagram != null && flowElementsCheck.isEmpty()) {
-				BPMNBundle bpmnBundle = BPMNParseUtils.readBPMNBundle(project);
-				List<DMNBundle> dmnBundles = BPMNParseUtils.readDMNBundles(project);
-				List<EmbeddedFormDocument> embeddedFormDocuments = BPMNParseUtils.readEmbeddedFormDocuments(project);
-				List<DMNDecisionModel> decisionModels = BPMNParseUtils.getDecisionModels(dmnBundles);
-
-				List<de.fhmuenster.masterthesis.testgeneratorDSL.Loop> dslLoops = serializer.getLoops();
-				List<Loop> loops = getLoops(dslLoops);
-
-				// Parse different flows of process model
-				BPMNFlowScanner scanner = new BPMNFlowScanner(bpmnBundle.getModelInstance(), loops);
-				BPMNFlowSet flowSet = scanner.scanFlows();
-
-				if (LOGGER.isInfo()) {
-					millisDataStart = System.currentTimeMillis();
-				}
-
-				// Read FormFields from Events and Tasks
-				BPMNVariableFormFieldScanner variableScanner = new BPMNVariableFormFieldScanner(flowSet);
-				EmbeddedFormDocument[] embeddedArray = new EmbeddedFormDocument[embeddedFormDocuments.size()];
-				variableScanner.setEmbeddedFormDocuments(embeddedFormDocuments.toArray(embeddedArray));
-				variableScanner.doScan();
-				BPMNFormFields formFields = variableScanner.getFormFields();
-
-				// Read Input/Output-Parameters
-				BPMNVariableIOScanner variableIOScanner = new BPMNVariableIOScanner(flowSet);
-				variableIOScanner.doScan();
-				BPMNIOParameters bpmnIOParameters = variableIOScanner.getBpmnIOParameters();
-
-				// Parse conditional expressions
-				BPMNExpressionScanner expressionScanner = new BPMNExpressionScanner(flowSet);
-				expressionScanner.doScan();
-				BPMNExpressions expressions = expressionScanner.getExpressions();
-
-				List<DMNVariables> dmnVariableList = BPMNParseUtils.getDMNVariables(dmnBundles);
-
-				BPMNVariableBoundaryScanner boundaryScanner = new BPMNVariableBoundaryScanner(expressions, formFields,
-						bpmnIOParameters, dmnVariableList);
-				boundaryScanner.doScan();
-				HashMap<String, BPMNTestdata<?>> variableTestdata = boundaryScanner.getVariableTestdata();
-
-				List<Variable> variables = BPMNParseUtils.getVariables(formFields, variableTestdata, bpmnIOParameters);
-
-				if (LOGGER.isInfo()) {
-					millisDataEnd = System.currentTimeMillis();
-					LOGGER.info("Time needed for Data-Scan: " + (millisDataEnd - millisDataStart) + " ms");
-				}
-				
-				List<ExternalTopic> externalTopics = getExternalTopics(flowSet);
-				List<FlowElement> flowElements = getFlowElements(flowSet, variables, formFields, expressions,
-						bpmnIOParameters, externalTopics);
-				List<Flow> flows = getFlows(bpmnDiagram, flowSet, flowElements);
-
-				flowElements.forEach(flowElement -> serializer.addFlowElement(flowElement));
-				variables.forEach(var -> serializer.addVariable(var));
-				externalTopics.forEach(externalTopic -> serializer.addExternalTopic(externalTopic));
-				flows.forEach(flow -> serializer.addFlow(flow));
-				flows.forEach(flow -> this.calculateFlowSize(flow));
-				serializer.serialize();
-			}
-
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	private void calculateFlowSize(Flow flow) {
-		flow.setFlowSize(flow.getInclElements().size());
-	}
-	
-	public void addTest(BPMNTestcase testcase, ProjectDirectories projectDirectories) {
-		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
-
-			checkTestIdAlreadyTaken(testcase.getName(), serializer);
-
-			addTest(testcase, serializer, projectDirectories);
-			serializer.serialize();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-
-	public void updateTest(String testId, BPMNTestcase testcase, ProjectDirectories projectDirectories) {
-		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
-
-			if (!testId.equals(testcase.getName())) {
-				checkTestIdAlreadyTaken(testcase.getName(), serializer);
-			}
-			
-			//Test-Flag aktualisieren
-			testcase.setFlag("GREEN");
-			
-			//Für alle Elemente das Flag zurücksetzen (GREEN oder NONE?)
-			//Aber nur machen, wenn es für ein FlowElement nicht noch ein Testcase existiert
-			Flow flow = serializer.getFlow(testcase.getFlow());
-			List<Test> testsForFlow = serializer.getTestsForFlow(flow);
-			boolean hasTestsWhichAreNotFixed = false;
-			for(FlowElementReference fer : flow.getInclElements()) {
-				checkLoop:
-				for(Test t : testsForFlow) {
-					if(!t.getName().equals(testcase.getName())) {
-						if(t.getFlag().equals(Flag.RED) || t.getFlag().equals(Flag.YELLOW)) {
-							for(VariableDeclarations vds : t.getDeclarations()) {
-								if(vds.getTaskReference().getRef().getName().equals(fer.getRef().getName())) {
-									hasTestsWhichAreNotFixed = true;
-									break checkLoop;
-								}
-							}
-						}
-					}
-					
-				}
-				
-				if(!hasTestsWhichAreNotFixed) {
-					if(!fer.getFlag().equals(Flag.NONE)) {
-						fer.setFlag(Flag.GREEN);
-					}
-					//fer.setFlag(Flag.NONE);
-				}
-			}
-			
-			Test testToDelete = getTest(testId, serializer);
-			serializer.deleteTest(testToDelete.getName());
-			addTest(testcase, serializer, projectDirectories);
-			
-			//Am Ende prüfen, ob der Flow auch ein neues Flag bekommen soll
-			Flag maxFlag = Flag.NONE;
-			for(Test t : serializer.getTestsForFlow(flow)) {
-				maxFlag = migrationService.calcMaxFlag(maxFlag, t.getFlag());
-			}
-			
-			flow.setFlag(maxFlag);
-			
-			//Elemente ggf auch noch updaten, wenn diese noch höher sind als der Flow selbst
-			for(FlowElementReference fer : flow.getInclElements()) {
-				if(flow.getFlag().equals(Flag.GREEN) && !fer.getFlag().equals(Flag.NONE)) {
-					fer.setFlag(Flag.GREEN);
-					continue;
-				}
-				if(!this.migrationService.calcMaxFlag(flow.getFlag(), fer.getFlag()).equals(flow.getFlag())) {
-					fer.setFlag(flow.getFlag());
-				}
-			}
-
-			serializer.serialize();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	public void markTest(String testId, BPMNTestcase testcase, ProjectDirectories projectDirectories) {
-		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
-			
-			Test test = getTest(testId, serializer);
-			test.setFlag(Flag.get(testcase.getFlag()));
-			
-			//Für alle Elemente das Flag zurücksetzen (GREEN oder NONE?)
-			//Aber nur machen, wenn es für ein FlowElement nicht noch ein Testcase existiert
-			Flow flow = serializer.getFlow(testcase.getFlow());
-			List<Test> testsForFlow = serializer.getTestsForFlow(flow);
-			boolean hasTestsWhichAreNotFixed = false;
-			for(FlowElementReference fer : flow.getInclElements()) {
-				checkLoop:
-				for(Test t : testsForFlow) {
-					if(!t.getName().equals(testcase.getName())) {
-						if(t.getFlag().equals(Flag.RED) || t.getFlag().equals(Flag.YELLOW)) {
-							for(VariableDeclarations vds : t.getDeclarations()) {
-								if(vds.getTaskReference().getRef().getName().equals(fer.getRef().getName())) {
-									hasTestsWhichAreNotFixed = true;
-									break checkLoop;
-								}
-							}
-						}
-					}
-					
-				}
-				
-				if(!fer.getFlag().equals(Flag.NONE)) {
-					fer.setFlag(Flag.GREEN);
-				}
-			}
-			
-			//Am Ende prüfen, ob der Flow auch ein neues Flag bekommen soll
-			Flag maxFlag = Flag.NONE;
-			for(Test t : serializer.getTestsForFlow(flow)) {
-				maxFlag = migrationService.calcMaxFlag(maxFlag, t.getFlag());
-			}
-			
-			flow.setFlag(maxFlag);
-			
-			//Elemente ggf auch noch updaten, wenn diese noch höher sind als der Flow selbst
-			for(FlowElementReference fer : flow.getInclElements()) {
-				if(flow.getFlag().equals(Flag.GREEN) && !fer.getFlag().equals(Flag.NONE)) {
-					fer.setFlag(Flag.GREEN);
-					continue;
-				}
-				
-				if(!this.migrationService.calcMaxFlag(flow.getFlag(), fer.getFlag()).equals(flow.getFlag())) {
-					fer.setFlag(flow.getFlag());
-				}
-				
-				
-			}
-			
-			serializer.serialize();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-
-	private void addTest(BPMNTestcase testcase, TestgeneratorDSLSerializer serializer,
-			ProjectDirectories projectDirectories) {
-		Flow flow = serializer.getFlow(testcase.getFlow());
-		
-		List<FlowElement> flowElements = serializer.getFlowElements();
-		List<Variable> variables = serializer.getVariables();
-		List<Mock> mocks = mockService.getMocks(testcase.getMocks(), projectDirectories);
-		
-		Test newTest = TestConverter.getTest(testcase, flow, flowElements, variables, mocks);
-		serializer.addTest(newTest);
-		
-		//Am Ende prüfen, ob der Flow auch ein neues Flag bekommen soll
-		Flag maxFlag = Flag.NONE;
-		for(Test t : serializer.getTestsForFlow(flow)) {
-			maxFlag = migrationService.calcMaxFlag(maxFlag, t.getFlag());
-		}
-		
-		flow.setFlag(maxFlag);
-	}
-
-	public List<VariableProposal<?>> getVariableProposals(ProjectDirectories projectDirectories) {
-		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
-
-		List<VariableProposal<?>> variableProposals = new ArrayList<>();
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
-
-			variableProposals = serializer.getVariableProposals();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-
-		return variableProposals;
-	}
-
-	public List<BPMNTestcase> getTests(ProjectDirectories projectDirectories, Flow flow) {
-		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
-
-			List<Test> testsForFlow = serializer.getTestsForFlow(flow);
-			List<BPMNTestcase> bpmnTestcases = new ArrayList<>();
-			for (Test test : testsForFlow) {
-				bpmnTestcases.add(TestConverter.getBPMNTestcase(test));
-			}
-
-			return bpmnTestcases;
-		} catch (IOException e) {
-			//
-		}
-
-		return null;
-	}
-
-	public BPMNTestcase getTest(ProjectDirectories projectDirectories, String testId) {
-		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
-
-			Test test = getTest(testId, serializer);
-
-			BPMNTestcase bpmnTestcase = TestConverter.getBPMNTestcase(test);
-			
-			for(TaskVariables t : bpmnTestcase.getTaskVariableList()) {
-				FlowElement e = serializer.getFlowElements(Arrays.asList(t.getTask())).get(0);
-				if(e instanceof UserTaskFlowElement) {
-					UserTaskFlowElement ue = (UserTaskFlowElement) e;
-					for(VariableReference vr : ue.getInputVariables()) {
-						for(VariableValue vv : t.getVariableValues()) {
-							if(vv.getVariable().equals(vr.getRef().getName())) {
-								if(vr.getValidationStatus().equals(ValidationState.REQUIRED)) {
-									vv.setRequired(true);
-								}
-								else {
-									vv.setRequired(false);
-								}
-							}
-						}
-					}
-				}
-				if(e instanceof StartFlowElement) {
-					StartFlowElement se = (StartFlowElement) e;
-					for(VariableReference vr : se.getInputVariables()) {
-						for(VariableValue vv : t.getVariableValues()) {
-							if(vv.getVariable().equals(vr.getRef().getName())) {
-								if(vr.getValidationStatus().equals(ValidationState.REQUIRED)) {
-									vv.setRequired(true);
-								}
-								else {
-									vv.setRequired(false);
-								}
-							}
-						}
-					}
-				}
-			}
-			
-			
-			return bpmnTestcase;
-		} catch (IOException e) {
-			//
-		}
-
-		return null;
-	}
-
-	public void deleteTest(ProjectDirectories projectDirectories, String testId) {
-		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
-			
-			Test test = serializer.getTest(testId);
-			Flow f = test.getFlowReference().getRef();
-			int testCount = serializer.getTestsForFlow(f).size();
-
-			serializer.deleteTest(testId);
-			
-			//Letzter Test gelöscht?
-			if(testCount == 1) {
-				f.setFlag(Flag.NONE);
-			}
-			
-			//Für alle Elemente das Flag zurücksetzen (GREEN oder NONE?)
-			//Aber nur machen, wenn es für ein FlowElement nicht noch ein Testcase existiert
-			List<Test> testsForFlow = serializer.getTestsForFlow(f);
-			boolean hasTestsWhichAreNotFixed = false;
-			for(FlowElementReference fer : f.getInclElements()) {
-				checkLoop:
-				for(Test t : testsForFlow) {
-					if(!t.getName().equals(test.getName())) {
-						if(t.getFlag().equals(Flag.RED) || t.getFlag().equals(Flag.YELLOW)) {
-							for(VariableDeclarations vds : t.getDeclarations()) {
-								if(vds.getTaskReference().getRef().getName().equals(fer.getRef().getName())) {
-									hasTestsWhichAreNotFixed = true;
-									break checkLoop;
-								}
-							}
-						}
-					}
-					
-				}
-				
-				if(!hasTestsWhichAreNotFixed) {
-					if(!fer.getFlag().equals(Flag.NONE)) {
-						fer.setFlag(Flag.GREEN);
-					}
-				}
-			}
-			
-			//Am Ende prüfen, ob der Flow auch ein neues Flag bekommen soll
-			Flag maxFlag = Flag.NONE;
-			for(Test t : serializer.getTestsForFlow(f)) {
-				maxFlag = migrationService.calcMaxFlag(maxFlag, t.getFlag());
-			}
-			
-			f.setFlag(maxFlag);
-			
-			//Elemente ggf auch noch updaten, wenn diese noch höher sind als der Flow selbst
-			for(FlowElementReference fer : f.getInclElements()) {
-				if(f.getFlag().equals(Flag.GREEN) && !fer.getFlag().equals(Flag.NONE)) {
-					fer.setFlag(Flag.GREEN);
-					continue;
-				}
-				
-				if(!this.migrationService.calcMaxFlag(f.getFlag(), fer.getFlag()).equals(f.getFlag())) {
-					fer.setFlag(f.getFlag());
-				}
-				
-				
-			}
-			
-			serializer.serialize();
-		} catch (IOException e) {
-			//
-		}
-	}
-
-	public List<FlowElement> getUserInputTasks(Flow flow) {
-		return TestgeneratorDSLUtils.getUserInputElements(flow);
-	}
-
-	public Map<String, Long> getFlowTestcount(ProjectDirectories projectDirectories) {
-		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
-
-		try {
-			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
-			Map<String, Long> flowTestCount = serializer.getFlowTestCount();
-
-			return flowTestCount;
-		} catch (IOException e) {
-			//
-		}
-
-		return new HashMap<>();
-	}
-
-	private List<FlowElement> getFlowElements(BPMNFlowSet flowSet, List<Variable> variables, BPMNFormFields formFields,
-			BPMNExpressions expressions, BPMNIOParameters bpmnIOParameters, List<ExternalTopic> externalTopics) {
-		return flowSet.getFlowElements().stream() //
-				.map(flowElement -> getFlowElement(flowElement, variables, formFields, expressions, bpmnIOParameters,
-						externalTopics)) //
-				.collect(Collectors.toList()); //
-	}
-
-	private FlowElement getFlowElement(org.camunda.bpm.model.bpmn.instance.FlowElement flowElement,
-			List<Variable> variables, BPMNFormFields formFields, BPMNExpressions expressions,
-			BPMNIOParameters bpmnIOParameters, List<ExternalTopic> externalTopics) {
-		if (flowElement instanceof StartEvent) {
-			List<Variable> startVariables = filterFlowElementVariables(variables,
-					formFields.getVariablesForTask(flowElement.getId()));
-			
-			int dependencies = startVariables.size();
-			
-			HashMap<String, List<BPMNFieldConstraint>> allConstraintsForTask = formFields.getAllTaskSpecificConstraintsForTask(flowElement.getId());
-			HashMap<String, List<Constraint>> newTaskSpecificConstraints = new HashMap<>();
-			
-			
-			for(Variable v : startVariables) {
-				if(allConstraintsForTask.get(v.getName()) != null && !allConstraintsForTask.get(v.getName()).isEmpty()) {
-					//Constraints kopieren
-					List<Constraint> variableConstraints = new ArrayList<>();
-					for(BPMNFieldConstraint c : allConstraintsForTask.get(v.getName())) {
-						Constraint newConstraint = TestgeneratorDSLFactory.eINSTANCE.createConstraint();
-						if(c instanceof BPMNBooleanConstraint) {
-							BPMNBooleanConstraint bc = (BPMNBooleanConstraint) c;
-							newConstraint.setKey("required");
-							if(bc.getRequired()) {
-								newConstraint.setValue(1);
-							}
-							else {
-								newConstraint.setValue(0);
-							}
-							variableConstraints.add(newConstraint);
-						}
-					}
-					
-					newTaskSpecificConstraints.put(v.getName(), variableConstraints);
-				}
-				else {
-					List<Constraint> variableConstraints = new ArrayList<>();
-					Constraint newConstraint = TestgeneratorDSLFactory.eINSTANCE.createConstraint();
-					newConstraint.setKey("required");
-					newConstraint.setValue(0);
-					variableConstraints.add(newConstraint);
-					newTaskSpecificConstraints.put(v.getName(), variableConstraints);
-				}
-			}
-			
-			
-			return TestgeneratorDSLObjectCreator.createStartFlowElement(flowElement.getId(), startVariables, newTaskSpecificConstraints);
-		} else if (flowElement instanceof EndEvent) {
-			return TestgeneratorDSLObjectCreator.createEndFlowElement(flowElement.getId());
-		} else if (flowElement instanceof Gateway) {
-			return TestgeneratorDSLObjectCreator.createGatewayFlowElement(flowElement.getId());
-		} else if (flowElement instanceof UserTask) {
-			List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
-			List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
-			int dependencies = inputVariables.size() + outputVariables.size();
-			
-			HashMap<String, List<BPMNFieldConstraint>> allConstraintsForTask = formFields.getAllTaskSpecificConstraintsForTask(flowElement.getId());
-			HashMap<String, List<Constraint>> newTaskSpecificConstraints = new HashMap<>();
-			
-			for(Variable v : inputVariables) {
-				if(allConstraintsForTask.get(v.getName()) != null && !allConstraintsForTask.get(v.getName()).isEmpty()) {
-					//Constraints kopieren
-					List<Constraint> variableConstraints = new ArrayList<>();
-					for(BPMNFieldConstraint c : allConstraintsForTask.get(v.getName())) {
-						Constraint newConstraint = TestgeneratorDSLFactory.eINSTANCE.createConstraint();
-						if(c instanceof BPMNBooleanConstraint) {
-							BPMNBooleanConstraint bc = (BPMNBooleanConstraint) c;
-							newConstraint.setKey("required");
-							if(bc.getRequired()) {
-								newConstraint.setValue(1);
-							}
-							else {
-								newConstraint.setValue(0);
-							}
-							variableConstraints.add(newConstraint);
-						}
-					}
-					
-					newTaskSpecificConstraints.put(v.getName(), variableConstraints);
-				}
-				else {
-					List<Constraint> variableConstraints = new ArrayList<>();
-					Constraint newConstraint = TestgeneratorDSLFactory.eINSTANCE.createConstraint();
-					newConstraint.setKey("required");
-					newConstraint.setValue(0);
-					variableConstraints.add(newConstraint);
-					newTaskSpecificConstraints.put(v.getName(), variableConstraints);
-				}
-			}
-			
-			return TestgeneratorDSLObjectCreator.createUserTaskFlowElement(flowElement.getId(), inputVariables, outputVariables,
-					flowElement.getName(), newTaskSpecificConstraints);
-		} else if (flowElement instanceof ManualTask) {
-			List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
-			List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
-			int dependencies = inputVariables.size() + outputVariables.size();
-			return TestgeneratorDSLObjectCreator.createManualTaskFlowElement(flowElement.getId(), inputVariables, outputVariables, flowElement.getName());
-		} else if (flowElement instanceof ScriptTask) {
-			List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
-			List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
-			int dependencies = inputVariables.size() + outputVariables.size();
-			return TestgeneratorDSLObjectCreator.createScriptTaskFlowElement(flowElement.getId(), inputVariables, outputVariables, flowElement.getName());
-		} else if (flowElement instanceof BusinessRuleTask) {
-			String resultVariable = BPMNParseUtils.getResultVariable((BusinessRuleTask) flowElement);
-			List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
-			List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
-			int dependencies = inputVariables.size() + outputVariables.size();
-			return TestgeneratorDSLObjectCreator.createBusinessRuleTaskFlowElement(flowElement.getId(), resultVariable, inputVariables, outputVariables, flowElement.getName());
-		
-		} else if (flowElement instanceof ServiceTask) {
-			String delegate = getDelegate((ServiceTask) flowElement);
-			String externalTopicTextual = getExternalTopic((ServiceTask) flowElement);
-			ExternalTopic externalTopic = getExternalTopic(externalTopics, externalTopicTextual);
-
-			if (delegate != null) {
-				List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
-				List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
-				int dependencies = inputVariables.size() + outputVariables.size();
-				return TestgeneratorDSLObjectCreator.createDelegateServiceTaskFlowElement(flowElement.getId(),
-						delegate, inputVariables, outputVariables, flowElement.getName());
-			} else if (externalTopic != null) {
-				List<VariableDeclaration> hardcodedVariables = BPMNParseUtils.getHardcodedVariables(flowElement.getId(), variables,
-						bpmnIOParameters);
-				List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
-				List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
-				int dependencies = inputVariables.size() + outputVariables.size();
-				return TestgeneratorDSLObjectCreator.createExternalServiceTaskFlowElement(flowElement.getId(),
-						externalTopic, hardcodedVariables, flowElement.getName(), inputVariables, outputVariables);
-			} else {
-				throw new IncompleteFlowElementException(flowElement.getId());
-			}
-		} else if (flowElement instanceof SequenceFlow) {
-			String expression = expressions.getSequenceFlowExpressionMap().get(flowElement.getId());
-			return TestgeneratorDSLObjectCreator.createSequenceFlowElement(flowElement.getId(), expression);
-			
-		}
-
-
-		throw new UnsupportedFlowElementException(flowElement.getId());
-	}
-	
-	private List<Variable> getInputVariables(String flowElementId, BPMNIOParameters bpmnIOParameters, List<Variable> variables, BPMNFormFields formFields) {
-		List<String> inputVariableNames = new ArrayList<>();
-		inputVariableNames.addAll(bpmnIOParameters.getInputVariables(flowElementId));
-		
-		//Test Flo
-		inputVariableNames.addAll(formFields.getVariablesForTask(flowElementId));
-		
-		List<Variable> inputVariables = filterFlowElementVariables(variables, inputVariableNames);
-		return inputVariables;
-	}
-	
-	private List<Variable> getOutputVariables(String flowElementId, BPMNIOParameters bpmnIOParameters, List<Variable> variables) {
-		List<String> outputVariableNames = new ArrayList<>();
-		outputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElementId));
-		List<Variable> outputVariables = filterFlowElementVariables(variables, outputVariableNames);
-		return outputVariables;
-	}
- 
-	private List<Flow> getFlows(BPMNDiagram bpmn, BPMNFlowSet flowSet, List<FlowElement> flowElements) {
-		return flowSet.getFlows().stream() //
-				.map(flow -> createFlow(bpmn, flow, flowElements)) //
-				.collect(Collectors.toList()); //
-	}
-
-	private Flow createFlow(BPMNDiagram bpmn, BPMNFlow flow, List<FlowElement> flowElements) {
-		List<String> flowNodes = flow.getFlowElementIds();
-
-		List<FlowElement> inclFlowElements = getInclFlowElements(flowElements, flowNodes);
-		List<FlowElement> exclFlowElements = getExclFlowElements(flowElements, flowNodes);
-		return TestgeneratorDSLObjectCreator.createFlow(flow.getName(), bpmn, inclFlowElements, exclFlowElements);
-	}
-
-	private List<FlowElement> getInclFlowElements(List<FlowElement> flowElements, List<String> subset) {
-		return subset.stream() //
-				.map(flowElementName -> getFlowElementByName(flowElements, flowElementName)) //
-				.collect(Collectors.toList()); //
-	}
-
-	private List<FlowElement> getExclFlowElements(List<FlowElement> flowElements, List<String> subset) {
-		return flowElements.stream() //
-				.filter(flowElement -> !subset.contains(flowElement.getName())) //
-				.collect(Collectors.toList()); //
-	}
-
-	private List<Variable> filterFlowElementVariables(List<Variable> allVariables,
-			List<String> variablesForFlowElement) {
-		return allVariables.stream() //
-				.filter(variable -> variablesForFlowElement.contains(variable.getName())) //
-				.collect(Collectors.toList()); //
-	}
-
-	@SuppressWarnings("unchecked")
-	private <T extends Object> List<T> getProposals(String variable, BPMNTestdata<? extends Object> variableTestdata,
-			Class<T> clazz) {
-		return variableTestdata.getValues().stream() //
-				.map(value -> ((T) value)) //
-				.collect(Collectors.toList()); //
-	}
-
-	private List<Integer> getIntProposals(String variable, BPMNTestdata<? extends Object> variableTestdata) {
-		return variableTestdata.getValues().stream() //
-				.map(value -> ((Long) value).intValue()) //
-				.collect(Collectors.toList()); //
-	}
-
-	private void checkTestIdAlreadyTaken(String testId, TestgeneratorDSLSerializer serializer) {
-		Test test = serializer.getTest(testId);
-
-		if (test != null) {
-			throw new TestIdAlreadyTakenException(testId);
-		}
-	}
-
-	private Test getTest(String testId, TestgeneratorDSLSerializer serializer) {
-		Test test = serializer.getTest(testId);
-		if (test == null) {
-			throw new TestNotFoundException(testId);
-		}
-
-		return test;
-	}
-
-	private FlowElement getFlowElementByName(List<FlowElement> flowElements, String name) {
-		return flowElements.stream() //
-				.filter(flowElement -> flowElement.getName().equals(name)) //
-				.findFirst() //
-				.get(); // always present
-	}
-
-	private String getDelegate(ServiceTask serviceTask) {
-		String delegate = serviceTask.getAttributeValueNs(NAMESPACE_URI_BPMN, "delegateExpression");
-
-		if (delegate != null) {
-			delegate = delegate.substring(2, delegate.length() - 1);
-		}
-
-		return delegate;
-	}
-
-	private List<ExternalTopic> getExternalTopics(BPMNFlowSet flowSet) {
-		return flowSet.getFlowElements().stream() //
-				.filter(flowElement -> flowElement instanceof ServiceTask) //
-				.map(serviceTask -> ((ServiceTask) serviceTask)) //
-				.map(serviceTask -> getExternalTopic(serviceTask)) //
-				.filter(externalTopicName -> externalTopicName != null) //
-				.distinct() //
-				.map(externalTopicName -> TestgeneratorDSLObjectCreator.createExternalTopic(externalTopicName)) //
-				.collect(Collectors.toList()); //
-	}
-
-	private String getExternalTopic(ServiceTask serviceTask) {
-		String externalTopic = serviceTask.getAttributeValueNs(NAMESPACE_URI_BPMN, "topic");
-		return externalTopic;
-	}
-
-	private ExternalTopic getExternalTopic(List<ExternalTopic> externalTopics, String externalTopicTextual) {
-		Optional<ExternalTopic> externalTopicOpt = externalTopics.stream() //
-				.filter(externalTopic -> externalTopic.getName().equals(externalTopicTextual)) //
-				.findFirst();
-
-		return externalTopicOpt.isPresent() ? externalTopicOpt.get() : null;
-	}
-
-	
-
-	private List<Loop> getLoops(List<de.fhmuenster.masterthesis.testgeneratorDSL.Loop> dslLoops) {
-		return dslLoops.stream() //
-				.map(dslLoop -> getLoop(dslLoop)) //
-				.collect(Collectors.toList()); //
-	}
-
-	private Loop getLoop(de.fhmuenster.masterthesis.testgeneratorDSL.Loop dslLoop) {
-		Loop loop = new Loop();
-		loop.setId(dslLoop.getName());
-		loop.setEndId(dslLoop.getEnd());
-		loop.setStartId(dslLoop.getStart());
-		loop.setStartFollowerId(dslLoop.getFollower());
-		loop.setComplexity(dslLoop.getComplexity());
-		loop.setFrequencies(TestgeneratorDSLUtils.getFrequencies(dslLoop));
-
-		return loop;
-	}
-}
+package de.fhmuenster.masterthesis.Testgenerator.rest.service.test;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import org.camunda.bpm.model.bpmn.instance.BusinessRuleTask;
+import org.camunda.bpm.model.bpmn.instance.EndEvent;
+import org.camunda.bpm.model.bpmn.instance.Gateway;
+import org.camunda.bpm.model.bpmn.instance.ManualTask;
+import org.camunda.bpm.model.bpmn.instance.ScriptTask;
+import org.camunda.bpm.model.bpmn.instance.SequenceFlow;
+import org.camunda.bpm.model.bpmn.instance.ServiceTask;
+import org.camunda.bpm.model.bpmn.instance.StartEvent;
+import org.camunda.bpm.model.bpmn.instance.UserTask;
+import org.eclipse.emf.common.util.BasicEList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNBooleanConstraint;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNBundle;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNExpressions;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFieldConstraint;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlow;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFlowSet;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNFormFields;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNIOParameters;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNNumericConstraint;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNTestcase;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNTestdata;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.TaskVariables;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.data.VariableValue;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNExpressionScanner;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNFlowScanner;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNVariableBoundaryScanner;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNVariableFormFieldScanner;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.BPMNVariableIOScanner;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.loop.Loop;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.loop.LoopFrequencyAssigner;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.loop.LoopScanner;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.sese.IsElement;
+import de.fhmuenster.masterthesis.Testgenerator.bpmn.processfragmentation.sese.SESEBuilder;
+import de.fhmuenster.masterthesis.Testgenerator.dmn.data.DMNBundle;
+import de.fhmuenster.masterthesis.Testgenerator.dmn.data.DMNDecisionModel;
+import de.fhmuenster.masterthesis.Testgenerator.dmn.data.DMNVariables;
+import de.fhmuenster.masterthesis.Testgenerator.embeddedform.data.EmbeddedFormDocument;
+import de.fhmuenster.masterthesis.Testgenerator.logging.LoggerProvider;
+import de.fhmuenster.masterthesis.Testgenerator.logging.TestgeneratorLogger;
+import de.fhmuenster.masterthesis.Testgenerator.migration.MigrationService;
+import de.fhmuenster.masterthesis.Testgenerator.rest.service.converters.TestConverter;
+import de.fhmuenster.masterthesis.Testgenerator.rest.service.flow.FlowService;
+import de.fhmuenster.masterthesis.Testgenerator.rest.service.mock.MockService;
+import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.Project;
+import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.ProjectDirectories;
+import de.fhmuenster.masterthesis.Testgenerator.utils.BPMNParseUtils;
+import de.fhmuenster.masterthesis.Testgenerator.utils.ProjectDirectoryUtils;
+import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLObjectCreator;
+import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
+import de.fhmuenster.masterthesis.serialization.VariableProposal;
+import de.fhmuenster.masterthesis.testgeneratorDSL.BPMNDiagram;
+import de.fhmuenster.masterthesis.testgeneratorDSL.Constraint;
+import de.fhmuenster.masterthesis.testgeneratorDSL.ExternalTopic;
+import de.fhmuenster.masterthesis.testgeneratorDSL.Flag;
+import de.fhmuenster.masterthesis.testgeneratorDSL.Flow;
+import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference;
+import de.fhmuenster.masterthesis.testgeneratorDSL.Mock;
+import de.fhmuenster.masterthesis.testgeneratorDSL.StartFlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.Test;
+import de.fhmuenster.masterthesis.testgeneratorDSL.TestgeneratorDSLFactory;
+import de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement;
+import de.fhmuenster.masterthesis.testgeneratorDSL.ValidationState;
+import de.fhmuenster.masterthesis.testgeneratorDSL.Variable;
+import de.fhmuenster.masterthesis.testgeneratorDSL.VariableDeclaration;
+import de.fhmuenster.masterthesis.testgeneratorDSL.VariableDeclarations;
+import de.fhmuenster.masterthesis.testgeneratorDSL.VariableReference;
+import de.fhmuenster.masterthesis.utils.TestgeneratorDSLUtils;
+
+@Service
+public class TestService {
+
+	private static final TestgeneratorLogger LOGGER = LoggerProvider.getLogger(TestService.class);
+	private static final String NAMESPACE_URI_BPMN = "http://camunda.org/schema/1.0/bpmn";
+
+	private long millisDataStart;
+	private long millisDataEnd;
+	
+	private List<String> taskIds = new ArrayList<String>();
+	
+	@Autowired
+	private FlowService flowService;
+	@Autowired
+	private MockService mockService;
+	
+	@Autowired
+	private MigrationService migrationService;
+
+	public TestService() {
+	}
+
+	public List<de.fhmuenster.masterthesis.testgeneratorDSL.Loop> initLoops(Project project) {
+		Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
+		String testpackage = project.getProjectDirectories().getTestPackage();
+		List<de.fhmuenster.masterthesis.testgeneratorDSL.Loop> dslLoops = null;
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testFilePath.toString());
+
+			BPMNDiagram bpmnDiagram = serializer.getBPMNDiagram("process");
+			if (bpmnDiagram == null) {
+				BPMNBundle bpmnBundle = BPMNParseUtils.readBPMNBundle(project);
+				List<DMNBundle> dmnBundles = BPMNParseUtils.readDMNBundles(project);
+				List<EmbeddedFormDocument> embeddedFormDocuments = BPMNParseUtils.readEmbeddedFormDocuments(project);
+				List<DMNDecisionModel> decisionModels = BPMNParseUtils.getDecisionModels(dmnBundles);
+				bpmnDiagram = BPMNParseUtils.getBPMNDiagram(bpmnBundle.getProcessModel(), testpackage, decisionModels,
+						embeddedFormDocuments);
+
+				// Build Single-Entry-Single-Exit-Graph
+				SESEBuilder seseBuilder = new SESEBuilder(bpmnBundle.getModelInstance());
+				seseBuilder.buildSingleEntrySingleExit();
+				List<IsElement> seseTransform = seseBuilder.getSeseTransform();
+
+				// Scan for loops
+				LoopScanner loopScanner = new LoopScanner(seseTransform);
+				List<Loop> loops = loopScanner.scanLoops();
+
+				// Set frequency for loops
+				LoopFrequencyAssigner frequencyAssigner = new LoopFrequencyAssigner(loops);
+				frequencyAssigner.assign();
+
+				serializer.addBPMNDiagram(bpmnDiagram);
+				dslLoops = flowService.getDSLLoops(loops);
+				dslLoops.forEach(dslLoop -> serializer.addLoop(dslLoop));
+
+				serializer.serialize();
+			}
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		if (dslLoops == null) {
+			return flowService.getLoops(project.getProjectDirectories());
+		}
+
+		return dslLoops;
+	}
+
+	public void initTestcollection(Project project) {
+		Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
+		String testpackage = project.getProjectDirectories().getTestPackage();
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testFilePath.toString());
+
+			BPMNDiagram bpmnDiagram = serializer.getBPMNDiagram("process");
+			List<FlowElement> flowElementsCheck = serializer.getFlowElements();
+			
+			if (bpmnDiagram != null && flowElementsCheck.isEmpty()) {
+				BPMNBundle bpmnBundle = BPMNParseUtils.readBPMNBundle(project);
+				List<DMNBundle> dmnBundles = BPMNParseUtils.readDMNBundles(project);
+				List<EmbeddedFormDocument> embeddedFormDocuments = BPMNParseUtils.readEmbeddedFormDocuments(project);
+				List<DMNDecisionModel> decisionModels = BPMNParseUtils.getDecisionModels(dmnBundles);
+
+				List<de.fhmuenster.masterthesis.testgeneratorDSL.Loop> dslLoops = serializer.getLoops();
+				List<Loop> loops = getLoops(dslLoops);
+
+				// Parse different flows of process model
+				BPMNFlowScanner scanner = new BPMNFlowScanner(bpmnBundle.getModelInstance(), loops);
+				BPMNFlowSet flowSet = scanner.scanFlows();
+
+				if (LOGGER.isInfo()) {
+					millisDataStart = System.currentTimeMillis();
+				}
+
+				// Read FormFields from Events and Tasks
+				BPMNVariableFormFieldScanner variableScanner = new BPMNVariableFormFieldScanner(flowSet);
+				EmbeddedFormDocument[] embeddedArray = new EmbeddedFormDocument[embeddedFormDocuments.size()];
+				variableScanner.setEmbeddedFormDocuments(embeddedFormDocuments.toArray(embeddedArray));
+				variableScanner.doScan();
+				BPMNFormFields formFields = variableScanner.getFormFields();
+
+				// Read Input/Output-Parameters
+				BPMNVariableIOScanner variableIOScanner = new BPMNVariableIOScanner(flowSet);
+				variableIOScanner.doScan();
+				BPMNIOParameters bpmnIOParameters = variableIOScanner.getBpmnIOParameters();
+
+				// Parse conditional expressions
+				BPMNExpressionScanner expressionScanner = new BPMNExpressionScanner(flowSet);
+				expressionScanner.doScan();
+				BPMNExpressions expressions = expressionScanner.getExpressions();
+
+				List<DMNVariables> dmnVariableList = BPMNParseUtils.getDMNVariables(dmnBundles);
+
+				BPMNVariableBoundaryScanner boundaryScanner = new BPMNVariableBoundaryScanner(expressions, formFields,
+						bpmnIOParameters, dmnVariableList);
+				boundaryScanner.doScan();
+				HashMap<String, BPMNTestdata<?>> variableTestdata = boundaryScanner.getVariableTestdata();
+
+				List<Variable> variables = BPMNParseUtils.getVariables(formFields, variableTestdata, bpmnIOParameters);
+
+				if (LOGGER.isInfo()) {
+					millisDataEnd = System.currentTimeMillis();
+					LOGGER.info("Time needed for Data-Scan: " + (millisDataEnd - millisDataStart) + " ms");
+				}
+				
+				List<ExternalTopic> externalTopics = getExternalTopics(flowSet);
+				List<FlowElement> flowElements = getFlowElements(flowSet, variables, formFields, expressions,
+						bpmnIOParameters, externalTopics);
+				List<Flow> flows = getFlows(bpmnDiagram, flowSet, flowElements);
+
+				flowElements.forEach(flowElement -> serializer.addFlowElement(flowElement));
+				variables.forEach(var -> serializer.addVariable(var));
+				externalTopics.forEach(externalTopic -> serializer.addExternalTopic(externalTopic));
+				flows.forEach(flow -> serializer.addFlow(flow));
+				flows.forEach(flow -> this.calculateFlowSize(flow));
+				
+				// TODO Henning
+				serializer.serialize();
+			}
+
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	private void calculateFlowSize(Flow flow) {
+		flow.setFlowSize(flow.getInclElements().size());
+	}
+	
+	public void addTest(BPMNTestcase testcase, ProjectDirectories projectDirectories) {
+		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
+
+			checkTestIdAlreadyTaken(testcase.getName(), serializer);
+
+			addTest(testcase, serializer, projectDirectories);
+			serializer.serialize();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	public void updateTest(String testId, BPMNTestcase testcase, ProjectDirectories projectDirectories) {
+		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
+
+			if (!testId.equals(testcase.getName())) {
+				checkTestIdAlreadyTaken(testcase.getName(), serializer);
+			}
+			
+			//Test-Flag aktualisieren
+			testcase.setFlag("GREEN");
+			
+			//Für alle Elemente das Flag zurücksetzen (GREEN oder NONE?)
+			//Aber nur machen, wenn es für ein FlowElement nicht noch ein Testcase existiert
+			Flow flow = serializer.getFlow(testcase.getFlow());
+			List<Test> testsForFlow = serializer.getTestsForFlow(flow);
+			boolean hasTestsWhichAreNotFixed = false;
+			for(FlowElementReference fer : flow.getInclElements()) {
+				checkLoop:
+				for(Test t : testsForFlow) {
+					if(!t.getName().equals(testcase.getName())) {
+						if(t.getFlag().equals(Flag.RED) || t.getFlag().equals(Flag.YELLOW)) {
+							for(VariableDeclarations vds : t.getDeclarations()) {
+								if(vds.getTaskReference().getRef().getName().equals(fer.getRef().getName())) {
+									hasTestsWhichAreNotFixed = true;
+									break checkLoop;
+								}
+							}
+						}
+					}
+					
+				}
+				
+				if(!hasTestsWhichAreNotFixed) {
+					if(!fer.getFlag().equals(Flag.NONE)) {
+						fer.setFlag(Flag.GREEN);
+					}
+					//fer.setFlag(Flag.NONE);
+				}
+			}
+			
+			Test testToDelete = getTest(testId, serializer);
+			serializer.deleteTest(testToDelete.getName());
+			addTest(testcase, serializer, projectDirectories);
+			
+			//Am Ende prüfen, ob der Flow auch ein neues Flag bekommen soll
+			Flag maxFlag = Flag.NONE;
+			for(Test t : serializer.getTestsForFlow(flow)) {
+				maxFlag = migrationService.calcMaxFlag(maxFlag, t.getFlag());
+			}
+			
+			flow.setFlag(maxFlag);
+			
+			//Elemente ggf auch noch updaten, wenn diese noch höher sind als der Flow selbst
+			for(FlowElementReference fer : flow.getInclElements()) {
+				if(flow.getFlag().equals(Flag.GREEN) && !fer.getFlag().equals(Flag.NONE)) {
+					fer.setFlag(Flag.GREEN);
+					continue;
+				}
+				if(!this.migrationService.calcMaxFlag(flow.getFlag(), fer.getFlag()).equals(flow.getFlag())) {
+					fer.setFlag(flow.getFlag());
+				}
+			}
+
+			serializer.serialize();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	public void markTest(String testId, BPMNTestcase testcase, ProjectDirectories projectDirectories) {
+		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
+			
+			Test test = getTest(testId, serializer);
+			test.setFlag(Flag.get(testcase.getFlag()));
+			
+			//Für alle Elemente das Flag zurücksetzen (GREEN oder NONE?)
+			//Aber nur machen, wenn es für ein FlowElement nicht noch ein Testcase existiert
+			Flow flow = serializer.getFlow(testcase.getFlow());
+			List<Test> testsForFlow = serializer.getTestsForFlow(flow);
+			boolean hasTestsWhichAreNotFixed = false;
+			for(FlowElementReference fer : flow.getInclElements()) {
+				checkLoop:
+				for(Test t : testsForFlow) {
+					if(!t.getName().equals(testcase.getName())) {
+						if(t.getFlag().equals(Flag.RED) || t.getFlag().equals(Flag.YELLOW)) {
+							for(VariableDeclarations vds : t.getDeclarations()) {
+								if(vds.getTaskReference().getRef().getName().equals(fer.getRef().getName())) {
+									hasTestsWhichAreNotFixed = true;
+									break checkLoop;
+								}
+							}
+						}
+					}
+					
+				}
+				
+				if(!fer.getFlag().equals(Flag.NONE)) {
+					fer.setFlag(Flag.GREEN);
+				}
+			}
+			
+			//Am Ende prüfen, ob der Flow auch ein neues Flag bekommen soll
+			Flag maxFlag = Flag.NONE;
+			for(Test t : serializer.getTestsForFlow(flow)) {
+				maxFlag = migrationService.calcMaxFlag(maxFlag, t.getFlag());
+			}
+			
+			flow.setFlag(maxFlag);
+			
+			//Elemente ggf auch noch updaten, wenn diese noch höher sind als der Flow selbst
+			for(FlowElementReference fer : flow.getInclElements()) {
+				if(flow.getFlag().equals(Flag.GREEN) && !fer.getFlag().equals(Flag.NONE)) {
+					fer.setFlag(Flag.GREEN);
+					continue;
+				}
+				
+				if(!this.migrationService.calcMaxFlag(flow.getFlag(), fer.getFlag()).equals(flow.getFlag())) {
+					fer.setFlag(flow.getFlag());
+				}
+				
+				
+			}
+			
+			serializer.serialize();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	private void addTest(BPMNTestcase testcase, TestgeneratorDSLSerializer serializer,
+			ProjectDirectories projectDirectories) {
+		Flow flow = serializer.getFlow(testcase.getFlow());
+		
+		List<FlowElement> flowElements = serializer.getFlowElements();
+		List<Variable> variables = serializer.getVariables();
+		List<Mock> mocks = mockService.getMocks(testcase.getMocks(), projectDirectories);
+		
+		Test newTest = TestConverter.getTest(testcase, flow, flowElements, variables, mocks);
+		serializer.addTest(newTest);
+		
+		//Am Ende prüfen, ob der Flow auch ein neues Flag bekommen soll
+		Flag maxFlag = Flag.NONE;
+		for(Test t : serializer.getTestsForFlow(flow)) {
+			maxFlag = migrationService.calcMaxFlag(maxFlag, t.getFlag());
+		}
+		
+		flow.setFlag(maxFlag);
+	}
+
+	public List<VariableProposal<?>> getVariableProposals(ProjectDirectories projectDirectories) {
+		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
+
+		List<VariableProposal<?>> variableProposals = new ArrayList<>();
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
+
+			variableProposals = serializer.getVariableProposals();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		return variableProposals;
+	}
+
+	public List<BPMNTestcase> getTests(ProjectDirectories projectDirectories, Flow flow) {
+		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
+
+			List<Test> testsForFlow = serializer.getTestsForFlow(flow);
+			List<BPMNTestcase> bpmnTestcases = new ArrayList<>();
+			for (Test test : testsForFlow) {
+				bpmnTestcases.add(TestConverter.getBPMNTestcase(test));
+			}
+
+			return bpmnTestcases;
+		} catch (IOException e) {
+			//
+		}
+
+		return null;
+	}
+
+	public BPMNTestcase getTest(ProjectDirectories projectDirectories, String testId) {
+		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
+
+			Test test = getTest(testId, serializer);
+
+			BPMNTestcase bpmnTestcase = TestConverter.getBPMNTestcase(test);
+			
+			for(TaskVariables t : bpmnTestcase.getTaskVariableList()) {
+				FlowElement e = serializer.getFlowElements(Arrays.asList(t.getTask())).get(0);
+				if(e instanceof UserTaskFlowElement) {
+					UserTaskFlowElement ue = (UserTaskFlowElement) e;
+					for(VariableReference vr : ue.getInputVariables()) {
+						for(VariableValue vv : t.getVariableValues()) {
+							if(vv.getVariable().equals(vr.getRef().getName())) {
+								if(vr.getValidationStatus().equals(ValidationState.REQUIRED)) {
+									vv.setRequired(true);
+								}
+								else {
+									vv.setRequired(false);
+								}
+							}
+						}
+					}
+				}
+				if(e instanceof StartFlowElement) {
+					StartFlowElement se = (StartFlowElement) e;
+					for(VariableReference vr : se.getInputVariables()) {
+						for(VariableValue vv : t.getVariableValues()) {
+							if(vv.getVariable().equals(vr.getRef().getName())) {
+								if(vr.getValidationStatus().equals(ValidationState.REQUIRED)) {
+									vv.setRequired(true);
+								}
+								else {
+									vv.setRequired(false);
+								}
+							}
+						}
+					}
+				}
+			}
+			
+			
+			return bpmnTestcase;
+		} catch (IOException e) {
+			//
+		}
+
+		return null;
+	}
+
+	public void deleteTest(ProjectDirectories projectDirectories, String testId) {
+		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
+			
+			Test test = serializer.getTest(testId);
+			Flow f = test.getFlowReference().getRef();
+			int testCount = serializer.getTestsForFlow(f).size();
+
+			serializer.deleteTest(testId);
+			
+			//Letzter Test gelöscht?
+			if(testCount == 1) {
+				f.setFlag(Flag.NONE);
+			}
+			
+			//Für alle Elemente das Flag zurücksetzen (GREEN oder NONE?)
+			//Aber nur machen, wenn es für ein FlowElement nicht noch ein Testcase existiert
+			List<Test> testsForFlow = serializer.getTestsForFlow(f);
+			boolean hasTestsWhichAreNotFixed = false;
+			for(FlowElementReference fer : f.getInclElements()) {
+				checkLoop:
+				for(Test t : testsForFlow) {
+					if(!t.getName().equals(test.getName())) {
+						if(t.getFlag().equals(Flag.RED) || t.getFlag().equals(Flag.YELLOW)) {
+							for(VariableDeclarations vds : t.getDeclarations()) {
+								if(vds.getTaskReference().getRef().getName().equals(fer.getRef().getName())) {
+									hasTestsWhichAreNotFixed = true;
+									break checkLoop;
+								}
+							}
+						}
+					}
+					
+				}
+				
+				if(!hasTestsWhichAreNotFixed) {
+					if(!fer.getFlag().equals(Flag.NONE)) {
+						fer.setFlag(Flag.GREEN);
+					}
+				}
+			}
+			
+			//Am Ende prüfen, ob der Flow auch ein neues Flag bekommen soll
+			Flag maxFlag = Flag.NONE;
+			for(Test t : serializer.getTestsForFlow(f)) {
+				maxFlag = migrationService.calcMaxFlag(maxFlag, t.getFlag());
+			}
+			
+			f.setFlag(maxFlag);
+			
+			//Elemente ggf auch noch updaten, wenn diese noch höher sind als der Flow selbst
+			for(FlowElementReference fer : f.getInclElements()) {
+				if(f.getFlag().equals(Flag.GREEN) && !fer.getFlag().equals(Flag.NONE)) {
+					fer.setFlag(Flag.GREEN);
+					continue;
+				}
+				
+				if(!this.migrationService.calcMaxFlag(f.getFlag(), fer.getFlag()).equals(f.getFlag())) {
+					fer.setFlag(f.getFlag());
+				}
+				
+				
+			}
+			
+			serializer.serialize();
+		} catch (IOException e) {
+			//
+		}
+	}
+
+	public List<FlowElement> getUserInputTasks(Flow flow) {
+		return TestgeneratorDSLUtils.getUserInputElements(flow);
+	}
+
+	public Map<String, Long> getFlowTestcount(ProjectDirectories projectDirectories) {
+		Path testspecificationPath = ProjectDirectoryUtils.getTestspecificationPath(projectDirectories);
+
+		try {
+			TestgeneratorDSLSerializer serializer = new TestgeneratorDSLSerializer(testspecificationPath.toString());
+			Map<String, Long> flowTestCount = serializer.getFlowTestCount();
+
+			return flowTestCount;
+		} catch (IOException e) {
+			//
+		}
+
+		return new HashMap<>();
+	}
+
+	private List<FlowElement> getFlowElements(BPMNFlowSet flowSet, List<Variable> variables, BPMNFormFields formFields,
+			BPMNExpressions expressions, BPMNIOParameters bpmnIOParameters, List<ExternalTopic> externalTopics) {
+		return flowSet.getFlowElements().stream() //
+				.map(flowElement -> getFlowElement(flowElement, variables, formFields, expressions, bpmnIOParameters,
+						externalTopics)) //
+				.collect(Collectors.toList()); //
+	}
+
+	private FlowElement getFlowElement(org.camunda.bpm.model.bpmn.instance.FlowElement flowElement,
+			List<Variable> variables, BPMNFormFields formFields, BPMNExpressions expressions,
+			BPMNIOParameters bpmnIOParameters, List<ExternalTopic> externalTopics) {
+		if (flowElement instanceof StartEvent) {
+			List<Variable> startVariables = filterFlowElementVariables(variables,
+					formFields.getVariablesForTask(flowElement.getId()));
+			
+			int dependencies = startVariables.size();
+			
+			HashMap<String, List<BPMNFieldConstraint>> allConstraintsForTask = formFields.getAllTaskSpecificConstraintsForTask(flowElement.getId());
+			HashMap<String, List<Constraint>> newTaskSpecificConstraints = new HashMap<>();
+			
+			
+			for(Variable v : startVariables) {
+				if(allConstraintsForTask.get(v.getName()) != null && !allConstraintsForTask.get(v.getName()).isEmpty()) {
+					//Constraints kopieren
+					List<Constraint> variableConstraints = new ArrayList<>();
+					for(BPMNFieldConstraint c : allConstraintsForTask.get(v.getName())) {
+						Constraint newConstraint = TestgeneratorDSLFactory.eINSTANCE.createConstraint();
+						if(c instanceof BPMNBooleanConstraint) {
+							BPMNBooleanConstraint bc = (BPMNBooleanConstraint) c;
+							newConstraint.setKey("required");
+							if(bc.getRequired()) {
+								newConstraint.setValue(1);
+							}
+							else {
+								newConstraint.setValue(0);
+							}
+							variableConstraints.add(newConstraint);
+						}
+					}
+					
+					newTaskSpecificConstraints.put(v.getName(), variableConstraints);
+				}
+				else {
+					List<Constraint> variableConstraints = new ArrayList<>();
+					Constraint newConstraint = TestgeneratorDSLFactory.eINSTANCE.createConstraint();
+					newConstraint.setKey("required");
+					newConstraint.setValue(0);
+					variableConstraints.add(newConstraint);
+					newTaskSpecificConstraints.put(v.getName(), variableConstraints);
+				}
+			}
+			
+			
+			return TestgeneratorDSLObjectCreator.createStartFlowElement(flowElement.getId(), startVariables, newTaskSpecificConstraints);
+		} else if (flowElement instanceof EndEvent) {
+			return TestgeneratorDSLObjectCreator.createEndFlowElement(flowElement.getId());
+		} else if (flowElement instanceof Gateway) {
+			return TestgeneratorDSLObjectCreator.createGatewayFlowElement(flowElement.getId());
+		} else if (flowElement instanceof UserTask) {
+			List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
+			List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
+			List<Variable> removeVariables = getRemoveVariables(flowElement.getId(), bpmnIOParameters, variables);
+			int dependencies = inputVariables.size() + outputVariables.size();
+			
+			HashMap<String, List<BPMNFieldConstraint>> allConstraintsForTask = formFields.getAllTaskSpecificConstraintsForTask(flowElement.getId());
+			HashMap<String, List<Constraint>> newTaskSpecificConstraints = new HashMap<>();
+			
+			for(Variable v : inputVariables) {
+				if(allConstraintsForTask.get(v.getName()) != null && !allConstraintsForTask.get(v.getName()).isEmpty()) {
+					//Constraints kopieren
+					List<Constraint> variableConstraints = new ArrayList<>();
+					for(BPMNFieldConstraint c : allConstraintsForTask.get(v.getName())) {
+						Constraint newConstraint = TestgeneratorDSLFactory.eINSTANCE.createConstraint();
+						if(c instanceof BPMNBooleanConstraint) {
+							BPMNBooleanConstraint bc = (BPMNBooleanConstraint) c;
+							newConstraint.setKey("required");
+							if(bc.getRequired()) {
+								newConstraint.setValue(1);
+							}
+							else {
+								newConstraint.setValue(0);
+							}
+							variableConstraints.add(newConstraint);
+						}
+					}
+					
+					newTaskSpecificConstraints.put(v.getName(), variableConstraints);
+				}
+				else {
+					List<Constraint> variableConstraints = new ArrayList<>();
+					Constraint newConstraint = TestgeneratorDSLFactory.eINSTANCE.createConstraint();
+					newConstraint.setKey("required");
+					newConstraint.setValue(0);
+					variableConstraints.add(newConstraint);
+					newTaskSpecificConstraints.put(v.getName(), variableConstraints);
+				}
+			}
+			
+			return TestgeneratorDSLObjectCreator.createUserTaskFlowElement(flowElement.getId(), inputVariables, outputVariables,
+					flowElement.getName(), newTaskSpecificConstraints, removeVariables);
+		} 
+		else if (flowElement instanceof ManualTask) 
+		{
+			List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
+			List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
+			List<Variable> removeVariables = getRemoveVariables(flowElement.getId(), bpmnIOParameters, variables);
+			int dependencies = inputVariables.size() + outputVariables.size();
+			
+			return TestgeneratorDSLObjectCreator.createManualTaskFlowElement(flowElement.getId(), inputVariables, 
+					outputVariables, flowElement.getName(), removeVariables);
+		} 
+		else if (flowElement instanceof ScriptTask) {
+			List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
+			List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
+			List<Variable> removeVariables = getRemoveVariables(flowElement.getId(), bpmnIOParameters, variables);
+			int dependencies = inputVariables.size() + outputVariables.size();
+			return TestgeneratorDSLObjectCreator.createScriptTaskFlowElement(flowElement.getId(), inputVariables, outputVariables, flowElement.getName(), removeVariables);
+		} else if (flowElement instanceof BusinessRuleTask) {
+			String resultVariable = BPMNParseUtils.getResultVariable((BusinessRuleTask) flowElement);
+			List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
+			List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
+			List<Variable> removeVariables = getRemoveVariables(flowElement.getId(), bpmnIOParameters, variables);
+			int dependencies = inputVariables.size() + outputVariables.size();
+			return TestgeneratorDSLObjectCreator.createBusinessRuleTaskFlowElement(flowElement.getId(), resultVariable, inputVariables, outputVariables, flowElement.getName(), removeVariables);
+		
+		} else if (flowElement instanceof ServiceTask) {
+			String delegate = getDelegate((ServiceTask) flowElement);
+			String externalTopicTextual = getExternalTopic((ServiceTask) flowElement);
+			ExternalTopic externalTopic = getExternalTopic(externalTopics, externalTopicTextual);
+
+			if (delegate != null) {
+				List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
+				List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
+				List<Variable> removeVariables = getRemoveVariables(flowElement.getId(), bpmnIOParameters, variables);
+				int dependencies = inputVariables.size() + outputVariables.size();
+				return TestgeneratorDSLObjectCreator.createDelegateServiceTaskFlowElement(flowElement.getId(),
+						delegate, inputVariables, outputVariables, flowElement.getName(), removeVariables);
+			} else if (externalTopic != null) {
+				List<VariableDeclaration> hardcodedVariables = BPMNParseUtils.getHardcodedVariables(flowElement.getId(), variables,
+						bpmnIOParameters);
+				List<Variable> inputVariables = getInputVariables(flowElement.getId(), bpmnIOParameters, variables, formFields);
+				List<Variable> outputVariables = getOutputVariables(flowElement.getId(), bpmnIOParameters, variables);
+				List<Variable> removeVariables = getRemoveVariables(flowElement.getId(), bpmnIOParameters, variables);
+				int dependencies = inputVariables.size() + outputVariables.size();
+				return TestgeneratorDSLObjectCreator.createExternalServiceTaskFlowElement(flowElement.getId(),
+						externalTopic, hardcodedVariables, flowElement.getName(), inputVariables, outputVariables, removeVariables);
+			} else {
+				throw new IncompleteFlowElementException(flowElement.getId());
+			}
+		} else if (flowElement instanceof SequenceFlow) {
+			String expression = expressions.getSequenceFlowExpressionMap().get(flowElement.getId());
+			return TestgeneratorDSLObjectCreator.createSequenceFlowElement(flowElement.getId(), expression);
+			
+		}
+
+
+		throw new UnsupportedFlowElementException(flowElement.getId());
+	}
+	
+	private List<Variable> getInputVariables(String flowElementId, BPMNIOParameters bpmnIOParameters, List<Variable> variables, BPMNFormFields formFields) {
+		List<String> inputVariableNames = new ArrayList<>();
+		inputVariableNames.addAll(bpmnIOParameters.getInputVariables(flowElementId));
+		
+		//Test Flo
+		inputVariableNames.addAll(formFields.getVariablesForTask(flowElementId));
+		
+		List<Variable> inputVariables = filterFlowElementVariables(variables, inputVariableNames);
+		return inputVariables;
+	}
+	
+	private List<Variable> getOutputVariables(String flowElementId, BPMNIOParameters bpmnIOParameters, List<Variable> variables) {
+		List<String> outputVariableNames = new ArrayList<>();
+		outputVariableNames.addAll(bpmnIOParameters.getOutputVariables(flowElementId));
+		List<Variable> outputVariables = filterFlowElementVariables(variables, outputVariableNames);
+		return outputVariables;
+	}
+	
+	/**
+	 * Function to get the removeVariables. Based on existing Vars, this function builds a new list with the type List<Variable>
+	 * @param flowElementId
+	 * @param bpmnIOParameters
+	 * @param variables
+	 * @return
+	 */
+	private List<Variable> getRemoveVariables(String flowElementId, BPMNIOParameters bpmnIOParameters, List<Variable> variables) {
+		List<String> removeVariableNames = new ArrayList<>();
+		removeVariableNames.addAll(bpmnIOParameters.getRemoveVariables(flowElementId));
+		
+		List<Variable> removeVariables = new ArrayList<>();
+		
+		for(String searchVar : removeVariableNames)
+		{
+			for(Variable var : variables)
+			{
+				if(var.getName().equals(searchVar))
+					removeVariables.add(var);
+			}
+		}
+		
+		return removeVariables;
+	}
+	
+	private List<Flow> getFlows(BPMNDiagram bpmn, BPMNFlowSet flowSet, List<FlowElement> flowElements) {
+		return flowSet.getFlows().stream() //
+				.map(flow -> createFlow(bpmn, flow, flowElements)) //
+				.collect(Collectors.toList()); //
+	}
+
+	private Flow createFlow(BPMNDiagram bpmn, BPMNFlow flow, List<FlowElement> flowElements) {
+		List<String> flowNodes = flow.getFlowElementIds();
+
+		List<FlowElement> inclFlowElements = getInclFlowElements(flowElements, flowNodes);
+		List<FlowElement> exclFlowElements = getExclFlowElements(flowElements, flowNodes);
+		return TestgeneratorDSLObjectCreator.createFlow(flow.getName(), bpmn, inclFlowElements, exclFlowElements);
+	}
+
+	private List<FlowElement> getInclFlowElements(List<FlowElement> flowElements, List<String> subset) {
+		return subset.stream() //
+				.map(flowElementName -> getFlowElementByName(flowElements, flowElementName)) //
+				.collect(Collectors.toList()); //
+	}
+
+	private List<FlowElement> getExclFlowElements(List<FlowElement> flowElements, List<String> subset) {
+		return flowElements.stream() //
+				.filter(flowElement -> !subset.contains(flowElement.getName())) //
+				.collect(Collectors.toList()); //
+	}
+
+	private List<Variable> filterFlowElementVariables(List<Variable> allVariables,
+			List<String> variablesForFlowElement) {
+		return allVariables.stream() //
+				.filter(variable -> variablesForFlowElement.contains(variable.getName())) //
+				.collect(Collectors.toList()); //
+	}
+
+	@SuppressWarnings("unchecked")
+	private <T extends Object> List<T> getProposals(String variable, BPMNTestdata<? extends Object> variableTestdata,
+			Class<T> clazz) {
+		return variableTestdata.getValues().stream() //
+				.map(value -> ((T) value)) //
+				.collect(Collectors.toList()); //
+	}
+
+	private List<Integer> getIntProposals(String variable, BPMNTestdata<? extends Object> variableTestdata) {
+		return variableTestdata.getValues().stream() //
+				.map(value -> ((Long) value).intValue()) //
+				.collect(Collectors.toList()); //
+	}
+
+	private void checkTestIdAlreadyTaken(String testId, TestgeneratorDSLSerializer serializer) {
+		Test test = serializer.getTest(testId);
+
+		if (test != null) {
+			throw new TestIdAlreadyTakenException(testId);
+		}
+	}
+
+	private Test getTest(String testId, TestgeneratorDSLSerializer serializer) {
+		Test test = serializer.getTest(testId);
+		if (test == null) {
+			throw new TestNotFoundException(testId);
+		}
+
+		return test;
+	}
+
+	private FlowElement getFlowElementByName(List<FlowElement> flowElements, String name) {
+		return flowElements.stream() //
+				.filter(flowElement -> flowElement.getName().equals(name)) //
+				.findFirst() //
+				.get(); // always present
+	}
+
+	private String getDelegate(ServiceTask serviceTask) {
+		String delegate = serviceTask.getAttributeValueNs(NAMESPACE_URI_BPMN, "delegateExpression");
+
+		if (delegate != null) {
+			delegate = delegate.substring(2, delegate.length() - 1);
+		}
+
+		return delegate;
+	}
+
+	private List<ExternalTopic> getExternalTopics(BPMNFlowSet flowSet) {
+		return flowSet.getFlowElements().stream() //
+				.filter(flowElement -> flowElement instanceof ServiceTask) //
+				.map(serviceTask -> ((ServiceTask) serviceTask)) //
+				.map(serviceTask -> getExternalTopic(serviceTask)) //
+				.filter(externalTopicName -> externalTopicName != null) //
+				.distinct() //
+				.map(externalTopicName -> TestgeneratorDSLObjectCreator.createExternalTopic(externalTopicName)) //
+				.collect(Collectors.toList()); //
+	}
+
+	private String getExternalTopic(ServiceTask serviceTask) {
+		String externalTopic = serviceTask.getAttributeValueNs(NAMESPACE_URI_BPMN, "topic");
+		return externalTopic;
+	}
+
+	private ExternalTopic getExternalTopic(List<ExternalTopic> externalTopics, String externalTopicTextual) {
+		Optional<ExternalTopic> externalTopicOpt = externalTopics.stream() //
+				.filter(externalTopic -> externalTopic.getName().equals(externalTopicTextual)) //
+				.findFirst();
+
+		return externalTopicOpt.isPresent() ? externalTopicOpt.get() : null;
+	}
+
+	
+
+	private List<Loop> getLoops(List<de.fhmuenster.masterthesis.testgeneratorDSL.Loop> dslLoops) {
+		return dslLoops.stream() //
+				.map(dslLoop -> getLoop(dslLoop)) //
+				.collect(Collectors.toList()); //
+	}
+
+	private Loop getLoop(de.fhmuenster.masterthesis.testgeneratorDSL.Loop dslLoop) {
+		Loop loop = new Loop();
+		loop.setId(dslLoop.getName());
+		loop.setEndId(dslLoop.getEnd());
+		loop.setStartId(dslLoop.getStart());
+		loop.setStartFollowerId(dslLoop.getFollower());
+		loop.setComplexity(dslLoop.getComplexity());
+		loop.setFrequencies(TestgeneratorDSLUtils.getFrequencies(dslLoop));
+
+		return loop;
+	}
+}