AssertJ Neo4j assertions

Provides assertions for Neo4j 2 or higher.

This module have been written by Florent Biville, huge thanks to him ! Great Work !
If you need additional assertions, just fill a ticket in AssertJ Neo4j issue tracker.

AssertJ Neo4j is hosted on github :

To quickly start using Neo4j assertions, follow the steps below.


You also need to provide Neo4j 2+ dependencies.

If you use another dependency tool, please check this page to find the relevant assertj dependency declaration for your tool.

... and use your preferred IDE code completion after assertThat.

Example from :

import static org.assertj.neo4j.api.Assertions.assertThat;

// initialization omitted for brevity ...
Path bulmaToMasterRoshiPath = dragonBallGraph.findShortestPathBetween("Bulma", "Master Roshi");

Node bulmaNode = dragonBallGraph.findCharacter("Bulma");
Node masterRoshiNode = dragonBallGraph.findCharacter("Master Roshi");
Relationship trainingFromSonGoku = dragonBallGraph.findTrainingFrom("Son Goku");

// you can test several Path properties such as length, start/end node and last relationship

assertThat and entry are static imports from the Assertions class.

Note that you can find more working examples in neo4j package of assertj-examples project.

Release date : 2014-01-02

  • Node assertions
  • Path assertions
  • Relationship assertions
  • PropertyContainer assertions

Latest javadoc release : AssertJ Neo4j javadoc.

You will have to make two static import : one for org.assertj.core.api.Assertions.assertThat to get core assertions and one org.assertj.neo4j.api.Assertions.assertThat for neo4j assertions.

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.neo4j.api.Assertions.assertThat;

// initialization omitted for brevity ...
Node firstDisciple = ...;

// assertThat comes from org.assertj.neo4j.api.Assertions.assertThat static import
                         .hasProperty("name", "Son Goku")
                         .doesNotHaveProperty("name", "Bulma");

// assertThat comes from org.assertj.core.api.Assertions.assertThat static import
assertThat("hello world").startsWith("hello");

If you have any questions, please use AssertJ google group.

AssertJ Neo4j is hosted on github :

Please report bugs or missing features in AssertJ Neo4j issue tracker.

Thanks for your interest ! Please check our contributor's guidelines.

Special thanks to Florent Biville AssertJ Neo4j main contributor.