Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-14-2020 06:52 AM
Hi guys.
I'm trying to debug a user defined procedure using the test harness as described by Max De Marzi's blog. I'm struggling with adding test data to debug against.
Does the test harness require the data fixture to be embedded in java as a string? I have found no other way (that works) to load data to the harness other than calling .withFixture(String MODEL_STATEMENT)
where that model statement is a single cypher statement.
I attempted to load exported cypher scripts files (using apoc) from other databases but those scripts are not compatible with withFixture(File cypherFile)
unless there is exactly one cypher statement in the file.
Using .copyFrom(File sourceDirectory)
does not load the databases in the folders (properly setup according to the now working javadocs as data/databases/neo4j).
Even if I wanted to launch the Harness and use apoc to execute the exported cypher to preload data during initialization, the harness would have no access to the cypher script file as there's no way to mount the folder or copy the file in.
I'm coming to the conclusion that if I want to debug any stored procedure in Neo4j that leverages apoc, it requires this:
Am I missing something?
Edit: I was able to load the cypher script file by splitting it by semicolon and line separator:
@BeforeAll
static void initialize() throws URISyntaxException, IOException {
var pluginDirContainingApocJar = new File(
ApocConfig.class.getProtectionDomain().getCodeSource().getLocation().toURI())
.getParentFile().toPath();
var builder = Neo4jBuilders.newInProcessBuilder()
.withDisabledServer()
.withConfig(GraphDatabaseSettings.plugin_dir, pluginDirContainingApocJar)
.withConfig(GraphDatabaseSettings.procedure_unrestricted, List.of("apoc.*"))
.withConfig(ApocSettings.apoc_import_file_enabled, true)
.withConfig(ApocSettings.apoc_export_file_enabled, true)
.withFunction(MyFunction.class);
Path cypherScript = Path.of("/import/export-plain.cypher");
String fileContents = Files.readString(cypherScript);
List<String> statements = Arrays.asList(fileContents.split(";\n"));
for (String statement : statements) {
builder.withFixture(statement);
}
neo4j = builder.build();
}
10-15-2020 11:08 AM
not sure if this is still relevant but you can
A. ,
B.
File f = new File("....\\data");
this.embeddedDatabaseServer = TestServerBuilders
.newInProcessBuilder()
.copyFrom(f)
.withFunction(MyFunction.class)
.newServer();
then step into your breakpoints ( of course make sure that your apoc lib is a system dependency )
All the sessions of the conference are now available online