Skip to content
Snippets Groups Projects
Commit 53765a78 authored by Henning's avatar Henning
Browse files

added throws IOException, added function to set the Test priority

The test score is calculated from the sum of flow.size, flow.score and flow.dependency
parent c85ee6d8
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference;
import de.fhmuenster.masterthesis.testgeneratorDSL.ManualTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.ScriptTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.SequenceFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.Test;
import de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement;
import de.fhmuenster.masterthesis.testgeneratorDSL.VariableReference;
......@@ -39,7 +40,7 @@ public class PrioritizationService {
this.newDSL = newDSL;
}
public void prioritize() {
public void prioritize() throws IOException {
Map<String, List<VariableReference>> readVariablesOldDSL, writeVariablesOldDSL, readVariablesNewDSL, writeVariablesNewDSL, removeVariablesOldDSL, removeVariablesNewDSL;
readVariablesOldDSL = this.getReadVariables(this.oldDSL);
......@@ -66,21 +67,52 @@ public class PrioritizationService {
HashMap<String, List<String>> differentRemoveVariables = this.checkDifferences(changesRemoveVariablesOLD, changesRemoveVariables);
HashMap<String, Integer> dependenciesRead = this.checkFlowsWhereVariableExists(differentReadVariables);
HashMap<String, Integer> dependenciesWrite = this.checkFlowsWhereVariableExists(differentWriteVariables);
HashMap<String, Integer> dependenciesRemove = this.checkFlowsWhereVariableExists(differentRemoveVariables);
this.sumDependencies(dependenciesRead, dependenciesWrite, dependenciesRemove);
this.dumpDependencyList(this.newDSL.getFlows());
try {
this.newDSL.serialize();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.newDSL.serialize();
HashMap<String, Integer> testPriorities = this.sumTestPriorities();
this.setTestPriorities(testPriorities);
}
private void setTestPriorities(HashMap<String, Integer> testPriorities) throws IOException
{
testPriorities.forEach((k, v) -> {
Test test = this.newDSL.getTest(k);
test.setPriority(v);
System.out.println("[PRIORITY] Set priority " + v + " for Test " + k);
});
this.newDSL.serialize();
}
private HashMap<String, Integer> sumTestPriorities() {
List<Test> tests = this.newDSL.getTests();
List<Flow> flows = this.newDSL.getFlows();
HashMap<String, Integer> testPriorities = new HashMap<>();
for(Test test : tests)
{
for(Flow flow: flows)
{
if(test.getFlowReference().getRef().getName().equals(flow.getName()))
{
int size = flow.getFlowSize();
int score = flow.getScore();
int dependency = flow.getDependency();
int finalScore = size + score + dependency;
testPriorities.put(test.getName(), finalScore);
}
}
}
return testPriorities;
}
/**
* Here, the changes of the variables are compared to the flowelements
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment