@@ -61,6 +61,22 @@ void shouldAcceptValidSourceNodeFilter() {
6161 );
6262 }
6363
64+ @ Test
65+ void shouldAcceptValidTargetNodeFilter () {
66+ new FilteredKnnBaseConfigImpl (
67+ CypherMapWrapper .create (
68+ Map .of (
69+ "nodeProperties" , List .of ("dummy" ),
70+ "targetNodeFilter" , List .of (idFunction .of ("a" ))
71+ )
72+ )
73+ ).validateSourceNodeFilter (
74+ graphStore ,
75+ List .of (),
76+ List .of ()
77+ );
78+ }
79+
6480 @ Test
6581 void shouldRejectOutOfRangeSourceNodeFilter () {
6682 var outOfRangeNode = -1L ;
@@ -77,6 +93,22 @@ void shouldRejectOutOfRangeSourceNodeFilter() {
7793 .hasMessage ("Value for `sourceNodeFilter` was `" + outOfRangeNode + "`, but must be within the range [0, 9223372036854775807]." );
7894 }
7995
96+ @ Test
97+ void shouldRejectOutOfRangeTargetNodeFilter () {
98+ var outOfRangeNode = -1L ;
99+ assertThatThrownBy (
100+ () -> new FilteredKnnBaseConfigImpl (
101+ CypherMapWrapper .create (
102+ Map .of (
103+ "nodeProperties" , List .of ("dummy" ),
104+ "targetNodeFilter" , List .of (outOfRangeNode )
105+ )
106+ )
107+ )
108+ ).isInstanceOf (IllegalArgumentException .class )
109+ .hasMessage ("Value for `targetNodeFilter` was `" + outOfRangeNode + "`, but must be within the range [0, 9223372036854775807]." );
110+ }
111+
80112 @ Test
81113 void shouldRejectSourceNodeFilterWithMissingNode () {
82114 //noinspection OptionalGetWithoutIsPresent
@@ -106,4 +138,34 @@ void shouldRejectSourceNodeFilterWithMissingNode() {
106138 .hasMessage (
107139 "Invalid configuration value 'sourceNodeFilter', the following nodes are missing from the graph: [" + missingNode + "]" );
108140 }
141+
142+ @ Test
143+ void shouldRejectTargetNodeFilterWithMissingNode () {
144+ //noinspection OptionalGetWithoutIsPresent
145+ var missingNode = new Random ()
146+ .longs (
147+ 0 ,
148+ 4_294_967_295L // a large-ish number that still fits in our id maps (Math.pow(2, 32) - 1)
149+ ).filter (l -> !graphStore .nodes ().contains (l ))
150+ .limit (1 )
151+ .findFirst ()
152+ .getAsLong ();
153+
154+ assertThatThrownBy (
155+ () -> new FilteredKnnBaseConfigImpl (
156+ CypherMapWrapper .create (
157+ Map .of (
158+ "nodeProperties" , List .of ("dummy" ),
159+ "targetNodeFilter" , List .of (idFunction .of ("a" ), missingNode ) // one existing, one missing
160+ )
161+ )
162+ ).validateTargetNodeFilter (
163+ graphStore ,
164+ List .of (),
165+ List .of ()
166+ )
167+ ).isInstanceOf (IllegalArgumentException .class )
168+ .hasMessage (
169+ "Invalid configuration value 'targetNodeFilter', the following nodes are missing from the graph: [" + missingNode + "]" );
170+ }
109171}
0 commit comments