Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/graphaware/neo4j-resttest
Library for testing Neo4j code over REST
https://github.com/graphaware/neo4j-resttest
java neo4j neo4j-graphaware-framework
Last synced: about 1 month ago
JSON representation
Library for testing Neo4j code over REST
- Host: GitHub
- URL: https://github.com/graphaware/neo4j-resttest
- Owner: graphaware
- Archived: true
- Created: 2014-06-17T21:55:25.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-11-14T14:37:42.000Z (about 4 years ago)
- Last Synced: 2024-08-02T07:10:40.633Z (4 months ago)
- Topics: java, neo4j, neo4j-graphaware-framework
- Language: Java
- Size: 197 KB
- Stars: 13
- Watchers: 26
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-neo4j - GraphAware Neo4j RestTest - GraphAware RestTest is a simple library for testing code that talks to Neo4j running in standalone server mode. (REST API / Other)
README
GraphAware Neo4j RestTest - RETIRED
===================================## RestTest Has Been Retired
As of April 2020, this module is retiring. This means it will no longer be maintained and released together with new versions of the GraphAware Framework and Neo4j. The last compatible Neo4j version is 3.5.14.Custom REST APIs on top of Neo4j have been practically replaced by Cypher User Functions and Procedures. If you need functionality similar to what RestTest provided, go ahead and write a procedure that uses [GraphUnit](https://github.com/graphaware/neo4j-framework/blob/master/tests/src/main/java/com/graphaware/test/unit/GraphUnit.java).
This repository will remain public.
## Introduction
GraphAware RestTest is a simple library for testing code that talks to Neo4j running in standalone server mode.
Getting the Software
--------------------You will need the GraphAware Neo4j Framework and GraphAware Neo4j RestTest .jar files (both of which you can download here) dropped
into the `plugins` directory of your Neo4j installation.
For the framework to work, you need to adjust your neo4j configuration as described in the framework installation instructions.
After Neo4j restart, you will be able to use the RestTest APIs.Releases are synced to Maven Central repository.
#### Note on Versioning Scheme
The version number has two parts. The first four numbers indicate compatibility with Neo4j GraphAware Framework.
The last number is the version of the RestTest library. For example, version 2.1.2.7.2 is version 2 of RestTest
compatible with GraphAware Neo4j Framework 2.1.2.7.Using GraphAware RestTest
-------------------------RestTest allows you to assert the state of the database running in server mode and to clear it. It is in a sense equivalent
to using GraphUnit in
embedded mode.### REST API
When deployed in server mode, there are three URLs that you can issue POST requests to:
* `http://your-server-address:7474/graphaware/resttest/clear` to clear your database. No body required.
* `http://your-server-address:7474/graphaware/resttest/assertSameGraph` to assert the state of the database. You need to provide a body described shortly.
* `http://your-server-address:7474/graphaware/resttest/assertSubgraph` to assert the state of the database. You need to provide a body described shortly.
* `http://your-server-address:7474/graphaware/resttest/assertEmpty` to assert the database is empty. You need to provide a body described shortly.The body where required needs to provide a Cypher CREATE statement, representing the state of the database being asserted,
for example:```json
{
"cypher": "CREATE (one:Person {name:'One'})-[:FRIEND_OF]->(two:Person {name:'Two'})"
}
```The second API call is used to verify that the graph in the database is exactly the same as the graph created by the Cypher
CREATE statement provided in the body of the request. This means that the nodes, their properties and labels, relationships,
and their properties and labels must be exactly the same. Note that Neo4j internal node/relationship IDs are ignored.
In case the graphs aren't identical, the assertion fails and you will get a response with EXPECTATION_FAILED (417) status code.
If the test passes, you will get an OK (200).The third API call is used to verify that the graph created by provided Cypher statement is a subgraph of the graph in the database.
Request body options and response codes are same as above.Finally, the API call that ensures that the database is empty has the body as an optional requirement and, of course,
no Cypher is required.### Cypher procedures and functions
This module provides a set of Cypher procedures and functions that allows to call the methods from Cypher.
#### Cleaning the database stored procedure from Cypher
This procedure allows to clear your database. No parameter required.
Example of usage:
```
CALL ga.resttest.clearDatabase();
```
#### Assertion functions from CypherThis function allows to assert the state of the database. You need to provide a parameter described shortly.
Example of usage:
```
RETURN ga.resttest.assertSameGraph("{ \"cypher\": \"...\"}") AS value;
```
This function is used to verify that the graph in the database is exactly the same as the graph created by the Cypher CREATE statement provided in the parameter. This means that the nodes, their properties and labels, relationships, and their properties and labels must be exactly the same. Note that Neo4j internal node/relationship IDs are ignored.
In case the graphs aren't identical, the assertion fails and you will get false value. If the test passes, you will get a true value.This function allows to assert a part of the database. You need to provide a parameter described shortly.
Example of usage:
```
RETURN ga.resttest.assertSubgraph("{ \"cypher\": \"...\"}") AS value;
```
This function is is used to verify that the graph created by provided Cypher statement is a subgraph of the graph in the database.
In case if the result of cypher is not identical of any subgraph of the database It will return false value. If it is a subgraph of the database you will get a true value.This function allows to ensure that the database is empty. You can define a parameter described shortly or use with an empty string.
Example of usage:
```
RETURN ga.resttest.assertEmpty("{ \"node\": \"...\"}") AS value;
```
If the database is not empty It will return false value. If it empty you will get a true value.### Request body and user function parameter
It is possible to use expressions to include/exclude certain nodes, relationships, and properties thereof from the comparisons.
For example, for the purposes of comparison, if we only wanted to include nodes labelled `Person`, relationships with type `FRIEND_OF`, and ignore any
`timestamp` properties on both nodes and relationships, the body of the POST request (or the parameter of the function) would look like this:```json
{
"cypher": "CREATE (one:Person {name:'One'})-[:FRIEND_OF]->(two:Person {name:'Two'})",
"node":"hasLabel('Person')",
"relationship":"isType('FRIEND_OF')",
"node.property":"key != 'timestamp'",
"relationship.property":"key != 'timestamp'"
}
```License
-------Copyright (c) 2014-2020 GraphAware
GraphAware is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see .