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

Deleted...

Deleted Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/prioritization/PrioritizationMetrics.java
parent d8b59888
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() {
}
/**
* Metric 1 (m1)
* @author Tim Flicke, Henning Schmeink
*/
public List<Flow> m1_flowAffected(List<Flow> newFlows, List<Flow> 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);
Flow oldFlow = oldFlows.get(i);
StringBuilder sNewWith = new StringBuilder();
StringBuilder sOldWith = new StringBuilder();
StringBuilder sNewWithout = new StringBuilder();
StringBuilder sOldWithout = new StringBuilder();
// Building strings to compare the elements of each flow
// with Elements = [..]
for(FlowElementReference newRefWith : newFlow.getInclElements())
sNewWith.append(newRefWith.getRef().getName()).append(", ");
for(FlowElementReference oldRefWith : oldFlow.getInclElements())
sOldWith.append(oldRefWith.getRef().getName()).append(", ");
// without Elements = [..]
for(FlowElementReference newRefWithout : newFlow.getExclElements())
sNewWithout.append(newRefWithout.getRef().getName()).append(", ");
for(FlowElementReference oldRefWithout : oldFlow.getExclElements())
sOldWithout.append(oldRefWithout.getRef().getName()).append(", ");
// Console output
System.out.println("=========================================");
System.out.println("++ Comparing [NEW] Flow " + newFlow.getName() + " with [OLD] Flow " + oldFlow.getName() + " ++");
// Included and excluded elements are the same
if(sNewWith.toString().equals(sOldWith.toString()) && sNewWithout.toString().equals(sOldWithout.toString()))
System.out.println("Equal");
else
{
affectedFlows.add(newFlow);
System.out.println("Not Equal");
}
}
}
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();
// 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();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment