|
19 | 19 | */ |
20 | 20 | package org.neo4j.gds.betweenness; |
21 | 21 |
|
| 22 | +import org.assertj.core.data.Offset; |
22 | 23 | import org.junit.jupiter.api.BeforeEach; |
23 | 24 | import org.junit.jupiter.api.Test; |
24 | 25 | import org.neo4j.gds.BaseProcTest; |
|
30 | 31 | import org.neo4j.gds.extension.Neo4jGraph; |
31 | 32 | import org.neo4j.graphdb.QueryExecutionException; |
32 | 33 |
|
33 | | -import java.util.List; |
34 | 34 | import java.util.Map; |
35 | 35 |
|
| 36 | +import static org.assertj.core.api.Assertions.assertThat; |
36 | 37 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
| 38 | +import static org.assertj.core.api.InstanceOfAssertFactories.DOUBLE; |
37 | 39 |
|
38 | 40 | class BetweennessCentralityStreamProcTest extends BaseProcTest { |
39 | 41 |
|
@@ -76,15 +78,26 @@ void testStream() { |
76 | 78 | .streamMode() |
77 | 79 | .yields(); |
78 | 80 |
|
79 | | - assertCypherResult( |
80 | | - query, |
81 | | - List.of( |
82 | | - Map.of("nodeId", idFunction.of("a"), "score", 0.0), |
83 | | - Map.of("nodeId", idFunction.of("b"), "score", 3.0), |
84 | | - Map.of("nodeId", idFunction.of("c"), "score", 4.0), |
85 | | - Map.of("nodeId", idFunction.of("d"), "score", 3.0), |
86 | | - Map.of("nodeId", idFunction.of("e"), "score", 0.0) |
87 | | - )); |
| 81 | + var expectedResultMap = Map.of( |
| 82 | + idFunction.of("a"), 0.0, |
| 83 | + idFunction.of("b"), 3.0, |
| 84 | + idFunction.of("c"), 4.0, |
| 85 | + idFunction.of("d"), 3.0, |
| 86 | + idFunction.of("e"), 0.0 |
| 87 | + ); |
| 88 | + |
| 89 | + var rowCount = runQueryWithRowConsumer(query, (resultRow) -> { |
| 90 | + |
| 91 | + var nodeId = resultRow.getNumber("nodeId"); |
| 92 | + var expectedScore = expectedResultMap.get(nodeId); |
| 93 | + |
| 94 | + assertThat(resultRow.getNumber("score")).asInstanceOf(DOUBLE).isCloseTo( |
| 95 | + expectedScore, |
| 96 | + Offset.offset(1e-6) |
| 97 | + ); |
| 98 | + |
| 99 | + }); |
| 100 | + assertThat(rowCount).isEqualTo(5l); |
88 | 101 | } |
89 | 102 |
|
90 | 103 | // FIXME: This should not be tested here |
|
0 commit comments