22
22
import org .junit .jupiter .api .Test ;
23
23
import org .neo4j .gds .NodeLabel ;
24
24
import org .neo4j .gds .RelationshipType ;
25
- import org .neo4j .gds .api .Graph ;
26
- import org .neo4j .gds .api .GraphStore ;
25
+ import org .neo4j .gds .TestSupport ;
27
26
import org .neo4j .gds .core .huge .HugeGraph ;
28
- import org .neo4j .gds .extension .GdlExtension ;
29
- import org .neo4j .gds .extension .GdlGraph ;
30
- import org .neo4j .gds .extension .Inject ;
31
27
import org .neo4j .kernel .database .DatabaseIdFactory ;
32
28
33
29
import java .util .Optional ;
34
30
import java .util .UUID ;
35
31
36
32
import static org .assertj .core .api .Assertions .assertThat ;
33
+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
37
34
import static org .neo4j .gds .TestSupport .assertGraphEquals ;
38
35
39
- @ GdlExtension
40
36
class CSRGraphStoreUtilTest {
41
37
42
- @ GdlGraph
43
- public static final String GDL =
44
- " CREATE" +
45
- " (a:A { foo: 42, bar: 1337 })" +
46
- ", (b:A { foo: 84, bar: 1234 })" +
47
- ", (c:B { foo: 23 })" +
48
- // Add one relationship type with a single property
49
- // to ensure that the graph is a HugeGraph.
50
- ", (a)-[:REL1 { prop1: 42 }]->(b)" ;
51
-
52
- @ Inject
53
- private GraphStore graphStore ;
54
-
55
- @ Inject
56
- private Graph graph ;
57
-
58
38
@ Test
59
39
void fromGraph () {
40
+ String GDL =
41
+ " CREATE" +
42
+ " (a:A { foo: 42, bar: 1337 })" +
43
+ ", (b:A { foo: 84, bar: 1234 })" +
44
+ ", (c:B { foo: 23 })" +
45
+ // Add one relationship type with a single property
46
+ // to ensure that the graph is a HugeGraph.
47
+ ", (a)-[:REL1 { prop1: 42 }]->(b)" ;
48
+
49
+ var graphStore = TestSupport .graphStoreFromGDL (GDL );
50
+ var graph = graphStore .getUnion ();
60
51
assertThat (graph ).isInstanceOf (HugeGraph .class );
61
52
assertThat (graph .availableNodeLabels ()).contains (NodeLabel .of ("A" ), NodeLabel .of ("B" ));
62
53
assertThat (graph .availableNodeProperties ()).contains ("foo" , "bar" );
@@ -74,4 +65,20 @@ void fromGraph() {
74
65
assertGraphEquals (graphStore .getUnion (), convertedGraphStore .getUnion ());
75
66
}
76
67
68
+ @ Test
69
+ void shouldValidateRelationshipPropertyKey () {
70
+ var graph = TestSupport .fromGdl ("()-[:REL]->()" );
71
+
72
+ assertThatThrownBy (() -> {
73
+ CSRGraphStoreUtil .createFromGraph (
74
+ DatabaseIdFactory .from ("dummy" , UUID .fromString ("42-42-42-42-42" )),
75
+ (HugeGraph ) graph .innerGraph (),
76
+ "REL" ,
77
+ Optional .of ("prop1" ),
78
+ 1
79
+ );
80
+ })
81
+ .hasMessage ("Relationship property name 'prop1' does not exist in the graph." );
82
+ }
83
+
77
84
}
0 commit comments