### Start Android Emulator Source: https://github.com/graphwalker/graphwalker-project/wiki/Appium Launch an Android emulator instance from the command line. This example starts a Nexus 5X API 23 emulator. ```bash emulator -avd Nexus_5X_API_23 ``` -------------------------------- ### Install Appium on Ubuntu Source: https://github.com/graphwalker/graphwalker-project/wiki/Appium Install Appium globally using npm on Ubuntu systems. Ensure Node.js is installed first. ```bash sudo apt install nodejs-legacy sudo npm install -g appium ``` -------------------------------- ### start Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Loads models into the session and starts path generation. This command must be called before any other commands. ```APIDOC ## start ### Description Loads models into the session and starts path generation. Must be called before other commands. ### Command `start` ### Request Body - **command** (string) - Required - The command name, should be "start". - **gw_model** (object) - Required - The model definition. - **models** (array) - Required - A list of models to load. - **name** (string) - Required - The name of the model. - **generator** (string) - Required - The path generator to use (e.g., "random(edge_coverage(100))"). - **startElementId** (string) - Required - The ID of the starting element. - **vertices** (array) - Required - A list of vertices in the model. - **id** (string) - Required - The unique identifier for the vertex. - **name** (string) - Required - The name of the vertex. - **edges** (array) - Required - A list of edges in the model. - **id** (string) - Required - The unique identifier for the edge. - **name** (string) - Required - The name of the edge. - **targetVertexId** (string) - Required - The ID of the target vertex. - **sourceVertexId** (string) - Optional - The ID of the source vertex. ### Response #### Success Response (200) - **result** (string) - Indicates the success of the operation, typically "ok". ### Request Example ```json { "command": "start", "gw_model": { "models": [ { "name": "Login", "generator": "random(edge_coverage(100))", "startElementId": "e0", "vertices": [ { "id": "n0", "name": "v_ClientNotRunning" }, { "id": "n1", "name": "v_LoginPrompted" }, { "id": "n2", "name": "v_Browse" } ], "edges": [ { "id": "e0", "name": "e_Init", "targetVertexId": "n0" }, { "id": "e1", "name": "e_StartClient", "sourceVertexId": "n0", "targetVertexId": "n1" }, { "id": "e2", "name": "e_ValidPremiumCredentials", "sourceVertexId": "n1", "targetVertexId": "n2" } ] } ] } } ``` ### Response Example ```json { "result": "ok" } ``` ``` -------------------------------- ### Maven Build Output Example Source: https://github.com/graphwalker/graphwalker-project/wiki/Maven---generate-sources-for-tests Example output from running the `graphwalker:generate-test-sources` goal, showing a successful build. ```log [INFO] Scanning for projects... [INFO] [INFO] --------------< org.graphwalker.example:java-prestashop >--------------- [INFO] Building GraphWalker PrestaShop Example 4.3.1 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- graphwalker-maven-plugin:4.3.1:generate-test-sources (default-cli) @ java-prestashop --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.741 s [INFO] Finished at: 2019-09-28T11:38:48+02:00 [INFO] ------------------------------------------------------------------------ ``` -------------------------------- ### Start Command Source: https://github.com/graphwalker/graphwalker-project/wiki/Websocket:-start The 'start' command loads one or more GraphWalker models and starts the service. The model must be in JSON notation. ```APIDOC ## Start Command ### Description Loads model(s) and starts the GraphWalker service. The model must use JSON notation. ### Request Body ```json { "command": "start", "gw3": { "name": "A small test model", "models": [ { "name": "Small model", "generator": "random(edge_coverage(100))", "startElementId": "e0", "vertices": [ { "name": "v_VerifySomeAction", "id": "n0" }, { "name": "v_VerifySomeOtherAction", "id": "n1" } ], "edges": [ { "name": "e_FirstAction", "id": "e0", "targetVertexId": "n0" }, { "name": "e_AnotherAction", "id": "e1", "sourceVertexId": "n0", "targetVertexId": "n1" }, { "name": "e_SomeOtherAction", "id": "e2", "sourceVertexId": "n1", "targetVertexId": "n1" }, { "name": "e_SomeOtherAction", "id": "e3", "sourceVertexId": "n1", "targetVertexId": "n0" } ] } ] } } ``` ### Response #### Success Response - **success** (boolean) - Indicates if the command was successful. - **msg** (string) - A message providing details, especially if `success` is false. ```json { "command": "start", "success": boolean, "msg": "If success is false, a message will be returned" } ``` ``` -------------------------------- ### Python Template Example Source: https://github.com/graphwalker/graphwalker-project/wiki/Source This Python template includes setup instructions, defines a basic function structure using the {LABEL} parameter, and provides a FOOTER section for GraphWalker interaction. ```python HEADER<{{ import requests,json ## ## 1) Generate python stub source code: ## java -jar graphwalker-4.3.1-jar source -i model.graphml python.template > model.py ## ## 2) Start graphwalker: ## java -jar graphwalker-4.3.1.jar online --service RESTFUL -m model.graphml "random(edge_coverage(100))" ## ## 3) Run the python program: ## python model.py ## }}> def {LABEL}() : print( "{LABEL}" ) return FOOTER<{{ gw_url = 'http://localhost:8887/graphwalker' while requests.get(gw_url+' பகிர்hasNext').json()['hasNext'] == 'true' : # Get next step from GraphWalker step = requests.get(gw_url+'/getNext').json()['currentElementName'] if step != '' : eval( step + "()" ) }}> ``` -------------------------------- ### Start GraphWalker Studio Source: https://github.com/graphwalker/graphwalker-project/wiki/Create-a-model-using-GraphWalker-Studio Run this command in your terminal to start the GraphWalker Studio application after downloading the JAR file. ```console java - jar graphwalker-studio-4.3.1.jar ``` -------------------------------- ### Clone and Run Example Project Source: https://github.com/graphwalker/graphwalker-project/wiki/Appium Clone the GraphWalker example project from GitHub, navigate into the Java Appium directory, and run the tests using Maven. ```bash git clone https://github.com/GraphWalker/graphwalker-example.git cd graphwalker-example/java-appium mvn graphwalker:test ``` -------------------------------- ### Edge Initialization Example Source: https://github.com/graphwalker/graphwalker-project/wiki/Creating-a-model-using-yEd This example shows an edge named 'e_Init' with action code to initialize 'validLogin' and 'rememberMe' attributes to false. ```plaintext e_Init/validLogin=false;rememberMe=false; ``` -------------------------------- ### Clone GraphWalker C# Example Source: https://github.com/graphwalker/graphwalker-project/wiki/C Clone the GraphWalker example repository and navigate to the C# PetClinic test directory. ```bash git clone https://github.com/GraphWalker/graphwalker-example.git cd graphwalker-example/c-sharp-rest/PetClinic/ ``` -------------------------------- ### Create and Start Websocket Server Source: https://github.com/graphwalker/graphwalker-project/wiki/GraphWalker-Player This Java code sets up a GraphWalker test executor and starts a Websocket server to communicate test progress. Ensure the port (8887 in this example) is available. ```java public static void main(String[] args) throws IOException, InterruptedException { Executor executor = new TestExecutor(PetClinic.class, FindOwners.class, NewOwner.class, OwnerInformation.class, Veterinariens.class); WebSocketServer server = new WebSocketServer(8887, executor.getMachine()); server.start(); Result result = executor.execute(true); result.getErrors().forEach(System.out::println); System.out.println("Done: [" + result.getResults().toString(2) + "]"); } ``` -------------------------------- ### Clone C# Example Source Code Source: https://github.com/graphwalker/graphwalker-project/wiki/C Clone the GraphWalker C# Websocket example project from GitHub. ```console git clone https://github.com/GraphWalker/graphwalker-example.git cd graphwalker-example/c-sharp-websocket/SmallModel ``` -------------------------------- ### Clone GraphWalker C# Example Source: https://github.com/graphwalker/graphwalker-project/wiki/C Clone the C# example project from the GraphWalker GitHub repository. ```console git clone https://github.com/GraphWalker/graphwalker-example.git cd graphwalker-example/c-sharp-rest/SmallModel ``` -------------------------------- ### Perl Template Example Source: https://github.com/graphwalker/graphwalker-project/wiki/Source This Perl template provides instructions for generating and running Perl code with GraphWalker, including setup, starting GraphWalker, and running the script. It defines a subroutine for each step using the {LABEL} parameter. ```perl HEADER<{{ use strict; use warnings; ## ## 1) Generate perl stub source code: ## java -jar graphwalker-4.3.1.jar source -i model.graphml perl.template > model.perl ## ## 2) Start graphwalker: ## java -jar graphwalker-4.3.1.jar online -s RESTFUL -m model.graphml "random(edge_coverage(100))" ## ## 3) Run the perl program: ## perl login.perl http://localhost:8887/graphwalker ## use LWP::Simple; my $host = $ARGV[0]; while ( get $host."/hasNext" eq "true"){ # Get next step from GraphWalker my $step = get $host."/getNext"; if ($step ne '') { # Run the step eval( $step ) or die; } } }}> # # This sub routine implements: '{LABEL}' # sub {LABEL}() { print "{LABEL}\n"; } FOOTER<{{ #End of generated source code }}> ``` -------------------------------- ### Java API: Core Machine Example Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Demonstrates how to build a model and run it programmatically using the `SimpleMachine` and `ExecutionContext` APIs in Java. ```APIDOC ## Java API: Core Machine Direct programmatic control of model traversal using the `SimpleMachine` and `ExecutionContext` APIs from `graphwalker-core`. **Build a model and run it programmatically** ```java import org.graphwalker.core.condition.*; import org.graphwalker.core.generator.*; import org.graphwalker.core.machine.*; import org.graphwalker.core.model.*; public class ExampleTest extends ExecutionContext { // Method names must match vertex/edge names in the model exactly public void v_ClientNotRunning() { System.out.println("Assert: client not running"); } public void v_LoginPrompted() { System.out.println("Assert: login dialog visible"); } public void v_Browse() { System.out.println("Assert: browse view shown"); } public void e_Init() { System.out.println("Action: clear cache"); } public void e_StartClient() { System.out.println("Action: launch client"); } public void e_ValidPremiumCredentials() { System.out.println("Action: log in"); } public static void main(String[] args) { // Build the model Vertex vNotRunning = new Vertex().setName("v_ClientNotRunning"); Vertex vLogin = new Vertex().setName("v_LoginPrompted"); Vertex vBrowse = new Vertex().setName("v_Browse"); Model model = new Model(); model.addEdge(new Edge().setName("e_Init") .setTargetVertex(vNotRunning) .addAction(new Action("rememberMe=false; validLogin=false;"))); model.addEdge(new Edge().setName("e_StartClient") .setSourceVertex(vNotRunning).setTargetVertex(vLogin) .setGuard(new Guard("!rememberMe || !validLogin"))); model.addEdge(new Edge().setName("e_ValidPremiumCredentials") .setSourceVertex(vLogin).setTargetVertex(vBrowse) .addAction(new Action("validLogin=true;"))); // Set up execution context ExampleTest ctx = new ExampleTest(); ctx.setModel(model.build()); ctx.setPathGenerator(new RandomPath(new EdgeCoverage(100))); ctx.setNextElement(model.build().findElements("e_Init").get(0)); // Run the machine Machine machine = new SimpleMachine(ctx); while (machine.hasNextStep()) { machine.getNextStep(); } System.out.println("Done. Edge coverage: " + ctx.getEdgeCoverage()); } } ``` ``` -------------------------------- ### Start Command Response Source: https://github.com/graphwalker/graphwalker-project/wiki/Websocket:-start This is the expected response structure from the GraphWalker service after a 'start' command. 'success' will be true if the model was loaded and started successfully. ```json { "command": "start", "success": boolean, "msg": "If success is false, a message will be returned" } ``` -------------------------------- ### Clone Amazon Example Source Code Source: https://github.com/graphwalker/graphwalker-project/wiki/Amazon-Shopping-Cart Use this command to clone the GraphWalker example repository containing the Amazon shopping cart test. ```console git clone https://github.com/GraphWalker/graphwalker-example.git cd graphwalker-example/java-amazon ``` -------------------------------- ### Clone and Start PetClinic Application Source: https://github.com/graphwalker/graphwalker-project/wiki/C Clone the Spring PetClinic repository, reset to a specific commit, and start the application using Maven. ```bash git clone https://github.com/SpringSource/spring-petclinic.git cd spring-petclinic git reset --hard 482eeb1c217789b5d772f5c15c3ab7aa89caf279 mvn tomcat7:run ``` -------------------------------- ### GraphWalker REST Service Output Source: https://github.com/graphwalker/graphwalker-project/wiki/C Example output from the GraphWalker REST service indicating the start of the service and available endpoints. ```log May 02, 2016 3:02:55 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate INFO: Initiating Jersey application, version 'Jersey: 1.18.3 12/01/2014 08:23 AM' May 02, 2016 3:02:55 PM org.glassfish.grizzly.http.server.NetworkListener start INFO: Started listener bound to [0.0.0.0:8887] May 02, 2016 3:02:55 PM org.glassfish.grizzly.http.server.HttpServer start INFO: [HttpServer] Started. Try http://localhost:8887/graphwalker/hasNext or http://localhost:8887/graphwalker/getNext Press Control+C to end... ``` -------------------------------- ### Start GraphWalker Websocket Service Source: https://github.com/graphwalker/graphwalker-project/wiki/C Start the GraphWalker standalone jar as a Websocket service. Ensure you have the latest jar downloaded. ```console java -jar graphwalker-cli-4.3.1.jar -d all online ``` -------------------------------- ### Clone and Run GraphWalker PetClinic Test Example Source: https://github.com/graphwalker/graphwalker-project/wiki/PetClinic Clone the GraphWalker example repository and execute the PetClinic tests using Maven. This command initiates the automated testing process against the PetClinic application. ```bash git clone https://github.com/GraphWalker/graphwalker-example.git cd graphwalker-example/java-petclinic mvn graphwalker:test ``` -------------------------------- ### Basic GraphWalker Core Example Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-core/README.md Demonstrates creating a simple model, a path generator, and executing a test sequence using GraphWalker Core components. ```java import org.graphwalker.core.condition.VertexCoverage; import org.graphwalker.core.generator.PathGenerator; import org.graphwalker.core.generator.RandomPath; import org.graphwalker.core.machine.Context; import org.graphwalker.core.machine.ExecutionContext; import org.graphwalker.core.machine.Machine; import org.graphwalker.core.machine.SimpleMachine; import org.graphwalker.core.model.Edge; import org.graphwalker.core.model.Model; import org.graphwalker.core.model.Vertex; import org.junit.Test; public class SimpleTest { @Test public void runTestWithOnlyCore() { // create a model Vertex start = new Vertex(); Model model = new Model().addEdge(new Edge() .setSourceVertex(start) .setTargetVertex(new Vertex().setName("myTestMethod"))); // create a context based on the model and a path generator PathGenerator pathGenerator = new RandomPath(new VertexCoverage(100)); Context context = new TestContext(model, pathGenerator); // set the start vertex as our start point context.setNextElement(start); // create a machine and execute the test Machine machine = new SimpleMachine(context); while (machine.hasNextStep()) { machine.getNextStep(); } } // needs to be public, because it will be instantiated from graphwalker public class TestContext extends ExecutionContext { public TestContext(Model model, PathGenerator pathGenerator) { super(model, pathGenerator); } public void myTestMethod() { // This is executed during the model execution } } } ``` -------------------------------- ### Run Maven Build with Standard Command Source: https://github.com/graphwalker/graphwalker-project/wiki/Maven-wrapper This is the standard command to execute a Maven build if Maven is installed and configured on the system's PATH. ```bash mvn clean install ``` -------------------------------- ### Launch GraphWalker Studio Source: https://github.com/graphwalker/graphwalker-project/wiki/GraphWalker-Studio Run this command in your terminal to start the GraphWalker Studio application. Ensure you replace `` with the actual version number of the downloaded JAR file. ```bash java -jar graphwalker-studio-.jar ``` -------------------------------- ### Start GraphWalker as a REST Service Source: https://github.com/graphwalker/graphwalker-project/wiki/Dependency-Edge-Coverage-example Starts the GraphWalker command-line interface as a RESTful service. The '-d all online' flags indicate that all models should be loaded and the service should be available online. ```bash java -jar graphwalker-cli-4.3.1.jar -d all online --service RESTFUL ``` -------------------------------- ### Start GraphWalker WebSocket Service (Custom Port, No Debug) Source: https://github.com/graphwalker/graphwalker-project/wiki/Websocket-API Use this command to start the GraphWalker WebSocket service on a custom port (e.g., 9999) without any debug level enabled. ```console java -jar graphwalker-cli-4.3.1.jar online --port 9999 --service WEBSOCKET ``` -------------------------------- ### Start GraphWalker REST Service Source: https://github.com/graphwalker/graphwalker-project/wiki/C Start the GraphWalker command-line interface as a REST service. This makes the GraphWalker model accessible via HTTP endpoints. ```console cd SmallModel java -jar graphwalker-cli-4.3.1.jar -d all online -s RESTFUL -m SmallModel.graphml "random(edge_coverage(100))" ``` -------------------------------- ### Example GraphWalker Vertex JSON (PetClinic) Source: https://github.com/graphwalker/graphwalker-project/wiki/JSON-file-format:-vertex An example of a vertex definition from the PetClinic test case, illustrating the use of 'id', 'name', 'properties', and 'sharedState'. ```json { "id": "n0", "name": "v_OwnerInformation", "properties": { "x": -177.34375, "y": 35.1875 }, "sharedState": "OwnerInformation" } ``` -------------------------------- ### Start GraphWalker WebSocket Service (Default Port, Debug All) Source: https://github.com/graphwalker/graphwalker-project/wiki/Websocket-API Use this command to start the GraphWalker WebSocket service on the default port 8887 with the debug level set to ALL. ```console java -jar graphwalker-cli-4.3.1.jar --debug all online ``` -------------------------------- ### Start GraphWalker REST Service with Model and Debug Source: https://github.com/graphwalker/graphwalker-project/wiki/Rest-API-overview Starts the GraphWalker REST service on the default port with full debug, loading a specified GraphML model and using a random edge coverage strategy. ```console java -jar graphwalker-cli-4.3.1.jar -d all online -s RESTFUL -m ShoppingCart.graphml "random(edge_coverage(100))" ``` -------------------------------- ### Implementation Stub Example Source: https://context7.com/graphwalker/graphwalker-project/llms.txt A Java implementation stub for a generated GraphWalker interface, extending ExecutionContext and providing method bodies for edges and vertices. ```java package com.company; import org.graphwalker.core.machine.ExecutionContext; public class SomeSmallTest extends ExecutionContext implements SmallTest { @Override public void e_FirstAction() { System.out.println("Running: e_FirstAction"); } @Override public void e_AnotherAction() { System.out.println("Running: e_AnotherAction"); } @Override public void e_SomeAction() { System.out.println("Running: e_SomeAction"); } @Override public void e_SomeOtherAction() { System.out.println("Running: e_SomeOtherAction"); } @Override public void v_VerifyInitialState() { System.out.println("Running: v_VerifyInitialState"); } @Override public void v_VerifyFirstAction() { System.out.println("Running: v_VerifyFirstAction"); } @Override public void v_NewVertex() { System.out.println("Running: v_NewVertex"); } } ``` -------------------------------- ### Start GraphWalker Session Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Initiates a GraphWalker session by loading models. This command must be executed before any other commands. ```json // Send (client → server): { "command": "start", "gw_model": { "models": [ { "name": "Login", "generator": "random(edge_coverage(100))", "startElementId": "e0", "vertices": [ { "id": "n0", "name": "v_ClientNotRunning" }, { "id": "n1", "name": "v_LoginPrompted" }, { "id": "n2", "name": "v_Browse" } ], "edges": [ { "id": "e0", "name": "e_Init", "targetVertexId": "n0" }, { "id": "e1", "name": "e_StartClient", "sourceVertexId": "n0", "targetVertexId": "n1" }, { "id": "e2", "name": "e_ValidPremiumCredentials", "sourceVertexId": "n1", "targetVertexId": "n2" } ] } ] } } // Receive (server → client): { "result": "ok" } ``` -------------------------------- ### Run Amazon Shopping Cart Example with Docker Source: https://github.com/graphwalker/graphwalker-project/wiki/Docker-example Pulls the GraphWalker Amazon Docker image and runs it. This command sets up the necessary environment variables and volume mounts for graphical applications and network access. ```bash docker pull graphwalker/amazon docker run -ti --rm -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \ -v $HOME/.Xauthority:/home/developer/.Xauthority \ --net=host --pid=host --ipc=host graphwalker/amazon ``` -------------------------------- ### Set Data via Curl Source: https://github.com/graphwalker/graphwalker-project/wiki/Rest:-setData Example of setting data using curl from a Linux terminal. This demonstrates how to interact with the setData endpoint externally. ```console curl -X PUT http://localhost:8887/graphwalker/setData/MAX_BOOKS=6; {"result":"ok","data":{"num_of_books":"0","MAX_BOOKS":"6"}} ``` -------------------------------- ### Run GraphWalker Studio Application Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-studio/README.md Execute the GraphWalker Studio application using the Java runtime. Access the studio via http://localhost:9090/studio.html after starting. ```bash java -jar target/graphwalker-studio-4.3.2.jar ``` -------------------------------- ### Basic Offline Generation Example Source: https://github.com/graphwalker/graphwalker-project/wiki/Offline Generates a test path using the random generator until 100% edge coverage is achieved on the specified model. ```console java -jar graphwalker-cli-4.3.1.jar offline -m model.graphml "random(edge_coverage(100))" ``` -------------------------------- ### Check for Next Step via REST API Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-restful/README.md Query the service to determine if there are more steps to execute in the current model using a GET request. ```bash curl -i http://localhost:8887/graphwalker/hasNext ``` -------------------------------- ### Start GraphWalker as REST Service Source: https://github.com/graphwalker/graphwalker-project/wiki/C Run the GraphWalker standalone JAR as a RESTful service. Ensure the JAR file is in your current directory or provide the correct path. The service will be available at http://localhost:8887. ```bash java -jar graphwalker-cli-4.3.1.jar -debug all online --verbose --service RESTFUL ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-maven-archetype/README.md After generating the project, change into the newly created project directory. ```sh %> cd myProject ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/graphwalker/graphwalker-project/wiki/Create-boilerplate-project-using-maven Change the current directory to the newly created project folder. ```bash cd myProject ``` -------------------------------- ### Run graphwalker:watch Maven Plugin Source: https://github.com/graphwalker/graphwalker-project/wiki/Monitor-for-model-changes Execute the graphwalker:watch command to start monitoring model files. The plugin will automatically trigger model generation upon detecting changes. ```bash $ mvn graphwalker:watch ``` ```text [INFO] Scanning for projects... [INFO] [INFO] --------------< org.graphwalker.example:java-prestashop >--------------- [INFO] Building GraphWalker PrestaShop Example 4.3.1 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- graphwalker-maven-plugin:4.3.1:watch (default-cli) @ java-prestashop --- [INFO] Watching: /home/krikar/dev/mbt/graphwalker/graphwalker-example/java-prestashop/src/main/resources [INFO] Watching: /home/krikar/dev/mbt/graphwalker/graphwalker-example/java-prestashop/src/main/resources/images [INFO] Watching: /home/krikar/dev/mbt/graphwalker/graphwalker-example/java-prestashop/src/main/resources/com [INFO] Watching: /home/krikar/dev/mbt/graphwalker/graphwalker-example/java-prestashop/src/main/resources/com/prestashop ``` -------------------------------- ### Generated Interface Example Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Example of a Java interface generated by GraphWalker, defining model elements like vertices and edges. ```java // Generated by GraphWalker (http://www.graphwalker.org) package com.company; import org.graphwalker.java.annotation.Model; import org.graphwalker.java.annotation.Vertex; import org.graphwalker.java.annotation.Edge; @Model(file = "com/company/SmallTest.json") public interface SmallTest { @Edge() void e_FirstAction(); @Edge() void e_SomeOtherAction(); @Edge() void e_AnotherAction(); @Edge() void e_SomeAction(); @Vertex() void v_VerifyFirstAction(); @Vertex() void v_VerifyInitialState(); @Vertex() void v_NewVertex(); } ``` -------------------------------- ### Run Maven Build with Maven Wrapper (Windows) Source: https://github.com/graphwalker/graphwalker-project/wiki/Maven-wrapper Execute a Maven build using the Maven Wrapper script on Windows. The wrapper handles downloading and using the correct Maven version if not already present. ```bash mvnw.cmd clean install ``` -------------------------------- ### Start GraphWalker REST Service with Debug Source: https://github.com/graphwalker/graphwalker-project/wiki/Rest-API-overview Starts the GraphWalker REST service on the default port 8887 with all debug levels enabled. ```console java -jar graphwalker-cli-4.3.1.jar --debug all online --service RESTFUL ``` -------------------------------- ### Run Maven Build with Maven Wrapper (Unix/Linux/macOS) Source: https://github.com/graphwalker/graphwalker-project/wiki/Maven-wrapper Execute a Maven build using the Maven Wrapper script on Unix-like systems. The wrapper handles downloading and using the correct Maven version if not already present. ```bash ./mvnw clean install ``` -------------------------------- ### Example GraphWalker Edge JSON Source: https://github.com/graphwalker/graphwalker-project/wiki/JSON-file-format:-edge An example of a GraphWalker edge as used in the PetClinic test, demonstrating the application of actions and guard conditions. ```json { "actions": [ " numOfPets++;" ], "id": "e0", "name": "e_AddPetSuccessfully", "guard": "numOfPets <= 10", "sourceVertexId": "n1", "targetVertexId": "n0" } ``` -------------------------------- ### Build and Run GraphWalker CLI Jar Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Instructions for cloning, building, and running the GraphWalker CLI jar. Includes creating a wrapper script for convenience. ```bash # Clone and build all modules git clone https://github.com/GraphWalker/graphwalker-project.git cd graphwalker-project mvn install # Build only the CLI jar mvn package -pl graphwalker-cli -am # Jar is placed at: graphwalker-cli/target/graphwalker-cli-.jar # Create a convenient wrapper script (Linux/macOS) echo '#!/bin/bash\njava -jar /opt/graphwalker/graphwalker-cli-4.3.2.jar "$@"' | sudo tee /usr/local/bin/gw sudo chmod +x /usr/local/bin/gw # Run directly java -jar graphwalker-cli-4.3.2.jar --help ``` -------------------------------- ### GraphWalker Online Start WebSocket Server Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Starts the GraphWalker WebSocket server on the default port 8887. This is the default mode for online operation. ```console # Start WebSocket server on default port 8887 java -jar graphwalker-cli-4.3.2.jar online ``` -------------------------------- ### Build and Run GraphWalker Studio Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Instructions to build the GraphWalker Studio using Maven and then run the generated JAR file. The Studio serves a web interface for model editing and test execution. ```bash # Build Studio mvn package -pl graphwalker-studio -am # Run Studio (serves at http://localhost:9090/studio.html) java -jar graphwalker-studio/target/graphwalker-studio-.jar # Open in browser open http://localhost:9090/studio.html ``` -------------------------------- ### Start GraphWalker REST Service on Custom Port Source: https://github.com/graphwalker/graphwalker-project/wiki/Rest-API-overview Starts the GraphWalker REST service on a specified port (9999) without any debug level. ```console java -jar graphwalker-cli-4.3.1.jar online --service RESTFUL --port 9999 ``` -------------------------------- ### Get Current Model Data via REST API Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-restful/README.md Retrieve all attributes and their current values for the active model using a GET request. ```bash curl -i http://localhost:8887/graphwalker/getData ``` -------------------------------- ### Build and Run C# Test (Linux) Source: https://github.com/graphwalker/graphwalker-project/wiki/C Build the C# project using xbuild and then run the test executable with mono. This connects to the GraphWalker server. ```console xbuild mono SmallModel/bin/Debug/SmallModel.exe ``` -------------------------------- ### Retrieve Next Execution Step via REST API Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-restful/README.md Get the next element to be executed from the loaded model using a GET request. ```bash curl -i http://localhost:8887/graphwalker/getNext ``` -------------------------------- ### Build GraphWalker Studio with Maven Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-studio/README.md Use this command to compile and package the GraphWalker Studio project. The resulting JAR file will be located in the target directory. ```bash mvn package ``` -------------------------------- ### Define PetClinic Model with Start Element Source: https://github.com/graphwalker/graphwalker-project/wiki/JSON-file-format This JSON defines the PetClinic model, including edges, vertices, a generator, and a start element. It specifies the initial transition for the model. ```json { "edges": [ { "id": "e0", "name": "e_FindOwners", "sourceVertexId": "n0", "targetVertexId": "n1" }, { "id": "e1", "name": "e_HomePage", "sourceVertexId": "n1", "targetVertexId": "n0" }, { "id": "e2", "name": "e_Veterinarians", "sourceVertexId": "n0", "targetVertexId": "n2" }, { "id": "e3", "name": "e_HomePage", "sourceVertexId": "n2", "targetVertexId": "n0" }, { "id": "e4", "name": "e_Veterinarians", "sourceVertexId": "n1", "targetVertexId": "n2" }, { "id": "e5", "name": "e_FindOwners", "sourceVertexId": "n2", "targetVertexId": "n1" }, { "id": "e6", "name": "e_StartBrowser", "targetVertexId": "n0" } ], "generator": "quick_random(edge_coverage(100))", "id": "3f6b365f-7011-4db6-b0cc-e19aa453d9b8", "name": "PetClinicSharedState", "startElementId": "e6", "vertices": [ { "id": "n0", "name": "v_HomePage", "properties": { "x": 0, "y": 0 }, "sharedState": "HomePage" }, { "id": "n1", "name": "v_FindOwners", "properties": { "x": 265.65625, "y": -74.8125 }, "sharedState": "FindOwners" }, { "id": "n2", "name": "v_Veterinarians", "properties": { "x": -103.34375, "y": -139.8125 }, "sharedState": "Veterinarians" } ] } ``` -------------------------------- ### Create Project Directory Structure Source: https://github.com/graphwalker/graphwalker-project/wiki/Create-a-GraphWalker-project-by-hand Use these commands to create the basic directory structure for a GraphWalker project. Navigate into the created directory afterwards. ```bash mkdir -p gw_test/src/test/java/ cd gw_test ``` -------------------------------- ### Compile and Run GraphWalker Project Source: https://github.com/graphwalker/graphwalker-project/wiki/Create-boilerplate-project-using-maven Compile the project and execute the main class to run the GraphWalker tests. ```bash mvn compile exec:java -Dexec.mainClass="com.company.Runner" ``` -------------------------------- ### Build Custom Docker Image for Amazon Shopping Cart Source: https://github.com/graphwalker/graphwalker-project/wiki/Docker-example Builds a local Docker image tagged as 'my-amazon-shopping-cart-example' from the Dockerfile in the current directory. This is useful for local development or customization. ```bash docker build -t my-amazon-shopping-cart-example . ``` -------------------------------- ### Model File Location Source: https://github.com/graphwalker/graphwalker-project/wiki/Maven---generate-sources Models are placed in `src/main/resources` and use subdirectories to mimic package structure. ```text src/main/resources/com/company/SmallTest.graphml ``` -------------------------------- ### Start Websocket Command with Model Source: https://github.com/graphwalker/graphwalker-project/wiki/Websocket:-start This JSON payload is sent to the GraphWalker service to load a model and start the testing session. Ensure the model is correctly formatted within the 'gw3' tag. ```json { "command":"start", "gw3":{ "name":"A small test model", "models":[ { "name":"Small model", "generator":"random(edge_coverage(100))", "startElementId":"e0", "vertices":[ { "name":"v_VerifySomeAction", "id":"n0" }, { "name":"v_VerifySomeOtherAction", "id":"n1" } ], "edges":[ { "name":"e_FirstAction", "id":"e0", "targetVertexId":"n0" }, { "name":"e_AnotherAction", "id":"e1", "sourceVertexId":"n0", "targetVertexId":"n1" }, { "name":"e_SomeOtherAction", "id":"e2", "sourceVertexId":"n1", "targetVertexId":"n1" }, { "name":"e_SomeOtherAction", "id":"e3", "sourceVertexId":"n1", "targetVertexId":"n0" } ] } ] } } ``` -------------------------------- ### Build and Run C# PetClinic Tests Source: https://github.com/graphwalker/graphwalker-project/wiki/C Build the C# test project using xbuild and then run the executable with mono, specifying the GraphWalker model file. ```bash xbuild mono PetClinic/bin/Debug/PetClinic.exe PetClinic.gw3 ``` -------------------------------- ### GraphWalker Online Start REST Service with Model Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Starts the GraphWalker REST service and pre-loads a model with a specific generator and stop condition. The '-m' option is used for this purpose in RESTful mode. ```console # Start REST service with a model pre-loaded java -jar graphwalker-cli-4.3.2.jar -d all online -s RESTFUL \ -m ShoppingCart.graphml "random(edge_coverage(100))" ``` -------------------------------- ### Run GraphWalker PetClinic Test with Docker Source: https://github.com/graphwalker/graphwalker-project/wiki/PetClinic Pull the GraphWalker PetClinic Docker image and run it. This method pre-installs Firefox version 47.0.1 and the petclinic webserver, simplifying setup and avoiding version conflicts. ```bash docker pull graphwalker/petclinic docker run -ti --rm -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \ -v $HOME/.Xauthority:/home/developer/.Xauthority \ --net=host --pid=host --ipc=host graphwalker/petclinic ``` -------------------------------- ### Run GraphWalker Studio Source: https://github.com/graphwalker/graphwalker-project/blob/master/README.md Execute the GraphWalker Studio application using the generated JAR file. Replace with the actual version number. ```bash java -jar graphwalker-studio/target/graphwalker-studio-.jar ``` -------------------------------- ### GraphWalker Online Start REST Service Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Starts the GraphWalker RESTful service on a specified port (e.g., 9999) with debug logging enabled. The '--debug ALL' option provides verbose output. ```console # Start REST service on port 9999 with debug logging java -jar graphwalker-cli-4.3.2.jar --debug ALL online --service RESTFUL --port 9999 ``` -------------------------------- ### Example GraphWalker JSON Model for PetClinic Source: https://github.com/graphwalker/graphwalker-project/wiki/JSON-file-format:-model An example of a GraphWalker model in JSON format, representing the OwnerInformationSharedState for the PetClinic test. It includes specific generator settings, actions, edges with guards, and vertices with properties and shared states. ```json { "generator": "quick_random(edge_coverage(100))", "id": "5f1149c3-2853-47e6-838d-691bf30406a8", "name": "OwnerInformationSharedState", "actions": [ "numOfPets=0;" ], "edges": [ { "actions": [ " numOfPets++;" ], "id": "e0", "name": "e_AddPetSuccessfully", "sourceVertexId": "n1", "targetVertexId": "n0" }, { "id": "e1", "name": "e_AddNewPet", "sourceVertexId": "n0", "targetVertexId": "n1" }, { "guard": "numOfPets>0", "id": "e2", "name": "e_EditPet", "sourceVertexId": "n0", "targetVertexId": "n2" }, { "id": "e3", "name": "e_UpdatePet", "sourceVertexId": "n2", "targetVertexId": "n0" }, { "id": "e4", "name": "e_AddPetFailed", "sourceVertexId": "n1", "targetVertexId": "n1" }, { "guard": "numOfPets>0", "id": "e5", "name": "e_AddVisit", "sourceVertexId": "n0", "targetVertexId": "n3" }, { "id": "e6", "name": "e_VisitAddedSuccessfully", "sourceVertexId": "n3", "targetVertexId": "n0" }, { "id": "e7", "name": "e_VisitAddedFailed", "sourceVertexId": "n3", "targetVertexId": "n3" }, { "id": "e8", "name": "e_FindOwners", "sourceVertexId": "n0", "targetVertexId": "n4" } ], "vertices": [ { "id": "n0", "name": "v_OwnerInformation", "properties": { "x": -177.34375, "y": 35.1875 }, "sharedState": "OwnerInformation" }, { "id": "n1", "name": "v_NewPet", "properties": { "x": 252.65625, "y": 90.1875 } }, { "id": "n2", "name": "v_Pet", "properties": { "x": 253.65625, "y": -235.8125 } }, { "id": "n3", "name": "v_NewVisit", "properties": { "x": -46.34375, "y": -321.8125 } }, { "id": "n4", "name": "v_FindOwners", "properties": { "x": -256.34375, "y": -207.8125 }, "sharedState": "FindOwners" } ] } ``` -------------------------------- ### Build C# Project (Linux) Source: https://github.com/graphwalker/graphwalker-project/wiki/C Build the C# project using xbuild on a Linux environment. This step compiles the C# client code. ```console xbuild ``` -------------------------------- ### Get Execution Statistics Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-restful/README.md Retrieves statistics about the current execution progress. ```APIDOC ## GET /graphwalker/getStatistics ### Description Retreives statistics of the execution. ### Method GET ### Endpoint /graphwalker/getStatistics ### Parameters No parameters are required for this request. ### Request Example ```bash curl -i http://localhost:8887/graphwalker/getStatistics ``` ### Response #### Success Response (200) - **result** (string) - Indicates success ('ok'). - **statistics** (object) - An object containing current execution statistics. #### Response Example ```json { "result": "ok", "statistics": { "executed": 10, "total": 50, "remaining": 40 } } ``` ``` -------------------------------- ### Get Next Execution Element Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-restful/README.md Retrieves the next element to be executed from the model. ```APIDOC ## GET /graphwalker/getNext ### Description Retrieve the next element to be executed. ### Method GET ### Endpoint /graphwalker/getNext ### Parameters No parameters are required for this request. ### Request Example ```bash curl -i http://localhost:8887/graphwalker/getNext ``` ### Response #### Success Response (200) - **result** (string) - Indicates success ('ok'). - **CurrentElementName** (string) - The name of the next element to execute. #### Response Example ```json { "result": "ok", "CurrentElementName": "e_StartBrowser" } ``` ``` -------------------------------- ### Running the Maven Goal Source: https://github.com/graphwalker/graphwalker-project/wiki/Maven---generate-sources-for-tests Execute the `graphwalker:generate-test-sources` goal using Maven to generate the test interfaces. ```bash $ mvn graphwalker:generate-test-sources ``` -------------------------------- ### REST API: GET /graphwalker/getStatistics Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Returns coverage and execution statistics for the current session. ```APIDOC ## GET /graphwalker/getStatistics ### Description Returns coverage and execution statistics for the current session. ### Method GET ### Endpoint /graphwalker/getStatistics ### Request Example ```bash curl http://localhost:8887/graphwalker/getStatistics ``` ### Response Example ```json { "totalNumberOfEdges": 8, "totalNumberOfVisitedEdges": 6, "edgeCoverage": 75, "totalNumberOfVertices": 3, "totalNumberOfVisitedVertices": 3, "vertexCoverage": 100 } ``` ``` -------------------------------- ### Get Current Model Data Source: https://github.com/graphwalker/graphwalker-project/blob/master/graphwalker-restful/README.md Retrieves all attributes and their current values for the active model. ```APIDOC ## GET /graphwalker/getData ### Description Get the data of the current model. ### Method GET ### Endpoint /graphwalker/getData ### Parameters No parameters are required for this request. ### Request Example ```bash curl -i http://localhost:8887/graphwalker/getData ``` ### Response #### Success Response (200) - **result** (string) - Indicates success ('ok'). - **data** (object) - An object containing all attributes and their values. #### Response Example ```json { "result": "ok", "data": { "num_of_books": "0", "MAX_BOOKS": "5" } } ``` ``` -------------------------------- ### Create Project Folder Structure Source: https://github.com/graphwalker/graphwalker-project/wiki/Test-execution Use these commands to create the necessary directory structure for a GraphWalker project. ```sh %> mkdir -p login/src/main/java/org/myorg/testautomation %> mkdir -p login/src/main/resources/org/myorg/testautomation %> mkdir -p login/src/test/java/org/myorg/testautomation ``` -------------------------------- ### REST API: GET /graphwalker/getData Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Returns all data (variables) currently set in the execution context. ```APIDOC ## GET /graphwalker/getData ### Description Returns all data (variables) currently set in the execution context. ### Method GET ### Endpoint /graphwalker/getData ### Request Example ```bash curl http://localhost:8887/graphwalker/getData ``` ### Response Example ```json { "data": { "rememberMe": "false", "validLogin": "true" } } ``` ``` -------------------------------- ### REST API: GET /graphwalker/hasNext Source: https://context7.com/graphwalker/graphwalker-project/llms.txt Returns whether the current path generator has more steps to generate. ```APIDOC ## GET /graphwalker/hasNext ### Description Returns whether the current path generator has more steps to generate. ### Method GET ### Endpoint /graphwalker/hasNext ### Request Example ```bash curl http://localhost:8887/graphwalker/hasNext ``` ### Response Example ```json { "hasNext": "true" } ``` ``` -------------------------------- ### INIT Keyword Syntax Source: https://github.com/graphwalker/graphwalker-project/wiki/Creating-a-model-using-yEd Use the INIT keyword in a vertex to initialize data within a model. Multiple INIT keywords can be used. ```plaintext INIT:loggedIn=false; rememberMe=true; ``` -------------------------------- ### Build GraphWalker Studio Source: https://github.com/graphwalker/graphwalker-project/blob/master/README.md Build the GraphWalker Studio application. The resulting JAR file will be located in the graphwalker-studio/target directory. ```bash mvn package -pl graphwalker-studio -am ```