3838import static org .hamcrest .MatcherAssert .assertThat ;
3939import static org .hamcrest .collection .IsCollectionWithSize .hasSize ;
4040import static org .hamcrest .text .MatchesPattern .matchesPattern ;
41+ import static org .junit .jupiter .api .Assertions .assertFalse ;
4142import static org .junit .jupiter .api .Assertions .assertThrows ;
43+ import static org .junit .jupiter .api .Assertions .assertTrue ;
4244import static org .neo4j .gds .ElementProjection .PROPERTIES_KEY ;
45+ import static org .neo4j .gds .RelationshipProjection .INDEX_INVERSE_KEY ;
4346import static org .neo4j .gds .RelationshipProjection .ORIENTATION_KEY ;
4447import static org .neo4j .gds .RelationshipProjection .TYPE_KEY ;
4548import static org .neo4j .gds .RelationshipType .ALL_RELATIONSHIPS ;
@@ -54,7 +57,8 @@ void shouldParse() {
5457 "MY_TYPE" , Map .of (
5558 "type" , "T" ,
5659 "orientation" , "NATURAL" ,
57- "aggregation" , "SINGLE"
60+ "aggregation" , "SINGLE" ,
61+ "indexInverse" , true
5862 ));
5963 noProperties .put (
6064 "ANOTHER" , Map .of (
@@ -69,13 +73,20 @@ void shouldParse() {
6973 assertThat (projections .allProjections (), hasSize (2 ));
7074 assertThat (
7175 projections .getFilter (RelationshipType .of ("MY_TYPE" )),
72- equalTo (RelationshipProjection .of ("T" , Orientation .NATURAL , SINGLE ))
73- );
76+ equalTo (RelationshipProjection
77+ .builder ()
78+ .type ("T" )
79+ .aggregation (SINGLE )
80+ .orientation (Orientation .NATURAL )
81+ .indexInverse (true )
82+ .build ()
83+ ));
7484 assertThat (
7585 projections .getFilter (RelationshipType .of ("ANOTHER" )),
7686 equalTo (RelationshipProjection
7787 .builder ()
7888 .type ("FOO" )
89+ .indexInverse (false )
7990 .properties (PropertyMappings
8091 .builder ()
8192 .addMapping (PropertyMapping .of ("prop1" , DefaultValue .DEFAULT ))
@@ -221,6 +232,19 @@ void shouldSupportCaseInsensitiveConfigKeys() {
221232 assertThat (projections .typeFilter (), equalTo ("T|FOO" ));
222233 }
223234
235+ @ Test
236+ void shouldHandleIndexInverse () {
237+ // default
238+ var projection = RelationshipProjection .fromMap (Map .of (), RelationshipType .of ("FOO" ));
239+ assertFalse (projection .indexInverse ());
240+ // explicitly set
241+ projection = RelationshipProjection .fromMap (Map .of (INDEX_INVERSE_KEY , true ), RelationshipType .of ("FOO" ));
242+ assertTrue (projection .indexInverse ());
243+ // explicitly unset
244+ projection = RelationshipProjection .fromMap (Map .of (INDEX_INVERSE_KEY , false ), RelationshipType .of ("FOO" ));
245+ assertFalse (projection .indexInverse ());
246+ }
247+
224248 static Stream <Arguments > syntacticSugarsSimple () {
225249 return Stream .of (
226250 Arguments .of (
0 commit comments