Skip to content
Snippets Groups Projects
Commit 1288a236 authored by Henning Josef Moritz Werner Schmeink's avatar Henning Josef Moritz Werner Schmeink
Browse files

Added prioritization packet, added parser for DSL, creates Lists for

Tests and Flows
parent 5cb15ed3
No related branches found
No related tags found
No related merge requests found
package de.fhmuenster.masterthesis.Testgenerator.prioritization;
import java.util.List;
public class Flow {
public String flowName;
public List<String> withElements;
public List<String> withoutElements;
public Flow(String flowName, List<String> withElements, List<String> withoutElements) {
this.flowName = flowName;
this.withElements = withElements;
this.withoutElements = withoutElements;
}
}
package de.fhmuenster.masterthesis.Testgenerator.prioritization;
public class Metrics {
public static void flowAffected() {
}
public static void testcaseAdded() {
}
public static void testcaseChanged() {
}
}
package de.fhmuenster.masterthesis.Testgenerator.prioritization;
public class ParseFlows {
}
package de.fhmuenster.masterthesis.Testgenerator.prioritization;
public class ParseTests {
}
package de.fhmuenster.masterthesis.Testgenerator.prioritization;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PrioritizationService {
public static final String file1 = "D:\\VSProjects\\fe-pda-testing-tool\\OnlineSchuhDemo\\src\\main\\resources\\Testcollection1.bpmn-testgen";
/**
* TESTING STAGE
* @return "test"
* @throws IOException
*/
@RequestMapping(path = "/project/{projectId}/parse", method = RequestMethod.GET)
public String parseFile() throws IOException {
// Testcollection1 einlesen
BufferedReader bufferedReaderTest = new BufferedReader(new FileReader(file1));
BufferedReader bufferedReaderFlow = new BufferedReader(new FileReader(file1));
List<Test> testList = createTestList(bufferedReaderTest);
List<Flow> flowList = createFlowList(bufferedReaderFlow);
try {
Test myTest = testList.get(0);
System.out.println("PRINT TEST 0 ==============");
System.out.println(myTest.testName);
System.out.println(Arrays.toString(myTest.variables.toArray()));
System.out.println(Arrays.toString(myTest.check.toArray()));
System.out.println(Arrays.toString(myTest.mocks.toArray()));
Flow myFlow = flowList.get(0);
System.out.println("PRINT FLOW 0 ==============");
System.out.println(myFlow.flowName);
System.out.println(Arrays.toString(myFlow.withElements.toArray()));
System.out.println(Arrays.toString(myFlow.withoutElements.toArray()));
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
return "true";
}
/**
* Diese Funktion durchläuft die Testcollection, welche im BufferdReader übergeben wurde. Auf
* Basis des Inhalts werden Flowobjekte erzeugt und der Liste hinzugefügt
* @param bufferedReader
* @return Liste mit den Testobjekten (Test.java)
*/
public List<Flow> createFlowList(BufferedReader bufferedReader) {
List<Flow> flowList = new ArrayList<Flow>();
String flowName;
List<String> withElements = new ArrayList<>();
List<String> withoutElements = new ArrayList<>();
try {
String line = bufferedReader.readLine();
while(line != null) {
line = bufferedReader.readLine();
if(line.startsWith("Flow")) {
flowName = line;
while(!line.endsWith(";")) {
line = bufferedReader.readLine();
if(line.contains("with elements"))
withElements.add(line);
else if(line.contains("without elements"))
withoutElements.add(line);
// Hier wird das Flowobjekt erzeugt
Flow flow = new Flow(flowName, withElements, withoutElements);
flowList.add(flow);
}
}
}
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
return flowList;
}
/**
* Diese Funktion durchläuft die Testcollection, welche im BufferdReader übergeben wurde. Auf
* Basis des Inhalts werden Testobjekte erzeugt und der Liste hinzugefügt
* @param bufferedReader
* @return Liste mit den Testobjekten (Test.java)
*/
public List<Test> createTestList(BufferedReader bufferedReader) {
List<Test> testList = new ArrayList<Test>();
String testName;
List<String> testVariables = new ArrayList<>();
List<String> testCheck = new ArrayList<>();
List<String> testMocks = new ArrayList<>();
try {
String line = bufferedReader.readLine();
while(line != null) {
line = bufferedReader.readLine();
if(line.startsWith("Test")) {
testName = line;
while(!line.endsWith(";")) {
line = bufferedReader.readLine();
if(line.contains("with variables"))
testVariables.add(line);
else if(line.contains("with check"))
testCheck.add(line);
else if(line.contains("with mocks"))
testMocks.add(line);
// Hier wird das Testobjekt erzeugt
Test test = new Test(testName, testVariables, testCheck, testMocks);
testList.add(test);
}
}
}
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
return testList;
}
}
package de.fhmuenster.masterthesis.Testgenerator.prioritization;
import java.util.List;
public class Test {
public String testName;
public List<String> variables;
public List<String> check;
public List<String> mocks;
public Test(String testName, List<String> variables, List<String> check, List<String> mocks) {
this.testName = testName;
this.variables = variables;
this.check = check;
this.mocks = mocks;
}
}
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