Neo4j
Why Using Neo4j?¶
Neo4j
is an open-source graph database management system. It is designed to store, manage, and query large amounts of data that are represented in the form of a graph, with nodes, edges, and properties to represent the data.
The main advantage of using a graph database like
Neo4j
is that it is particularly well-suited for representing and querying complex relationships and connections between data points such as usage states in a usage model. This makes it an excellent choice for use cases such as traversing state models and presenting characteristic properties like model name, test suite properties and timestamp information.
Neo4j
is implemented in Java and is available for use on a variety of platforms, including Linux
, macOS
, and Windows
. It is accessed using a query language called Cypher
, which is designed specifically for querying and updating graph data. Neo4j also provides a rich set of APIs and integrations with other tools and technologies, making it easy to use in a variety of applications and environments such as the TestUS TestPlayer©
.
Neo4j Database Browser¶
The
Some of the main functionality of the
Neo4j Database Browser
is a graphical user interface (GUI) tool for interacting with and querying a Neo4j
graph database. It provides a number of features and functions that allow experienced users to view, manipulate, and query the data stored in the database.
Some of the main functionality of the
Neo4j Database Browser
includes:
- Displaying data stored in the database in a graphical format, with nodes and edges representing the data and relationships between data points, i.e. usage states of the usage model.
- Allowing users to create, edit, and delete nodes and relationships in the database using a visual interface.
-
Providing a query editor that allows users to write and execute
Cypher
queries to retrieve and manipulate data in the database, i.e. models, test suites, test steps, transitions etc.. - Displaying query results in a variety of formats, including tables, charts, and maps.
- Providing tools for creating and modifying database schema, including indexes, constraints, and user-defined procedures.
- Enabling users to view and manage database statistics, such as the number of nodes and relationships in the database, and the performance of various database operations.
-
Providing a built-in terminal for accessing the database using the
Neo4j
command-line interface.
Neo4j Database Browser
is a tool that allows experienced users to interact with a Neo4j
database, making it easier to work with graph data and perform various database operations.
First Neo4j Queries¶
After successfully logging in to the URL http://172.26.0.2:7474/browser
, the user will have access to the Neo4j
graph database and can interact with the Neo4j
browser GUI shown below.
![](../img/neo4j-1.png)
-
Database Information¶
On the left side of the browser window you can find detailed information about the current database content by clicking on the database icon in the upper left corner.
- Node labels show the total number of nodes and the various node types in the graph database.
- Relationship Types display the total number of relationships and the different relationships, i.e. annotated edges between nodes, contained in the graph database.
- Property Keys are the various attributes associated with nodes and relationships.
![](../img/neo4j-2.png)
-
Query Database Information¶
The Neo4j
user can obtain detailed database information by using an appropriate Cypher CALL
database query instead.
- Query for Node labels
- Query for Relationship Types
- Query for Property Keys
Cypher Queries for the TestPlayer© database¶
After knowing all the labels, relationships and properties of the
Neo4j
TestPlayer© database, the experienced user can formulate more concrete Cypher
queries to get specific information for each model, usage profile or test suite stored in the TestPlayer© database.
-
Test suite graph via TestPlayer© GUI¶
With the help of the
TestPlayer© GUI
, a test suite tree of a usage model can be generated and visualized after selecting a concrete test suite.
![](../img/neo4j-7.png)
The result of selecting
HelloTestPlayer©/state_coverage/2022_12_04_22_39_38
is presented in the following diagram.
![](../img/neo4j-8.png)
-
Test suite graph via Neo4j CLI¶
Instead of using the
TestPlayer© GUI
, a Neo4j
user can formulate the following Cypher
query directly from the Neo4j
browser's CLI
(Command Line Interface). The result is immediately presented in either a graph, table or text representation.
MATCH p=(t)-[]->(r) WHERE t.modelName='HelloTestPlayer©'
AND t.user='TestPlayer©' AND t.timestamp='2022_12_04_22_39_38'
RETURN p
![](../img/neo4j-9.png)
The result of selecting
HelloTestPlayer©/state_coverage/2022_12_04_22_39_38
is presented in the following diagram.
The diagram consists of nodes in multiple colors that have different attributes, as well as labeled edges, and contains the following information created in
Neo4j
.
-
Test suite (turquoise)
Logging data (yellow)
-
Report data (blue)
-
Json representation of the test suite (red)
-
Diagram either in XML, HTML, Png or Svg format (green)
-
Test case (light blue)
-
Test step (light green)
-
Relationship between nodes
![](../img/neo4j-12.png)
-
Usage model via Neo4j CLI¶
Instead of using the
TestPlayer© GUI
, a Neo4j
user can formulate the following Cypher
query to generate a usage model directly from the Neo4j
relationship HAS_TRANSITION
.
MATCH p=()-[r:HAS_TRANSITION]->()
WHERE r.modelName="HelloTestPlayer©"
RETURN p
![](../img/neo4j-23.png)
The result of selecting usage model
HelloTestPlayer©
is presented in the following diagram.