|
29 | 29 | import org.neo4j.gds.extension.Inject; |
30 | 30 | import org.neo4j.gds.extension.Neo4jGraph; |
31 | 31 |
|
32 | | -import java.util.List; |
33 | 32 | import java.util.Map; |
34 | 33 |
|
35 | 34 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -83,8 +82,19 @@ void setup() throws Exception { |
83 | 82 | @Test |
84 | 83 | void shouldWrite(){ |
85 | 84 |
|
86 | | - String query="CALL gds.kcore.write('graph', { writeProperty: 'coreValue'})"; |
87 | 85 |
|
| 86 | + String query="CALL gds.kcore.write('graph', { writeProperty: 'coreValue'})"; |
| 87 | + var expectedResultMap = Map.of |
| 88 | + (idFunction.of("z"), 0L, |
| 89 | + idFunction.of("a"), 1L, |
| 90 | + idFunction.of("b"), 1L, |
| 91 | + idFunction.of("c"), 2L, |
| 92 | + idFunction.of("d"), 2L, |
| 93 | + idFunction.of("e"), 2L, |
| 94 | + idFunction.of("f"), 2L, |
| 95 | + idFunction.of("g"), 2L, |
| 96 | + idFunction.of("h"), 2L |
| 97 | + ); |
88 | 98 | var rowCount = runQueryWithRowConsumer(query, row -> { |
89 | 99 |
|
90 | 100 | assertThat(row.getNumber("preProcessingMillis")) |
@@ -127,20 +137,15 @@ void shouldWrite(){ |
127 | 137 | .as("`write` mode should always return one row") |
128 | 138 | .isEqualTo(1); |
129 | 139 |
|
130 | | - assertCypherResult( |
| 140 | + var verificationRowCount = runQueryWithRowConsumer( |
131 | 141 | "MATCH (n:node) RETURN id(n) AS nodeId, n.coreValue AS coreValue", |
132 | | - List.of( |
133 | | - Map.of("nodeId", idFunction.of("z"), "coreValue", 0L), |
134 | | - Map.of("nodeId", idFunction.of("a"), "coreValue", 1L), |
135 | | - Map.of("nodeId", idFunction.of("b"), "coreValue", 1L), |
136 | | - Map.of("nodeId", idFunction.of("c"), "coreValue", 2L), |
137 | | - Map.of("nodeId", idFunction.of("d"), "coreValue", 2L), |
138 | | - Map.of("nodeId", idFunction.of("e"), "coreValue", 2L), |
139 | | - Map.of("nodeId", idFunction.of("f"), "coreValue", 2L), |
140 | | - Map.of("nodeId", idFunction.of("g"), "coreValue", 2L), |
141 | | - Map.of("nodeId", idFunction.of("h"), "coreValue", 2L) |
142 | | - ) |
| 142 | + (resultRow) -> { |
| 143 | + var nodeId = resultRow.getNumber("nodeId"); |
| 144 | + var expected = expectedResultMap.get(nodeId); |
| 145 | + assertThat(resultRow.getNumber("coreValue")).asInstanceOf(LONG).isEqualTo(expected); |
| 146 | + } |
143 | 147 | ); |
| 148 | + assertThat(verificationRowCount).isEqualTo(9L); |
144 | 149 | } |
145 | 150 |
|
146 | 151 | @Test |
|
0 commit comments