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 : https://github.com/joel-costigliola/assertj-neo4j.

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

<dependency>
  <groupId>org.assertj</groupId>
  <artifactId>assertj-neo4j</artifactId>
  <version>1.0.0</version>
  <scope>test</scope>
</dependency>

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 PathAssertionExamples.java :

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(bulmaToMasterRoshiPath).hasLength(3)
                                  .startsWithNode(bulmaNode)
                                  .endsWithNode(masterRoshiNode)
                                  .endsWithRelationship(trainingFromSonGoku);

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
assertThat(firstDisciple).hasPropertyKey("name")
                         .hasProperty("name", "Son Goku")
                         .doesNotHavePropertyKey("firstName")
                         .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 : https://github.com/joel-costigliola/assertj-neo4j.

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.