1212import java .io .File ;
1313import java .io .IOException ;
1414import java .nio .charset .StandardCharsets ;
15+ import java .util .ArrayList ;
1516import java .util .Collections ;
1617import java .util .List ;
1718import java .util .Map ;
3132 */
3233public class StartupExtendedTest {
3334 private static final String APOC_HELP_QUERY = "CALL apoc.help('') YIELD core, type, name WHERE core = $core and type = $type RETURN name" ;
34- private static final List <String > EXPECTED_EXTENDED_NAMES ;
35+ private static final List <String > EXPECTED_EXTENDED_NAMES_CYPHER_5 ;
36+ private static final List <String > EXPECTED_EXTENDED_NAMES_CYPHER_25 ;
3537
3638 static {
37- // retrieve every extended procedure and function via the extended.txt file
38- final File extendedFile = new File (TestContainerUtil .extendedDir , "src/main/resources/extended.txt" );
39+ // retrieve every extended procedure and function via the extendedCypher5.txt file
40+ final File extendedFileCypher5 = new File (TestContainerUtil .extendedDir , "src/main/resources/extendedCypher5.txt" );
41+ final File extendedFileCypher25 = new File (TestContainerUtil .extendedDir , "src/main/resources/extendedCypher25.txt" );
3942 try {
40- EXPECTED_EXTENDED_NAMES = FileUtils .readLines (extendedFile , StandardCharsets .UTF_8 );
43+ EXPECTED_EXTENDED_NAMES_CYPHER_5 = FileUtils .readLines (extendedFileCypher5 , StandardCharsets .UTF_8 );
44+ EXPECTED_EXTENDED_NAMES_CYPHER_25 = FileUtils .readLines (extendedFileCypher25 , StandardCharsets .UTF_8 );
4145 } catch (IOException e ) {
4246 throw new RuntimeException (e );
4347 }
@@ -48,32 +52,37 @@ public void checkCoreAndExtendedWithExtraDependenciesJars() {
4852 // we check that with apoc-extended, apoc-core jar and all extra-dependencies jars every procedure/function is detected
4953 startContainerSessionWithExtraDeps ((version ) -> createDB (version , List .of (CORE , EXTENDED ), true ),
5054 session -> {
51- checkCoreProcsAndFuncsExistence (session );
5255
5356 // all full procedures and functions are present, also the ones which require extra-deps, e.g. the apoc.export.xls.*
54- final List <String > actualExtNames = getNames (session , APOC_HELP_QUERY ,
55- Map .of ("core" , false , "type" , "function" ) );
56- final List <String > functionExtNames = getNames (session , APOC_HELP_QUERY ,
57- Map .of ("core" , false , "type" , "procedure" ) );
58-
59- actualExtNames .addAll (functionExtNames );
60-
61- assertEquals (sorted (EXPECTED_EXTENDED_NAMES ), sorted (actualExtNames ));
57+ checkExtendedProcsAndFuncsExistence (session );
58+ checkCoreProcsAndFuncsExistence (session );
6259 });
6360 }
6461
6562 @ Test
6663 public void checkExtendedWithExtraDependenciesJars () {
6764 // we check that with apoc-extended jar and all extra-dependencies jars every procedure/function is detected
65+ // all full procedures and functions are present, also the ones which require extra-deps, e.g. the apoc.export.xls.*
6866 startContainerSessionWithExtraDeps ((version ) -> createDB (version , List .of (EXTENDED ), true ),
6967 session -> {
7068 // all full procedures and functions are present, also the ones which require extra-deps, e.g. the apoc.export.xls.*
71- final List <String > actualExtNames = getNames (session , "SHOW PROCEDURES YIELD name WHERE name STARTS WITH 'apoc.' RETURN name" );
72- final List <String > functionExtNames = getNames (session , "SHOW FUNCTIONS YIELD name WHERE name STARTS WITH 'apoc.' RETURN name" );
73-
74- actualExtNames .addAll (functionExtNames );
75-
76- assertEquals (sorted (EXPECTED_EXTENDED_NAMES ), sorted (actualExtNames ));
69+ final List <String > actualExtNamesCypher5 = getNames (session , "CYPHER 5 SHOW PROCEDURES YIELD name WHERE name STARTS WITH 'apoc.' RETURN name" );
70+ final List <String > functionExtNamesCypher5 = getNames (session , "CYPHER 5 SHOW FUNCTIONS YIELD name WHERE name STARTS WITH 'apoc.' RETURN name" );
71+
72+ List <String > procsAndFuncsCypher5 = new ArrayList <>();
73+ procsAndFuncsCypher5 .addAll (actualExtNamesCypher5 );
74+ procsAndFuncsCypher5 .addAll (functionExtNamesCypher5 );
75+
76+ assertEquals (sorted (EXPECTED_EXTENDED_NAMES_CYPHER_5 ), sorted (procsAndFuncsCypher5 ));
77+
78+ final List <String > actualExtNamesCypher25 = getNames (session , "CYPHER 25 SHOW PROCEDURES YIELD name WHERE name STARTS WITH 'apoc.' RETURN name" );
79+ final List <String > functionExtNamesCypher25 = getNames (session , "CYPHER 25 SHOW FUNCTIONS YIELD name WHERE name STARTS WITH 'apoc.' RETURN name" );
80+
81+ List <String > procsAndFuncsCypher25 = new ArrayList <>();
82+ procsAndFuncsCypher25 .addAll (actualExtNamesCypher25 );
83+ procsAndFuncsCypher25 .addAll (functionExtNamesCypher25 );
84+
85+ assertEquals (sorted (EXPECTED_EXTENDED_NAMES_CYPHER_25 ), sorted (procsAndFuncsCypher25 ));
7786 });
7887 }
7988
@@ -88,7 +97,9 @@ private void startContainerSessionWithExtraDeps(Function<Neo4jVersion, Neo4jCont
8897 Consumer <Session > sessionConsumer ) {
8998 for (var version : Neo4jVersion .values ()) {
9099
91- try (final Neo4jContainerExtension neo4jContainer = neo4jContainerCreation .apply (version )) {
100+ try (final Neo4jContainerExtension neo4jContainer = neo4jContainerCreation .apply (version )
101+ .withNeo4jConfig ("internal.dbms.cypher.enable_experimental_versions" , "true" )
102+ ) {
92103 // add extra-deps before starting it
93104 ExtendedTestContainerUtil .addExtraDependencies ();
94105 neo4jContainer .start ();
@@ -110,14 +121,47 @@ private void startContainerSessionWithExtraDeps(Function<Neo4jVersion, Neo4jCont
110121 }
111122
112123 private void checkCoreProcsAndFuncsExistence (Session session ) {
113- final List <String > functionNames = getNames (session , APOC_HELP_QUERY ,
124+ final List <String > functionCypher5Names = getNames (session , "CYPHER 5 " + APOC_HELP_QUERY ,
125+ Map .of ("core" , true , "type" , "function" ) );
126+
127+ final List <String > procedureCypher5Names = getNames (session , "CYPHER 5 " + APOC_HELP_QUERY ,
128+ Map .of ("core" , true , "type" , "procedure" ) );
129+
130+ assertEquals (sorted (ApocSignatures .PROCEDURES_CYPHER_5 ), procedureCypher5Names );
131+ assertEquals (sorted (ApocSignatures .FUNCTIONS_CYPHER_5 ), functionCypher5Names );
132+
133+ final List <String > functionCypher25Names = getNames (session , "CYPHER 25 " + APOC_HELP_QUERY ,
114134 Map .of ("core" , true , "type" , "function" ) );
115135
116- final List <String > procedureNames = getNames (session , APOC_HELP_QUERY ,
136+ final List <String > procedureCypher25Names = getNames (session , "CYPHER 25 " + APOC_HELP_QUERY ,
117137 Map .of ("core" , true , "type" , "procedure" ) );
118138
119- assertEquals (sorted (ApocSignatures .PROCEDURES ), procedureNames );
120- assertEquals (sorted (ApocSignatures .FUNCTIONS ), functionNames );
139+ assertEquals (sorted (ApocSignatures .PROCEDURES_CYPHER_25 ), procedureCypher25Names );
140+ assertEquals (sorted (ApocSignatures .FUNCTIONS_CYPHER_25 ), functionCypher25Names );
141+ }
142+
143+ private void checkExtendedProcsAndFuncsExistence (Session session ) {
144+ // all full procedures and functions are present, also the ones which require extra-deps, e.g. the apoc.export.xls.*
145+ final List <String > actualExtNamesCypher5 = getNames (session , "CYPHER 5 " + APOC_HELP_QUERY ,
146+ Map .of ("core" , false , "type" , "function" ) );
147+ final List <String > functionExtNamesCypher5 = getNames (session , "CYPHER 5 " + APOC_HELP_QUERY ,
148+ Map .of ("core" , false , "type" , "procedure" ) );
149+
150+ final List <String > actualExtNamesCypher25 = getNames (session , "CYPHER 25 " + APOC_HELP_QUERY ,
151+ Map .of ("core" , false , "type" , "function" ) );
152+ final List <String > functionExtNamesCypher25 = getNames (session , "CYPHER 25 " + APOC_HELP_QUERY ,
153+ Map .of ("core" , false , "type" , "procedure" ) );
154+
155+ List <String > procsAndFuncsCypher5 = new ArrayList <>();
156+ procsAndFuncsCypher5 .addAll (actualExtNamesCypher5 );
157+ procsAndFuncsCypher5 .addAll (functionExtNamesCypher5 );
158+
159+ List <String > procsAndFuncsCypher25 = new ArrayList <>();
160+ procsAndFuncsCypher25 .addAll (actualExtNamesCypher25 );
161+ procsAndFuncsCypher25 .addAll (functionExtNamesCypher25 );
162+
163+ assertEquals (sorted (EXPECTED_EXTENDED_NAMES_CYPHER_5 ), sorted (procsAndFuncsCypher5 ));
164+ assertEquals (sorted (EXPECTED_EXTENDED_NAMES_CYPHER_25 ), sorted (procsAndFuncsCypher25 ));
121165 }
122166
123167 private static List <String > getNames (Session session , String query , Map <String , Object > params ) {
0 commit comments