### Question:
DirectionUtils { public static boolean matches(Relationship relationship, Node pointOfView, Direction direction) { return matches(direction, resolveDirection(relationship, pointOfView, BOTH)); } private  DirectionUtils(); static Direction resolveDirection(Relationship relationship, Node pointOfView); static Direction resolveDirection(Relationship relationship, Node pointOfView, Direction defaultDirection); static Direction resolveDirection(AttachedRelationshipExpressions<?> relationship, AttachedNodeExpressions pointOfView, Direction defaultDirection); static boolean matches(Relationship relationship, Node pointOfView, Direction direction); static boolean matches(Direction direction1, Direction direction2); static Direction reverse(Direction direction);  }### Answer:
@Test public void verifyMatching() { try (Transaction tx = database.beginTx()) { Node nodeThree = database.getNodeById(2); Relationship selfRelationship = nodeThree.getSingleRelationship(withName("test"), OUTGOING); assertTrue(matches(selfRelationship, nodeThree, OUTGOING)); assertTrue(matches(selfRelationship, nodeThree, INCOMING)); assertTrue(matches(selfRelationship, nodeThree, BOTH)); Node nodeOne = database.getNodeById(0); Node nodeTwo = database.getNodeById(1); Relationship relationship = nodeOne.getSingleRelationship(withName("test"), OUTGOING); assertTrue(matches(relationship, nodeOne, OUTGOING)); assertTrue(matches(relationship, nodeOne, BOTH)); assertFalse(matches(relationship, nodeOne, INCOMING)); assertTrue(matches(relationship, nodeTwo, INCOMING)); assertTrue(matches(relationship, nodeTwo, BOTH)); assertFalse(matches(relationship, nodeTwo, OUTGOING)); } }
@Test public void verifyMatching2() { assertTrue(matches(BOTH, OUTGOING)); assertTrue(matches(BOTH, INCOMING)); assertTrue(matches(INCOMING, BOTH)); assertTrue(matches(OUTGOING, BOTH)); assertTrue(matches(BOTH, BOTH)); assertTrue(matches(INCOMING, INCOMING)); assertTrue(matches(OUTGOING, OUTGOING)); assertFalse(matches(INCOMING, OUTGOING)); assertFalse(matches(OUTGOING, INCOMING)); }
@Test(expected = IllegalArgumentException.class) public void verifyIncorrectMatching() { try (Transaction tx = database.beginTx()) { Relationship relationship = database.getNodeById(0).getSingleRelationship(withName("test"), OUTGOING); matches(relationship, database.getNodeById(2), OUTGOING); } }