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

Added Metrics, changes in Changecontroller

parent c203e528
No related branches found
No related tags found
No related merge requests found
package de.fhmuenster.masterthesis.Testgenerator.prioritization;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import de.fhmuenster.masterthesis.Testgenerator.rest.service.test.TestService;
import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
import de.fhmuenster.masterthesis.testgeneratorDSL.EndCheck;
import de.fhmuenster.masterthesis.testgeneratorDSL.Flow;
import de.fhmuenster.masterthesis.testgeneratorDSL.FlowElementReference;
import de.fhmuenster.masterthesis.testgeneratorDSL.MockReference;
import de.fhmuenster.masterthesis.testgeneratorDSL.Test;
import de.fhmuenster.masterthesis.testgeneratorDSL.VariableDeclaration;
import de.fhmuenster.masterthesis.testgeneratorDSL.VariableDeclarations;
public class PrioritizationMetrics {
@Autowired
private TestService testService;
public PrioritizationMetrics() {
......@@ -15,11 +28,15 @@ public class PrioritizationMetrics {
/**
* Metric 1 (m1)
*
* @author Tim Flicke, Henning Schmeink
*/
public void m1_flowAffected(List<Flow> newFlows, List<Flow> oldFlows) {
public List<Flow> m1_flowAffected(List<Flow> newFlows, List<F+low> oldFlows) {
List<Flow> affectedFlows = new ArrayList<Flow>();
try
{
// NEU SCHREIBEN! Objekte iterieren
for(int i = 0; i < newFlows.size(); i++)
{
Flow newFlow = newFlows.get(i);
......@@ -57,51 +74,128 @@ public class PrioritizationMetrics {
System.out.println("Equal");
else
{
affectedFlows.add(newFlow);
System.out.println("Not Equal");
// Specify the differences in in/excluded elements
if(!sNewWith.toString().equals(sOldWith.toString()))
{
System.out.println("Difference in [Included] Elements");
System.out.println("[NEW] Flow " + sNewWith.toString());
System.out.println("[OLD] Flow " + sOldWith.toString());
}
else if(!sNewWithout.toString().equals(sOldWithout.toString()))
{
System.out.println("Difference in [Excluded] Elements");
System.out.println("[NEW] Flow " + sNewWithout.toString());
System.out.println("[OLD] Flow " + sOldWithout.toString());
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
return affectedFlows;
}
/**
* Metric 1 (m1)
* @author Tim Flicke, Henning Schmeink
*/
public void m1_getTestsOfAffectedFlows(List<Flow> affectedFlows, TestgeneratorDSLSerializer newDSL) {
List<Test> resultList = new ArrayList<Test>();
for(Flow flow : affectedFlows) {
resultList = newDSL.getTestsForFlow(flow);
for(Test test: resultList) {
System.out.println("Priority for Test " + test.getName() + " + 1 (for Flow: " + flow.getName() + ")");
}
}
}
/**
* Metric 2 (m1)
* @author Tim Flicke, Henning Schmeink
*/
public void m2_testsAffected(TestgeneratorDSLSerializer newDSL, TestgeneratorDSLSerializer oldDSL) {
try
{
List<Test> resultNewTests = new ArrayList<Test>();
List<Test> resultOldTests = new ArrayList<Test>();
// Lists with flows
List<Flow> newFlows = newDSL.getFlows();
List<Flow> oldFlows = oldDSL.getFlows();
for(int i = 0; i < newFlows.size(); i++)
{
List<Test> newTests = newDSL.getTestsForFlow(newFlows.get(i));
List<Test> oldTests = oldDSL.getTestsForFlow(oldFlows.get(i));
//TODO
// New Tests from new DSL
for(Flow flow : newFlows) {
List<Test> tests = newDSL.getTestsForFlow(flow);
resultNewTests.addAll(tests);
}
// Old Tests from old DSL
for(Flow flow : oldFlows) {
List<Test> tests = oldDSL.getTestsForFlow(flow);
resultOldTests.addAll(tests);
}
for(Test newTest : resultNewTests) {
for(Test oldTest : resultOldTests) {
if(newTest.getName().equals(oldTest.getName()))
{
System.out.println("COMPARE TEST [NEW]" + newTest.getName() + " to [OLD] " + oldTest.getName());
// ==================================================================================================
// Compare Mocks
Collection<String> newMocks = new ArrayList<String>();
Collection<String> oldMocks = new ArrayList<String>();
for(MockReference ref : newTest.getMocks())
newMocks.add(ref.getRef().getName());
for(MockReference ref : oldTest.getMocks())
oldMocks.add(ref.getRef().getName());
// Compare size of Mocks
if(newMocks.size() != oldMocks.size())
System.out.println("Deleted/Added Mock - Change detected"); // change detected
// NewMocks contains all Mocks from old DSL
if(!newMocks.containsAll(oldMocks))
System.out.println("New DSL doesnt contains all mocks from old DSL"); // change detected
// ==================================================================================================
// Compare Checks
Collection<String> newChecks = new ArrayList<String>();
Collection<String> oldChecks = new ArrayList<String>();
for(EndCheck ref : newTest.getEndCheck().getEndChecks())
System.out.println(ref); // Nur Value brauchen den Key
// ==================================================================================================
// Compare Variables
Collection<String> newVar = new ArrayList<String>();
Collection<String> oldVar = new ArrayList<String>();
for(VariableDeclarations ref : newTest.getDeclarations())
{
System.out.println(ref);
for(VariableDeclaration var : ref.getVariables())
{
System.out.println(var);
}
}
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
}
package de.fhmuenster.masterthesis.Testgenerator.prioritization;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import de.fhmuenster.masterthesis.Testgenerator.rest.mapper.ObjectMapper;
import de.fhmuenster.masterthesis.Testgenerator.rest.service.flow.FlowService;
import de.fhmuenster.masterthesis.Testgenerator.rest.service.project.ProjectService;
import de.fhmuenster.masterthesis.Testgenerator.rest.service.test.TestService;
import de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer;
import de.fhmuenster.masterthesis.testgeneratorDSL.Flow;
import de.fhmuenster.masterthesis.testgeneratorDSL.Test;
public class PrioritizationService {
......@@ -33,11 +38,18 @@ public class PrioritizationService {
public void prioritize() {
// Affected Flows
List<Flow> affectedFlows = new ArrayList<Flow>();
List<Test> affectedTests = new ArrayList<Test>();
// compare old and new flows
this.metrics.m1_flowAffected(newDSL.getFlows(), oldDSL.getFlows());
affectedFlows = this.metrics.m1_flowAffected(newDSL.getFlows(), oldDSL.getFlows());
this.metrics.m1_getTestsOfAffectedFlows(affectedFlows, newDSL);
// compare old and new tests
this.metrics.m2_testsAffected(newDSL, oldDSL);
//testService.get
}
}
......@@ -277,7 +277,6 @@ public class ChangeController {
// PrioritizationService erzeugen anhand der alten und neuen DSL
PrioritizationService prioritizationService = new PrioritizationService(oldDSL, newDSL);
prioritizationService.prioritize();
}
catch (Exception e) {
e.printStackTrace();
......
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