Skip to content
Snippets Groups Projects
Commit 054787c5 authored by Florian Lambers's avatar Florian Lambers
Browse files
parents 0618ce02 c9ef1c5c
No related branches found
No related tags found
No related merge requests found
Showing
with 235 additions and 1 deletion
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\\test\\java\\de\\sample\\onlineschuhdemo\\Testcollection.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;
}
}
......@@ -19,10 +19,16 @@
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<button mdbBtn type="submit" (click)="compareProjects()" class="testgen-btn-rounded testgen-primary" rounded="true"
i18n="compare bpmn">Compare BPMN-Diagrams</button>
</div>
<div class="col-md-6">
<button mdbBtn type="submit" (click)="parseFiles()" class="testgen-btn-rounded testgen-primary" rounded="true"
i18n="compare bpmn">@Henning parseFiles Testing-Button</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -45,6 +45,18 @@ export class UpdateProjectComponent implements OnInit {
}
/*
Function parseFiles
@Henning
Testfunktion um die Generierten Testfiles zu vergleichen. Event dient nur als Trigger fürs Backend
*/
async parseFiles(projectId: number): Promise<string> {
var projectId = this.actualProject;
console.log(projectId);
const url = `${environment.apiBaseUrl}project/${projectId}/parse`;
return this.http.get(url, {responseType: 'text'}).toPromise();
}
async compareProjects() {
var currentDiagram, newDiagram;
......
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