Skip to content

Commit

Permalink
Merge pull request #16 from pinetree408/mergefilterui
Browse files Browse the repository at this point in the history
Mergefilterui
  • Loading branch information
pinetree408 committed Jun 1, 2016
2 parents d321a3f + 48e894c commit 73d9ce9
Show file tree
Hide file tree
Showing 3 changed files with 378 additions and 190 deletions.
128 changes: 89 additions & 39 deletions VFT/src/vft/views/VFTGraph.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package vft.views;

import org.jgrapht.ListenableGraph;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.ListenableDirectedGraph;

import java.util.ArrayList;
Expand All @@ -10,19 +9,21 @@

public class VFTGraph {

public static ListenableGraph<String, DefaultEdge> init()
public static ListenableGraph<String, String> init(int filteringRule, ArrayList<String> options)
{
// create a JGraphT graph
ListenableGraph<String, DefaultEdge> g =
new ListenableDirectedGraph<String, DefaultEdge>(
DefaultEdge.class);
ListenableGraph<String, String> g =
new ListenableDirectedGraph<String, String>(
String.class);
ArrayList<GraphNode> graphNode = new ArrayList<GraphNode>();
ArrayList<String> componentList;

String v1 = "v1";
String v2 = "v2";
String v3 = "v3";
String v4 = "v4";
/*
String vertex = String.valueOf(option);
String v1 = vertex;
String v2 = vertex + "1";
String v3 = vertex + "2";
String v4 = vertex + "3";
// add some sample data (graph manipulated via JGraphX)
g.addVertex(v1);
Expand All @@ -34,14 +35,16 @@ public static ListenableGraph<String, DefaultEdge> init()
g.addEdge(v2, v3);
g.addEdge(v3, v1);
g.addEdge(v4, v3);

*/

/////////////////////////////////////////
long start = System.currentTimeMillis();

FilterWrapper Filter = new FilterWrapper();
int i;
String tmpList;
Filter.prePareLogData();

// 1st step : set filter rule and get list
componentList = Filter.setFilterRule(Filter.INTER_COMPONENT_FILTER);
for(i = 0; i < componentList.size(); i++) {
Expand All @@ -67,39 +70,86 @@ public static ListenableGraph<String, DefaultEdge> init()
System.out.println("VFTGraph : Test Method list " + tmpList);
}


// 2nd step : select package or file or test case
Filter.selectComponent(Filter.INTER_COMPONENT_FILTER, "Atm", "Simulation");
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface between Atm <-> Simulation #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}

Filter.selectComponent(Filter.FILE_FILTER, "Simulation.java", null);
graphNode = Filter.getGraphNode();
// 2nd step : select package or file or test case
if (filteringRule == Filter.INTER_COMPONENT_FILTER) {

Filter.selectComponent(Filter.INTER_COMPONENT_FILTER, options.get(0), options.get(1));
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface between Atm <-> Simulation #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}

} else if (filteringRule == Filter.FILE_FILTER) {

Filter.selectComponent(Filter.FILE_FILTER, options.get(0), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface with this file #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}

} else if (filteringRule == Filter.TEST_CASE_FILTER) {

Filter.selectComponent(Filter.TEST_CASE_FILTER, options.get(0), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### call graph involved with this test case #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}
} else if (filteringRule == Filter.TEST_METHOD_FILTER) {

Filter.selectComponent(Filter.TEST_METHOD_FILTER, options.get(0), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### call graph involved with this test method #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}

} else {

String vertex = String.valueOf(filteringRule);
String v1 = vertex;
String v2 = vertex + "1";
String v3 = vertex + "2";
String v4 = vertex + "3";

System.out.println("VFTGraph : ##### Interface with this file #####");
gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}

Filter.selectComponent(Filter.TEST_CASE_FILTER, "testBankName", null);
graphNode = Filter.getGraphNode();
// add some sample data (graph manipulated via JGraphX)
g.addVertex(v1);
g.addVertex(v2);
g.addVertex(v3);
g.addVertex(v4);

System.out.println("VFTGraph : ##### call graph involved with this test case #####");
gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
g.addEdge(v1, v2);
g.addEdge(v2, v3);
g.addEdge(v3, v1);
g.addEdge(v4, v3);
}


long end = System.currentTimeMillis();
System.out.println("VFTGraph : Filter (ms) " + (end - start));

Expand Down
119 changes: 117 additions & 2 deletions VFT/src/vft/views/VFTTree.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,142 @@
package vft.views;

import java.util.ArrayList;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;

import vft.filter.FilterWrapper;
import vft.filter.Filter.GraphNode;

public class VFTTree {

public static JTree init()
public static JTree init(int filteringRule, ArrayList<String> options)
{
JTree tree;

/*
//create the root node
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
//create the child nodes
DefaultMutableTreeNode vegetableNode = new DefaultMutableTreeNode("Vegetables");
DefaultMutableTreeNode fruitNode = new DefaultMutableTreeNode("Fruits");
//add the child nodes to the root node
root.add(vegetableNode);
root.add(fruitNode);
//create the tree by passing in the root node
tree = new JTree(root);
*/

DefaultMutableTreeNode root;
DefaultMutableTreeNode caller;
DefaultMutableTreeNode functionName;
DefaultMutableTreeNode callee;

ArrayList<GraphNode> graphNode = new ArrayList<GraphNode>();
ArrayList<String> componentList;
FilterWrapper Filter = new FilterWrapper();
int i;
String tmpList;
Filter.prePareLogData();

// 2nd step : select package or file or test case
if (filteringRule == Filter.INTER_COMPONENT_FILTER) {

root = new DefaultMutableTreeNode("INTER_COMPONENT_FILTER");

Filter.selectComponent(Filter.INTER_COMPONENT_FILTER, options.get(0), options.get(1));
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface between Atm <-> Simulation #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
caller = new DefaultMutableTreeNode(gNodeToDebug.caller);
callee = new DefaultMutableTreeNode(gNodeToDebug.callee);
functionName = new DefaultMutableTreeNode(gNodeToDebug.functionName);
functionName.add(callee);
caller.add(functionName);
root.add(caller);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}

} else if (filteringRule == Filter.FILE_FILTER) {

root = new DefaultMutableTreeNode("FILE_FILTER");

Filter.selectComponent(Filter.FILE_FILTER, options.get(0), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface with this file #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
caller = new DefaultMutableTreeNode(gNodeToDebug.caller);
callee = new DefaultMutableTreeNode(gNodeToDebug.callee);
functionName = new DefaultMutableTreeNode(gNodeToDebug.functionName);
functionName.add(callee);
caller.add(functionName);
root.add(caller);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}

} else if (filteringRule == Filter.TEST_CASE_FILTER) {

root = new DefaultMutableTreeNode("TEST_CASE_FILTER");

Filter.selectComponent(Filter.TEST_CASE_FILTER, options.get(0), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### call graph involved with this test case #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
caller = new DefaultMutableTreeNode(gNodeToDebug.caller);
callee = new DefaultMutableTreeNode(gNodeToDebug.callee);
functionName = new DefaultMutableTreeNode(gNodeToDebug.functionName);
functionName.add(callee);
caller.add(functionName);
root.add(caller);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}
} else if (filteringRule == Filter.TEST_METHOD_FILTER) {

root = new DefaultMutableTreeNode("TEST_METHOD_FILTER");

Filter.selectComponent(Filter.TEST_METHOD_FILTER, options.get(0), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### call graph involved with this test method #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
caller = new DefaultMutableTreeNode(gNodeToDebug.caller);
callee = new DefaultMutableTreeNode(gNodeToDebug.callee);
functionName = new DefaultMutableTreeNode(gNodeToDebug.functionName);
functionName.add(callee);
caller.add(functionName);
root.add(caller);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}

} else {

//create the root node
root = new DefaultMutableTreeNode("Root");
//create the child nodes
DefaultMutableTreeNode vegetableNode = new DefaultMutableTreeNode("Vegetables");
DefaultMutableTreeNode fruitNode = new DefaultMutableTreeNode("Fruits");

//add the child nodes to the root node
root.add(vegetableNode);
root.add(fruitNode);
//create the tree by passing in the root node

}

tree = new JTree(root);
return tree;

}
Expand Down
Loading

0 comments on commit 73d9ce9

Please sign in to comment.