From 67eb2db98db4ee06ad12a28f3c3d74a534667812 Mon Sep 17 00:00:00 2001 From: Florent Biville Date: Sun, 26 Jan 2014 04:32:09 +0100 Subject: [PATCH] Reformat. --- .../neo4j/Neo4jAssertionExamples.java | 28 ++-- .../examples/neo4j/NodeAssertionExamples.java | 82 +++++------ .../examples/neo4j/PathAssertionExamples.java | 38 +++--- .../neo4j/RelationshipAssertionExamples.java | 128 +++++++++--------- 4 files changed, 138 insertions(+), 138 deletions(-) diff --git a/src/test/java/org/assertj/examples/neo4j/Neo4jAssertionExamples.java b/src/test/java/org/assertj/examples/neo4j/Neo4jAssertionExamples.java index 4d3a574..53cc1ab 100644 --- a/src/test/java/org/assertj/examples/neo4j/Neo4jAssertionExamples.java +++ b/src/test/java/org/assertj/examples/neo4j/Neo4jAssertionExamples.java @@ -22,20 +22,20 @@ import java.io.IOException; public class Neo4jAssertionExamples { - protected static GraphDatabaseService graphDB; - protected static DragonBallGraph dragonBallGraph; + protected static GraphDatabaseService graphDB; + protected static DragonBallGraph dragonBallGraph; - @BeforeClass - public static void prepare_graph() throws IOException { - graphDB = new TestGraphDatabaseFactory().newImpermanentDatabase(); - dragonBallGraph = new DragonBallGraph(graphDB); - dragonBallGraph.importGraph( - Neo4jAssertionExamples.class.getResourceAsStream("/dragonBall.cypher") - ); - } + @BeforeClass + public static void prepare_graph() throws IOException { + graphDB = new TestGraphDatabaseFactory().newImpermanentDatabase(); + dragonBallGraph = new DragonBallGraph(graphDB); + dragonBallGraph.importGraph( + Neo4jAssertionExamples.class.getResourceAsStream("/dragonBall.cypher") + ); + } - @AfterClass - public static void cleanUp() { - graphDB.shutdown(); - } + @AfterClass + public static void cleanUp() { + graphDB.shutdown(); + } } diff --git a/src/test/java/org/assertj/examples/neo4j/NodeAssertionExamples.java b/src/test/java/org/assertj/examples/neo4j/NodeAssertionExamples.java index 491a8aa..71ca49f 100644 --- a/src/test/java/org/assertj/examples/neo4j/NodeAssertionExamples.java +++ b/src/test/java/org/assertj/examples/neo4j/NodeAssertionExamples.java @@ -22,52 +22,52 @@ import static org.assertj.neo4j.api.Assertions.assertThat; public class NodeAssertionExamples extends Neo4jAssertionExamples { - @Test - public void node_assertions_examples() { - try (Transaction tx = graphDB.beginTx()) { - // let us find the disciples of Master Roshi persisted in Neo4j - Iterable disciples = dragonBallGraph.disciplesOf("Master Roshi"); + @Test + public void node_assertions_examples() { + try (Transaction tx = graphDB.beginTx()) { + // let us find the disciples of Master Roshi persisted in Neo4j + Iterable disciples = dragonBallGraph.disciplesOf("Master Roshi"); - // you can enjoy the usual assertj-core assertions ;-) - assertThat(disciples).hasSize(3); + // you can enjoy the usual assertj-core assertions ;-) + assertThat(disciples).hasSize(3); - // you can benefit from all PropertyContainer assertions - // when you give a Node instance - Node firstDisciple = disciples.iterator().next(); - assertThat(firstDisciple) - .hasPropertyKey("name") - .hasProperty("name", "Son Goku") - .doesNotHavePropertyKey("firstName") - .doesNotHaveProperty("name", "Bulma") + // you can benefit from all PropertyContainer assertions + // when you give a Node instance + Node firstDisciple = disciples.iterator().next(); + assertThat(firstDisciple) + .hasPropertyKey("name") + .hasProperty("name", "Son Goku") + .doesNotHavePropertyKey("firstName") + .doesNotHaveProperty("name", "Bulma") - // you can test against node labels: their String representation or - // the equivalent Label object - .hasLabel("CHARACTER") - .hasLabel(DynamicLabel.label("HERO")) - .doesNotHaveLabel("VILLAIN") - .doesNotHaveLabel(DynamicLabel.label("MASTER")); + // you can test against node labels: their String representation or + // the equivalent Label object + .hasLabel("CHARACTER") + .hasLabel(DynamicLabel.label("HERO")) + .doesNotHaveLabel("VILLAIN") + .doesNotHaveLabel(DynamicLabel.label("MASTER")); - // and you can enjoy the same error message mechanism from assertj-core ! - try { - assertThat(firstDisciple) - .as("[check %s's name]", firstDisciple.getProperty("name")) - .doesNotHaveProperty("name", "Son Goku"); - } - catch (AssertionError ae) { - assertThat(ae).hasMessage("[[check Son Goku's name]] \n" + - "Expecting:\n" + - " \n" + - "not to have property with key:\n" + - " <\"name\">\n" + - "and value:\n" + - " <\"Son Goku\">\n" + - "but actually found such property "); - } + // and you can enjoy the same error message mechanism from assertj-core ! + try { + assertThat(firstDisciple) + .as("[check %s's name]", firstDisciple.getProperty("name")) + .doesNotHaveProperty("name", "Son Goku"); + } + catch (AssertionError ae) { + assertThat(ae).hasMessage("[[check Son Goku's name]] \n" + + "Expecting:\n" + + " \n" + + "not to have property with key:\n" + + " <\"name\">\n" + + "and value:\n" + + " <\"Son Goku\">\n" + + "but actually found such property "); + } - tx.close(); + tx.close(); - // just check that we can use standard assertions along with Neo4j ones - assertThat("hello world").startsWith("hello"); - } + // just check that we can use standard assertions along with Neo4j ones + assertThat("hello world").startsWith("hello"); } + } } diff --git a/src/test/java/org/assertj/examples/neo4j/PathAssertionExamples.java b/src/test/java/org/assertj/examples/neo4j/PathAssertionExamples.java index 9155cb3..f05224b 100644 --- a/src/test/java/org/assertj/examples/neo4j/PathAssertionExamples.java +++ b/src/test/java/org/assertj/examples/neo4j/PathAssertionExamples.java @@ -22,27 +22,27 @@ import static org.assertj.neo4j.api.Assertions.assertThat; public class PathAssertionExamples extends Neo4jAssertionExamples { - @Test - public void path_assertion_examples() { - try (Transaction tx = graphDB.beginTx()) { - // let us find the shortest path between Bulma and Master Roshi - Path bulmaToMasterRoshiPath = dragonBallGraph.findShortestPathBetween("Bulma", "Master Roshi"); + @Test + public void path_assertion_examples() { + try (Transaction tx = graphDB.beginTx()) { + // let us find the shortest path between Bulma and Master Roshi + Path bulmaToMasterRoshiPath = dragonBallGraph.findShortestPathBetween("Bulma", "Master Roshi"); - // you can test several Path properties such as length, - // start/end node and last relationship - final Node bulmaNode = dragonBallGraph.findCharacter("Bulma"); - final Node masterRoshiNode = dragonBallGraph.findCharacter("Master Roshi"); - final Relationship trainingFromSonGoku = dragonBallGraph.findTrainingFrom("Son Goku"); - assertThat(bulmaToMasterRoshiPath) - .hasLength(3) - .startsWithNode(bulmaNode) - .endsWithNode(masterRoshiNode) - .endsWithRelationship(trainingFromSonGoku) + // you can test several Path properties such as length, + // start/end node and last relationship + final Node bulmaNode = dragonBallGraph.findCharacter("Bulma"); + final Node masterRoshiNode = dragonBallGraph.findCharacter("Master Roshi"); + final Relationship trainingFromSonGoku = dragonBallGraph.findTrainingFrom("Son Goku"); + assertThat(bulmaToMasterRoshiPath) + .hasLength(3) + .startsWithNode(bulmaNode) + .endsWithNode(masterRoshiNode) + .endsWithRelationship(trainingFromSonGoku) // you can enjoy the usual assertj-core assertions (Path is an Iterable) ;-) - .doesNotContainNull(); + .doesNotContainNull(); - tx.close(); - } - } + tx.close(); + } + } } diff --git a/src/test/java/org/assertj/examples/neo4j/RelationshipAssertionExamples.java b/src/test/java/org/assertj/examples/neo4j/RelationshipAssertionExamples.java index 9ff6b50..ee21a87 100644 --- a/src/test/java/org/assertj/examples/neo4j/RelationshipAssertionExamples.java +++ b/src/test/java/org/assertj/examples/neo4j/RelationshipAssertionExamples.java @@ -28,80 +28,80 @@ import static org.assertj.neo4j.api.Assertions.assertThat; public class RelationshipAssertionExamples extends Neo4jAssertionExamples { - @Test - public void relationship_assertions_examples() { - try (Transaction tx = graphDB.beginTx()) { - // let us find the fusions between Dragon Ball characters persisted in Neo4j - Iterable fusions = dragonBallGraph.fusions(); + @Test + public void relationship_assertions_examples() { + try (Transaction tx = graphDB.beginTx()) { + // let us find the fusions between Dragon Ball characters persisted in Neo4j + Iterable fusions = dragonBallGraph.fusions(); - // you can enjoy the usual assertj-core assertions ;-) - assertThat(fusions).hasSize(4); - Iterable funnyFusions = filter(fusions, FUNNY_ONLY()); - assertThat(funnyFusions).hasSize(2); + // you can enjoy the usual assertj-core assertions ;-) + assertThat(fusions).hasSize(4); + Iterable funnyFusions = filter(fusions, FUNNY_ONLY()); + assertThat(funnyFusions).hasSize(2); - // you can chain assertions on relationship types: their String representation - // or the equivalent RelationshipType instance - Iterator iterator = funnyFusions.iterator(); - Relationship veku = iterator.next(); + // you can chain assertions on relationship types: their String representation + // or the equivalent RelationshipType instance + Iterator iterator = funnyFusions.iterator(); + Relationship veku = iterator.next(); - assertThat(veku) - .hasType("IN_FUSION_WITH") - .hasType(DynamicRelationshipType.withName("IN_FUSION_WITH")) - .doesNotHaveType("HAS_WORKED_FOR") - .doesNotHaveType(DynamicRelationshipType.withName("HAS_WORKED_FOR")); + assertThat(veku) + .hasType("IN_FUSION_WITH") + .hasType(DynamicRelationshipType.withName("IN_FUSION_WITH")) + .doesNotHaveType("HAS_WORKED_FOR") + .doesNotHaveType(DynamicRelationshipType.withName("HAS_WORKED_FOR")); - // you can benefit from all PropertyContainer assertions - // when you give a Relationship instance - Relationship krillinPiccoloFusion = iterator.next(); - Node krillin = dragonBallGraph.findCharacter("Krillin"); - Node piccolo = dragonBallGraph.findCharacter("Piccolo"); + // you can benefit from all PropertyContainer assertions + // when you give a Relationship instance + Relationship krillinPiccoloFusion = iterator.next(); + Node krillin = dragonBallGraph.findCharacter("Krillin"); + Node piccolo = dragonBallGraph.findCharacter("Piccolo"); - assertThat(krillinPiccoloFusion) - .hasPropertyKey("into") - .hasProperty("into", "Prilin") - .hasProperty("useless", true) - .doesNotHaveProperty("useless", false) - .doesNotHavePropertyKey("name") + assertThat(krillinPiccoloFusion) + .hasPropertyKey("into") + .hasProperty("into", "Prilin") + .hasProperty("useless", true) + .doesNotHaveProperty("useless", false) + .doesNotHavePropertyKey("name") - // you can test relationship start/end nodes - .startsOrEndsWithNode(krillin) - .startsWithNode(krillin) - .startsOrEndsWithNode(piccolo) - .endsWithNode(piccolo); + // you can test relationship start/end nodes + .startsOrEndsWithNode(krillin) + .startsWithNode(krillin) + .startsOrEndsWithNode(piccolo) + .endsWithNode(piccolo); - // and you can enjoy the same error message mechanism from assertj-core ! - try { - assertThat(veku).as("[check %s's start/end node]", veku.getProperty("into")) - .startsOrEndsWithNode(krillin); - } - catch (AssertionError ae) { - assertThat(ae).hasMessage("[[check Veku's start/end node]] \n" + - "Expecting:\n" + - " \n" + - "to either start or end with node:\n" + - " \n" - ); - } + // and you can enjoy the same error message mechanism from assertj-core ! + try { + assertThat(veku).as("[check %s's start/end node]", veku.getProperty("into")) + .startsOrEndsWithNode(krillin); + } + catch (AssertionError ae) { + assertThat(ae).hasMessage("[[check Veku's start/end node]] \n" + + "Expecting:\n" + + " \n" + + "to either start or end with node:\n" + + " \n" + ); + } - tx.close(); - } + tx.close(); + } + } + + static class UselessFusion implements Predicate { + + private UselessFusion() {} + + public static UselessFusion FUNNY_ONLY() { + return new UselessFusion(); } - static class UselessFusion implements Predicate { - - private UselessFusion() {} - - public static UselessFusion FUNNY_ONLY() { - return new UselessFusion(); - } - - @Override - public boolean apply(Relationship input) { - if (input == null) { - return false; - } - return (boolean) input.getProperty("useless", Boolean.FALSE); - } + @Override + public boolean apply(Relationship input) { + if (input == null) { + return false; + } + return (boolean) input.getProperty("useless", Boolean.FALSE); } + } }