Permalink
Browse files

ADD: Programatically add multiple genrators and stop condition to Mod…

…ealAPI
  • Loading branch information...
1 parent f9dba11 commit 1f42576a39b95596fcc551e12eddab00872635e3 @KristianKarl committed Jun 10, 2012
@@ -4,6 +4,7 @@
import org.graphwalker.ModelBasedTesting;
import org.graphwalker.generators.PathGenerator;
+import org.graphwalker.generators.RandomPathGenerator;
/**
* @author krikar Any test should extend this class.
@@ -27,11 +28,28 @@ public ModelAPI(File model, boolean efsm, PathGenerator generator, boolean weigh
mbt.setWeighted(weight);
}
+ public ModelAPI(String model) {
+ mbt = new ModelBasedTesting();
+ mbt.readGraph(model);
+ }
+
public void setMbt(ModelBasedTesting mbt) {
this.mbt = mbt;
}
public ModelBasedTesting getMbt() {
return mbt;
}
+
+ public void setWeighted(boolean weight) {
+ mbt.setWeighted(weight);
+ }
+
+ public void setExtended(boolean efsm) {
+ mbt.enableExtended(efsm);
+ }
+
+ public void setGenerator(PathGenerator pathGenerator) {
+ mbt.setGenerator(pathGenerator);
+ }
}
@@ -0,0 +1,40 @@
+package org.graphwalker.multipleModels;
+
+import junit.framework.Assert;
+
+import org.graphwalker.conditions.AlternativeCondition;
+import org.graphwalker.conditions.CombinationalCondition;
+import org.graphwalker.conditions.EdgeCoverage;
+import org.graphwalker.conditions.ReachedVertex;
+import org.graphwalker.conditions.RequirementCoverage;
+import org.graphwalker.conditions.TimeDuration;
+import org.graphwalker.exceptions.StopConditionException;
+import org.graphwalker.generators.A_StarPathGenerator;
+import org.graphwalker.generators.CombinedPathGenerator;
+import org.graphwalker.generators.RandomPathGenerator;
+import org.junit.Test;
+
+public class ModelAPITest {
+
+ @Test
+ public void addMultipleGenerators() throws StopConditionException {
+ ModelAPI model = new ModelAPI("graphml/org.graphwalker.multipleModels/a.graphml");
+ model.setWeighted(false);
+ model.setExtended(true);
+
+ CombinationalCondition combinationalCondition = new CombinationalCondition();
+ combinationalCondition.add(new RequirementCoverage(1.0));
+ combinationalCondition.add(new EdgeCoverage(1.0));
+
+ AlternativeCondition alternativeCondition = new AlternativeCondition();
+ alternativeCondition.add(combinationalCondition);
+ alternativeCondition.add(new TimeDuration(900));
+
+ CombinedPathGenerator generator = new CombinedPathGenerator();
+ generator.addPathGenerator(new A_StarPathGenerator(new ReachedVertex("C")));
+ generator.addPathGenerator(new RandomPathGenerator(alternativeCondition));
+
+ model.setGenerator(generator);
+ Assert.assertTrue("Failed setting up the model", model.getMbt().hasNextStep());
+ }
+}
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd">
+ <!--Created by yFiles for Java 2.7-->
+ <key for="graphml" id="d0" yfiles.type="resources"/>
+ <key attr.name="url" attr.type="string" for="node" id="d1"/>
+ <key attr.name="description" attr.type="string" for="node" id="d2"/>
+ <key for="node" id="d3" yfiles.type="nodegraphics"/>
+ <key attr.name="url" attr.type="string" for="edge" id="d4"/>
+ <key attr.name="description" attr.type="string" for="edge" id="d5"/>
+ <key for="edge" id="d6" yfiles.type="edgegraphics"/>
+ <graph edgedefault="directed" id="G">
+ <node id="n0">
+ <data key="d2"/>
+ <data key="d3">
+ <y:ShapeNode>
+ <y:Geometry height="30.0" width="45.75732421875" x="0.0" y="-92.18809523809524"/>
+ <y:Fill color="#00FF00" transparent="false"/>
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="19.1328125" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="35.75732421875" x="5.0" y="5.43359375">Start</y:NodeLabel>
+ <y:Shape type="rectangle"/>
+ </y:ShapeNode>
+ </data>
+ </node>
+ <node id="n1">
+ <data key="d2"/>
+ <data key="d3">
+ <y:ShapeNode>
+ <y:Geometry height="30.0" width="22.89306640625" x="118.28759765625" y="-88.43809523809524"/>
+ <y:Fill color="#FFCC00" transparent="false"/>
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="19.1328125" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="12.89306640625" x="5.0" y="5.43359375">A</y:NodeLabel>
+ <y:Shape type="roundrectangle"/>
+ </y:ShapeNode>
+ </data>
+ </node>
+ <node id="n2">
+ <data key="d2"/>
+ <data key="d3">
+ <y:ShapeNode>
+ <y:Geometry height="30.0" width="22.91845703125" x="197.7978515625" y="-95.93809523809524"/>
+ <y:Fill color="#FFCC00" transparent="false"/>
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="19.1328125" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="12.91845703125" x="5.0" y="5.43359375">B</y:NodeLabel>
+ <y:Shape type="roundrectangle"/>
+ </y:ShapeNode>
+ </data>
+ </node>
+ <node id="n3">
+ <data key="d2"/>
+ <data key="d3">
+ <y:ShapeNode>
+ <y:Geometry height="30.0" width="23.0771484375" x="291.31396484375" y="-64.45357142857142"/>
+ <y:Fill color="#FFCC00" transparent="false"/>
+ <y:BorderStyle color="#000000" type="line" width="1.0"/>
+ <y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="13" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="19.1328125" modelName="internal" modelPosition="c" textColor="#000000" visible="true" width="13.0771484375" x="5.0" y="5.43359375">C</y:NodeLabel>
+ <y:Shape type="roundrectangle"/>
+ </y:ShapeNode>
+ </data>
+ </node>
+ <edge id="e0" source="n1" target="n1">
+ <data key="d5"/>
+ <data key="d6">
+ <y:PolyLineEdge>
+ <y:Path sx="-11.446533203125" sy="11.25" tx="0.0" ty="15.0">
+ <y:Point x="102.11083984375" y="-62.188095238095244"/>
+ <y:Point x="102.11083984375" y="-24.219345238095244"/>
+ <y:Point x="129.734130859375" y="-24.219345238095244"/>
+ </y:Path>
+ <y:LineStyle color="#000000" type="line" width="1.0"/>
+ <y:Arrows source="none" target="standard"/>
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="free" modelPosition="anywhere" preferredPlacement="on_edge" ratio="0.5" textColor="#000000" visible="true" width="11.353515625" x="-21.853515625" y="9.999999854678201">a</y:EdgeLabel>
+ <y:BendStyle smoothed="false"/>
+ </y:PolyLineEdge>
+ </data>
+ </edge>
+ <edge id="e1" source="n1" target="n2">
+ <data key="d5"/>
+ <data key="d6">
+ <y:PolyLineEdge>
+ <y:Path sx="11.446533203125" sy="-7.5" tx="-11.459228515625" ty="-0.0"/>
+ <y:LineStyle color="#000000" type="line" width="1.0"/>
+ <y:Arrows source="none" target="standard"/>
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="free" modelPosition="anywhere" preferredPlacement="on_edge" ratio="0.5" textColor="#000000" visible="true" width="11.6171875" x="30.0" y="-8.984375145321806">b</y:EdgeLabel>
+ <y:BendStyle smoothed="false"/>
+ </y:PolyLineEdge>
+ </data>
+ </edge>
+ <edge id="e2" source="n0" target="n1">
+ <data key="d5"/>
+ <data key="d6">
+ <y:PolyLineEdge>
+ <y:Path sx="22.878662109375" sy="-0.0" tx="-11.446533203125" ty="-3.75"/>
+ <y:LineStyle color="#000000" type="line" width="1.0"/>
+ <y:Arrows source="none" target="standard"/>
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="free" modelPosition="anywhere" preferredPlacement="on_edge" ratio="0.5" textColor="#000000" visible="true" width="11.353515625" x="15.0" y="-8.984375145321806">a</y:EdgeLabel>
+ <y:BendStyle smoothed="false"/>
+ </y:PolyLineEdge>
+ </data>
+ </edge>
+ <edge id="e3" source="n2" target="n1">
+ <data key="d5"/>
+ <data key="d6">
+ <y:PolyLineEdge>
+ <y:Path sx="11.459228515625" sy="-7.5" tx="-11.446533203125" ty="-11.25">
+ <y:Point x="235.71630859375" y="-88.43809523809524"/>
+ <y:Point x="235.71630859375" y="-110.93809523809524"/>
+ <y:Point x="103.28759765625" y="-110.93809523809524"/>
+ <y:Point x="103.28759765625" y="-84.68809523809524"/>
+ </y:Path>
+ <y:LineStyle color="#000000" type="line" width="1.0"/>
+ <y:Arrows source="none" target="standard"/>
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="4.0" modelName="free" modelPosition="anywhere" preferredPlacement="on_edge" ratio="0.5" textColor="#000000" visible="true" width="4.0" x="-45.72705078125" y="-24.50000014532182"/>
+ <y:BendStyle smoothed="false"/>
+ </y:PolyLineEdge>
+ </data>
+ </edge>
+ <edge id="e4" source="n1" target="n3">
+ <data key="d5"/>
+ <data key="d6">
+ <y:PolyLineEdge>
+ <y:Path sx="11.446533203125" sy="7.5" tx="-11.53857421875" ty="7.5">
+ <y:Point x="156.1806640625" y="-65.93809523809524"/>
+ <y:Point x="156.1806640625" y="-41.95357142857143"/>
+ </y:Path>
+ <y:LineStyle color="#000000" type="line" width="1.0"/>
+ <y:Arrows source="none" target="standard"/>
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="free" modelPosition="anywhere" preferredPlacement="on_edge" ratio="0.5" textColor="#000000" visible="true" width="10.59765625" x="62.777587890625" y="15.000148664202015">c</y:EdgeLabel>
+ <y:BendStyle smoothed="false"/>
+ </y:PolyLineEdge>
+ </data>
+ </edge>
+ <edge id="e5" source="n2" target="n3">
+ <data key="d5"/>
+ <data key="d6">
+ <y:PolyLineEdge>
+ <y:Path sx="11.459228515625" sy="7.5" tx="-11.53857421875" ty="-7.5">
+ <y:Point x="276.31396484375" y="-73.43809523809524"/>
+ <y:Point x="276.31396484375" y="-56.95357142857143"/>
+ </y:Path>
+ <y:LineStyle color="#000000" type="line" width="1.0"/>
+ <y:Arrows source="none" target="standard"/>
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="free" modelPosition="anywhere" preferredPlacement="on_edge" ratio="0.5" textColor="#000000" visible="true" width="10.59765625" x="30.0" y="-8.984375145321806">c</y:EdgeLabel>
+ <y:BendStyle smoothed="false"/>
+ </y:PolyLineEdge>
+ </data>
+ </edge>
+ <edge id="e6" source="n3" target="n1">
+ <data key="d6">
+ <y:PolyLineEdge>
+ <y:Path sx="11.53857421875" sy="-0.0" tx="-11.446533203125" ty="3.75">
+ <y:Point x="329.39111328125" y="-49.45357142857143"/>
+ <y:Point x="329.39111328125" y="-8.98452380952381"/>
+ <y:Point x="87.11083984375" y="-8.98452380952381"/>
+ <y:Point x="87.11083984375" y="-69.68809523809524"/>
+ </y:Path>
+ <y:LineStyle color="#000000" type="line" width="1.0"/>
+ <y:Arrows source="none" target="standard"/>
+ <y:EdgeLabel alignment="center" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="17.96875" modelName="free" modelPosition="anywhere" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="11.353515625" x="-110.810791015625" y="31.484672510056257">a</y:EdgeLabel>
+ <y:BendStyle smoothed="false"/>
+ </y:PolyLineEdge>
+ </data>
+ </edge>
+ </graph>
+ <data key="d0">
+ <y:Resources/>
+ </data>
+</graphml>

0 comments on commit 1f42576

Please sign in to comment.