assertEquals(8L, getTotalFriendshipStrength(database));
}
@Test
public void totalFriendshipStrengthShouldBeCountedUsingCypher() {
ExecutionEngine executionEngine = new ExecutionEngine(database);
executionEngine.execute("CREATE " +
"(p1:Person), (p2:Person), (p3:Person)," +
"(p1)-[:FRIEND_OF {strength:3}]->(p2)," +
"(p2)-[:FRIEND_OF {strength:1}]->(p1)," +
"(p1)-[:FRIEND_OF {strength:2}]->(p3)");
String query = "MATCH (c:FriendshipCounter) RETURN c.totalFriendshipStrength as result";
for (Map<String, Object> result : executionEngine.execute(query)) {
assertEquals(6L, result.get("result"));
}
executionEngine.execute("MATCH (p1:Person)-[f:FRIEND_OF {strength:3}]->(p2) DELETE f");
for (Map<String, Object> result : executionEngine.execute(query)) {
assertEquals(3L, result.get("result"));
}
}