-
Notifications
You must be signed in to change notification settings - Fork 116
Convert
Kristian Karl edited this page Mar 4, 2021
·
10 revisions
Convert a graph in file format to some other format.
Options
-
--input
,-i
This command requires an input file.
-
--format
,-f
Which format to convert into. Valid key words are: JSON (default), GRAPHML, DOT or JAVA.
Default is JSON. -
--blocked
,-b
This option enables or disables the BLOCKED feature. When
-b true
GraphWalker will filter out elements in models with the keyword BLOCKED. When-b false
GraphWalker will not filter out any elements in models with the keyword BLOCKED.
Default is true.
Example:
$> java - jar graphwalker-cli-4.3.1.jar convert -i Login.graphml
import org.graphwalker.core.condition.*;
import org.graphwalker.core.generator.*;
import org.graphwalker.core.machine.*;
import org.graphwalker.core.model.*;
public class login {
public final class ModelTestContext extends ExecutionContext {
}
public static void main(String... aArgs) {
login modeltest = new login();
modeltest.run();
}
private void run() {
Vertex v_ClientNotRunning = new Vertex().setName("v_ClientNotRunning").setId("n0");
Vertex v_LoginPrompted = new Vertex().setName("v_LoginPrompted").setId("n1");
Vertex v_Browse = new Vertex().setName("v_Browse").setId("n2");
Model model = new Model();
model.addEdge( new Edge().setTargetVertex(v_ClientNotRunning).setName("e_Init").setId("e0").addAction(new Action("rememberMe=false;")).addAction(new Action("validLogin=false;")));
model.addEdge( new Edge().setSourceVertex(v_ClientNotRunning).setTargetVertex(v_LoginPrompted).setName("e_StartClient").setId("e1").setGuard(new Guard("!rememberMe||!validLogin")));
model.addEdge( new Edge().setSourceVertex(v_LoginPrompted).setTargetVertex(v_Browse).setName("e_ValidPremiumCredentials").setId("e2").addAction(new Action("validLogin=true;")));
model.addEdge( new Edge().setSourceVertex(v_Browse).setTargetVertex(v_LoginPrompted).setName("e_Logout").setId("e3"));
model.addEdge( new Edge().setSourceVertex(v_Browse).setTargetVertex(v_ClientNotRunning).setName("e_Exit").setId("e4"));
model.addEdge( new Edge().setSourceVertex(v_LoginPrompted).setTargetVertex(v_LoginPrompted).setName("e_ToggleRememberMe").setId("e5").addAction(new Action("rememberMe=!rememberMe;")));
model.addEdge( new Edge().setSourceVertex(v_LoginPrompted).setTargetVertex(v_ClientNotRunning).setName("e_Close").setId("e6"));
model.addEdge( new Edge().setSourceVertex(v_ClientNotRunning).setTargetVertex(v_Browse).setName("e_StartClient").setId("e7").setGuard(new Guard("rememberMe&&validLogin")));
model.addEdge( new Edge().setSourceVertex(v_LoginPrompted).setTargetVertex(v_LoginPrompted).setName("e_InvalidCredentials").setId("e8").addAction(new Action("validLogin=false;")));
Context context = new ModelTestContext();
context.setModel(model.build()).setPathGenerator(new RandomPath(new EdgeCoverage(100)));
context.setNextElement(context.getModel().findElements("e_Init").get(0));
Machine machine = new SimpleMachine(context);
while (machine.hasNextStep()) {
machine.getNextStep();
System.out.println(context.getCurrentElement().getName());
}
}
}
Example:
$> java - jar graphwalker-cli-4.3.1.jar convert -i Login.graphml -f json
{"models":[{"name":"Login","id":"6a4aab5f-df1e-451b-a35e-f331234845c0","startElementId":"e0","vertices":[{"id":"n1","name":"v_ClientNotRunning","properties":{"x":1123.2486275337837,"description":"Start the client process","y":257.184751203258}},{"id":"n2","name":"v_LoginPrompted","properties":{"x":1083.8359375,"description":"The user shall be prompted for user credentials","y":376.184751203258}},{"id":"n3","name":"v_Browse","properties":{"x":1102.4111328125,"description":"A successful login is expected.\nThe user is presented with the initial view of the client.","y":514.184751203258}}],"edges":[{"id":"e0","name":"e_Init","actions":["rememberMe\u003dfalse;","validLogin\u003dtrue;"],"properties":{"description":"Remove all cache and user settings from file system."},"dependency":0,"targetVertexId":"n1"},{"id":"e1","name":"e_StartClient","guard":"!rememberMe||!validLogin","dependency":0,"sourceVertexId":"n1","targetVertexId":"n2"},{"id":"e2","name":"e_ValidPremiumCredentials","actions":["validLogin\u003dtrue;"],"properties":{"description":"Log in as Premium user, using valid credentials"},"dependency":0,"sourceVertexId":"n2","targetVertexId":"n3"},{"id":"e3","name":"e_Logout","properties":{"description":"Logout current user from client"},"dependency":0,"sourceVertexId":"n3","targetVertexId":"n2"},{"id":"e4","name":"e_Exit","properties":{"description":"Exit and shutdown the client process"},"dependency":0,"sourceVertexId":"n3","targetVertexId":"n1"},{"id":"e5","name":"e_ToggleRememberMe","actions":["rememberMe\u003d!rememberMe;"],"dependency":0,"sourceVertexId":"n2","targetVertexId":"n2"},{"id":"e6","name":"e_Close","dependency":0,"sourceVertexId":"n2","targetVertexId":"n1"},{"id":"e7","name":"e_StartClient","guard":"rememberMe\u0026\u0026validLogin","dependency":0,"sourceVertexId":"n1","targetVertexId":"n3"},{"id":"e8","name":"e_InvalidCredentials","actions":["valdiLogin\u003dfalse;"],"dependency":0,"sourceVertexId":"n2","targetVertexId":"n2"}]}]}