19
19
*/
20
20
package org .neo4j .gds .pagerank ;
21
21
22
- import org .junit .jupiter .api .Test ;
22
+ import org .junit .jupiter .params .ParameterizedTest ;
23
+ import org .junit .jupiter .params .provider .Arguments ;
24
+ import org .junit .jupiter .params .provider .MethodSource ;
23
25
import org .neo4j .gds .api .GraphStore ;
24
26
import org .neo4j .gds .extension .GdlExtension ;
25
27
import org .neo4j .gds .extension .GdlGraph ;
26
28
import org .neo4j .gds .extension .Inject ;
27
29
28
30
import java .util .List ;
31
+ import java .util .stream .Stream ;
29
32
30
33
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
34
+ import static org .junit .jupiter .params .provider .Arguments .arguments ;
31
35
32
36
@ GdlExtension
33
- public class PageRankConfigTest {
37
+ class PageRankConfigTest {
34
38
35
39
@ GdlGraph
36
40
private static final String DB_CYPHER =
@@ -39,20 +43,41 @@ public class PageRankConfigTest {
39
43
" (b:node)," +
40
44
"(a)-[:R]->(b)" ;
41
45
42
-
43
46
@ Inject
44
47
private GraphStore graphStore ;
45
48
46
- @ Test
47
- void shouldNotAllowNegativeSourceNodes () {
48
- assertThatThrownBy (() -> PageRankStreamConfigImpl .builder ().sourceNodes (List .of (-1337 )).build ())
49
- .hasMessageContaining ("Negative node ids are not supported for the field `sourceNodes`" );
49
+ static Stream <Arguments > negativeSourceNodes () {
50
+ return Stream .of (
51
+ arguments (-1337 ),
52
+ arguments (List .of (-1337 )),
53
+ arguments (List .of (List .of (-1337 , 1.0 )))
54
+ );
55
+ }
56
+
57
+ @ ParameterizedTest
58
+ @ MethodSource ("negativeSourceNodes" )
59
+ void shouldNotAllowNegativeSourceNodes (Object sourceNodes ) {
60
+ assertThatThrownBy (() -> PageRankStreamConfigImpl
61
+ .builder ()
62
+ .sourceNodes (sourceNodes )
63
+ .build ()
64
+ ).hasMessageContaining ("Negative node ids are not supported for the field `sourceNodes`" );
50
65
}
51
66
52
- @ Test
53
- void shouldNotAllowNonExistantSourceNodes () {
67
+ static Stream <Arguments > invalidSourceNodes () {
68
+ return Stream .of (
69
+ arguments (421337 ),
70
+ arguments (List .of (421337 )),
71
+ arguments (List .of (List .of (421337 , 1.0 )))
72
+ );
73
+ }
74
+
75
+
76
+ @ ParameterizedTest
77
+ @ MethodSource ("invalidSourceNodes" )
78
+ void shouldNotAllowNonExistantSourceNodes (Object sourceNodes ) {
54
79
var config = PageRankStreamConfigImpl .builder ()
55
- .sourceNodes (List . of ( 421337 ) ).build ();
80
+ .sourceNodes (sourceNodes ).build ();
56
81
57
82
assertThatThrownBy (() -> config .graphStoreValidation (
58
83
graphStore ,
0 commit comments