Database Reference
In-Depth Information
GraphUnit.assertSameGraph(graphDb,"create
(n:TestNode) return n");
}
The first part of the preceding code, where we create a node in the test Neo4j database re-
mains the same, but the latter part is replaced with a single assertion provided by
GraphUnit, which checks whether the given graph is equivalent to the graph created by
the provided cypher statement. GraphUnit also provides assertions for testing parts of
graphs, that is, subgraphs. Refer to http://graphaware.com/site/framework/latest/apidocs/
com/graphaware/test/unit/GraphUnit.html for available assertions with GraphUnit.
AssertJ also helps in a similar way. Perform the following steps to use assertions provided
by AssertJ:
1. Open your MyNeo4jSamples/pom.xml file and add the following dependen-
cies in the <dependencies> section:
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-neo4j</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
2. Add another function by the name of compareProperties() and add the
following code:
@org.junit.Test
public void compareProperties () {
//Open a Transaction
try(Transaction transaction=graphDb.beginTx()){
String testLabel="TestNode";
String testKey="key";
String testValue="value";
//Create a Node with Label in the neo4j test
Database
Node node =
Search WWH ::




Custom Search