Usage


You can use the Data Generator as a unmanged plugin or in a unit test scenario. Since version 3+ of neo4j it is also possible to use fkr functions and procedures this is explained in the readme.
 

Unmanaged Plugin

To getting started do the following:
  1. Download the latest release from github
  2. Unzip the distribution zip file into a directory
  3. Copy all the contents of the dist directory to the neo4j server plugin directory
  4. Register the unmanaged plugin on the neo4j server
    You have to add the following line to your neo4j.conf file
    dbms.unmanaged_extension_classes=org.neo4j.faker.ump=/testdata

    For convenience you can disable the authentication. The curl examples in this documentation are without authentication.

    dbms.security.authorization_enabled=false
  5. (re) Start the neo4j server
  6. Test the plugin

    Test the availability of the plugin by calling it with a non existing property file name from you local browser

    http://127.0.0.1:7474/testdata/tdg/pfile/test.props

    The browser will now give an error message stating that the file test.props cannot be found.

You are now ready to create your own property files in the ddgres directory. You can use the help or use an already existing load definition file as a template.

In a typical scenario multiple load definition files are created to generate a data set. Keep the load definition files small!

As you have seen above, the unmanaged plugin is called via an url. However to make scripts which call the ump you can make use of curl. Curl will display the text returned as soon as the ump puts it in the response. The browser instead may wait with showing the response until the processing is finished.

The url to call the plugin is build up as follows:

http://localhost:7474/testdata/tdg/pfile/[load definition file name]

To load an example data set you can use the following curl line. Note this will actual load data into the database!

curl -g http://localhost:7474/testdata/tdg/pfile/tdgexample.props


Version 0.9.1 of neo4j-faker must run on Neo4j version 4 and higher. Neo4j version 4 can run multiple databases at the same time. You can specify in the url the parameter 'dbname' to generate data in that specific database.
If ommitted then the default database will be taken.

f
curl -g http://localhost:7474/testdata/tdg/pfile/tdgexample.props?dbname=mydb

Embedded

It is possible to Use the TestDataLoader with the following constructors
public TestDataLoader(GraphDatabaseService database
		    ,Properties genProperties
		    ,ExecutionEngine engine
		    ,Writer writer
		    ,String TDGRoot) 

or

public TestDataLoader(GraphDatabaseService database
		    ,Properties genProperties
		    ,ExecutionEngine engine
		    ,String TDGRoot) 

The TDGRoot is a filepath to the parent directory of the ddgres directory

If the call is done without the Writer, then the output will be placed in the system output


Here a coding example:

	
    String tdgroot = "/opt/test/tdg";// this is the test datagen 'root' directory.
    String propsOne = "fraud_one.props";
    String propsTwo = "fraud_two.props";
    String propsThree = "fraud_three.props";
    TestDataLoader tdg = new TestDataLoader(database, TDGUtils.loadProperties(tdgroot, propsOne), engine, tdgroot);
    tdg.loadData();
    tdg = new TestDataLoader(database, TDGUtils.loadProperties(tdgroot, propsTwo), engine, tdgroot);
    tdg.loadData();
    tdg = new TestDataLoader(database, TDGUtils.loadProperties(tdgroot, propsThree), engine, tdgroot);
    tdg.loadData();

	

File Descriptions

All the files and directories are in the plugins directory of the neo4j server. Or an to be configured directory when using the tool embedded.

    doc/                          : Directory with the help files for the Data Generator.

    dist/neo4jFaker-<version>.jar : The logic for the test data generator

    dist/ddgres/                  : Directory for all the resources. Property and list files.
    
    dist/ddgres/First_Names.csv   : Used by the person name generator
    dist/ddgres/Last_Names.csv    : Used by the person name generator
    
    dist/ddgres/cities.txt        : A list with distinct US city names.
                                    Used in the example.
    dist/ddgres/tdgexample.props  : This is an example test data definition file