Skip to content

App Developers: How to Exercise Your App

Barry Demchak edited this page Jul 7, 2017 · 1 revision

Sometimes it is necessary to use Commands and Functions outside of a scripting environment, to explore the features of existing automation or test automation that you have developed in your App. This section explains how to access the automation features in an app by various methods.

For accessing Commands and Functions through scripts, see Cytoscape Automation for Script Writers.

Execution requirements

The following requirements are necessary for any of these methods:

  1. Start Cytoscape from the command line. Be mindful that -R option (normally './cytoscape.sh -R 1234' or './cytoscape.exe -R 1234') sets the REST port that you will use to access the CyREST server.
  2. Using the Cytoscape App Manager, ensure that CyREST is installed, and is up to date -- it is installed by default, but new releases frequently appear in the app store.
  3. Install your sample app jar through the Cytoscape App Manager by using the 'Install from file...' button.

Accessing through CyREST's Swagger UI

If you are accessing a Function with Swagger documentation, or a well documented Command, automation features will be exposed in CyREST's in-application Swagger UI. The CyREST App provides a Help sub-menu called Automation, accessible through via Help --> Automation in the Cytoscape menu bar, which allows access to two API's that cab be displayed as Swagger pages in your web browser.

  • Functions (as JAX-RS annotated operations) are available through the CyREST API menu item.
  • Commands (as TaskFactories implementing the commands API) are available through the CyREST Command API menu item.

Swagger gives readers access to documentation on path parameters, query parameters, results and contextual information. It also allows a reader to frame and execute calls to Functions and Commands instead of requiring the reader to write and execute separate programs or command scripts.

  1. On Cytoscape, use the Help --> Automation --> CyREST API menu to show the CyREST Swagger page in the browser.
  2. Choose REST Service and then GET /v1.
  3. The browser should display the documentation page for the server status API.
  4. Click the Try it out! button to execute the GET /v1 function and see its response.

Though this method of testing can be convenient for quick tests, it has many limitations. HTTP operations outside of GET (e.g., POST, PUT, DELETE, PATCH) can require message bodies and might not be possible to access as intended through a browser. In addition, browsers normally request HTML data by default, and in some cases may not return other types, such as the plaintext or JSON results returned by Commands and Functions.

Accessing through a Web Browser

HTTP GET operations (i.e., Commands and some Functions) are very easy to execute through a web browser, such as Google Chrome, as they require no message body to be included. Any operation can be requested by entering its path in the browser's URL area (e.g., http://localhost:1234/v1/). If you are an App developer, you will have set the path for your function or command yourself. To find a list of existing operations and paths, you can explore the Swagger UI.

Experiment: See simple CyREST-based Cytoscape access via a browser:

  1. Start Cytoscape and a web browser.
  2. On the address bar, enter http://localhost:1234/v1/ CyREST operation.
  3. The browser should display Cytoscape information similar to:

Accessing through a REST Client

REST clients allow more control over operation access, allowing users to set message bodies, path parameters, query parameters, HTTP headers, etc.

Simple command-line clients, such as curl allow simple, shell access to REST, and may already be included in your operating system.

Some browsers accept plugins, such as Advanced REST Client, that implement a full-featured REST testing environment that allows all HTTP operations.

Dedicated applications such as Insomnia are also available.

Each tool has unique advantages and use cases to offer to the Cytoscape scripter or developer when dealing with App automation.