### Question:
DirectionUtils { public static Direction resolveDirection(Relationship relationship, Node pointOfView) { return 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 outgoingShouldBeCorrectlyIdentified() { try (Transaction tx = database.beginTx()) { assertEquals(OUTGOING, resolveDirection(database.getNodeById(0).getSingleRelationship(withName("test"), OUTGOING), database.getNodeById(0))); } }
@Test public void incomingShouldBeCorrectlyIdentified() { try (Transaction tx = database.beginTx()) { assertEquals(INCOMING, resolveDirection(database.getNodeById(0).getSingleRelationship(withName("test"), OUTGOING), database.getNodeById(1))); } }
@Test public void relationshipToSelfShouldBeBoth() { try (Transaction tx = database.beginTx()) { assertEquals(BOTH, resolveDirection(database.getNodeById(2).getSingleRelationship(withName("test"), OUTGOING), database.getNodeById(2))); assertEquals(BOTH, resolveDirection(database.getNodeById(2).getSingleRelationship(withName("test"), INCOMING), database.getNodeById(2))); } }
@Test public void relationshipToSelfShouldHonourDefault() { try (Transaction tx = database.beginTx()) { assertEquals(OUTGOING, resolveDirection(database.getNodeById(2).getSingleRelationship(withName("test"), OUTGOING), database.getNodeById(2), OUTGOING)); assertEquals(OUTGOING, resolveDirection(database.getNodeById(2).getSingleRelationship(withName("test"), INCOMING), database.getNodeById(2), OUTGOING)); assertEquals(INCOMING, resolveDirection(database.getNodeById(2).getSingleRelationship(withName("test"), OUTGOING), database.getNodeById(2), INCOMING)); assertEquals(INCOMING, resolveDirection(database.getNodeById(2).getSingleRelationship(withName("test"), INCOMING), database.getNodeById(2), INCOMING)); } }
@Test(expected = IllegalArgumentException.class) public void invalidResolutionShouldThrowException() { try (Transaction tx = database.beginTx()) { resolveDirection((database.getNodeById(0).getSingleRelationship(withName("test"), OUTGOING)), database.getNodeById(2)); } }