### Question:
RelationshipUtils { public static void deleteRelationshipIfExists(Node node1, Node node2, RelationshipType type, Direction direction) { Relationship r = getSingleRelationshipOrNull(node1, node2, type, direction); if (r != null) { r.delete(); } } private  RelationshipUtils(); static Relationship getSingleRelationship(Node node1, Node node2, RelationshipType type, Direction direction); static Relationship getSingleRelationshipOrNull(Node node1, Node node2, RelationshipType type, Direction direction); static boolean relationshipNotExists(Node node1, Node node2, RelationshipType type, Direction direction); static boolean relationshipExists(Node node1, Node node2, RelationshipType type, Direction direction); static void deleteRelationshipIfExists(Node node1, Node node2, RelationshipType type, Direction direction); static Relationship createRelationshipIfNotExists(Node node1, Node node2, RelationshipType type, Direction direction);  }### Answer:
@Test public void existingRelationshipShouldBeDeleted() { try (Transaction tx = database.beginTx()) { Node node1 = database.getNodeById(0); Node node2 = database.getNodeById(1); deleteRelationshipIfExists(node1, node2, withName("TEST"), OUTGOING); assertEquals(0, IterableUtils.count(database.getAllRelationships())); tx.success(); } }
@Test public void nonExistingRelationshipDeletionShouldDoNothing() { try (Transaction tx = database.beginTx()) { Node node1 = database.getNodeById(0); Node node2 = database.getNodeById(1); deleteRelationshipIfExists(node2, node1, withName("TEST"), OUTGOING); assertEquals(1, IterableUtils.count(database.getAllRelationships())); tx.success(); } }