### Question:
EntityUtils { public static int deleteNodeAndRelationships(Node toDelete) { int result = 0; for (Relationship relationship : toDelete.getRelationships()) { relationship.delete(); result++; } toDelete.delete(); return result; } private  EntityUtils(); static Map<Long, T> entitiesToMap(Collection<T> entities); static Long[] ids(Iterable<? extends Entity> entities); static String valueToString(Object value); static Map<String, Object> propertiesToMap(Entity Entity); static Map<String, Object> propertiesToMap(Entity Entity, ObjectInclusionPolicy<String> propertyInclusionPolicy); static int deleteNodeAndRelationships(Node toDelete); static String nodeToString(Node node); static String relationshipToString(Relationship relationship); static String propertiesToString(Entity Entity); static int getInt(Entity Entity, String key); static int getInt(Entity Entity, String key, int defaultValue); static long getLong(Entity Entity, String key); static long getLong(Entity Entity, String key, long defaultValue); static float getFloat(Entity Entity, String key); static float getFloat(Entity Entity, String key, float defaultValue);  }### Answer:
@Test public void shouldDeleteNodeWithAllRelationships() { database.shutdown(); database = new TestGraphDatabaseFactory().newImpermanentDatabase(); registerShutdownHook(database); database.execute("CREATE " + "(a), " + "(b {name:'node1'})," + "(c {name:'node2'})," + "(c)-[:test {key1:'value1'}]->(b)," + "(c)-[:test {key1:'value1'}]->(a)"); try (Transaction tx = database.beginTx()) { assertEquals(2, deleteNodeAndRelationships(database.getNodeById(2))); tx.success(); } }