Testing with GraphAware Timetree

五迷三道 提交于 2019-12-11 06:29:56

问题


I've been starting to use GraphAware timetree for neo4j, and so far its working out pretty well. Now I'm trying to work out how I can unit / integration test my code that uses neo4j timetree.

I've put together some code as below... but still I'm getting the message:

org.neo4j.ogm.exception.CypherException: Error executing Cypher "Neo.ClientError.Procedure.ProcedureNotFound"; Code: Neo.ClientError.Procedure.ProcedureNotFound; Description: There is no procedure with the name `ga.timetree.events.attach` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

Am I sort of on the right track?

package myproject.core;

import java.util.ArrayList;
import java.util.HashMap;

import javax.inject.Inject;

import org.junit.After;
import org.junit.runner.RunWith;
import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.neo4j.ogm.testutil.MultiDriverTestClass;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.neo4j.template.Neo4jOperations;
import org.springframework.test.context.junit4.SpringRunner;

import com.graphaware.common.policy.NodeInclusionPolicy;
import com.graphaware.module.timetree.module.TimeTreeConfiguration;
import com.graphaware.module.timetree.module.TimeTreeModule;
import com.graphaware.runtime.GraphAwareRuntime;
import com.graphaware.runtime.GraphAwareRuntimeFactory;

import myproject.core.context.TestPersistenceContext;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestPersistenceContext.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class AbstractTest extends MultiDriverTestClass {

    @Inject
    private Neo4jOperations neo4jOperations;

    public AbstractTest() {
        new SessionFactory("myproject.model.pojos").openSession();

        TimeTreeConfiguration timeTreeConfiguration = TimeTreeConfiguration.defaultConfiguration();
        TimeTreeModule timeTreeModule = new TimeTreeModule("TT.1", timeTreeConfiguration, super.getGraphDatabaseService());

        GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(super.getGraphDatabaseService());
        runtime.registerModule(timeTreeModule);
        runtime.start();
    }

    @After
    public void clearDatabase() {
        neo4jOperations.query("match (n) detach delete n;", new HashMap<>());
        neo4jOperations.clear();

    }

}

回答1:


Please change your AbstractTest() constructor to read as follows:

public AbstractTest() {
    new SessionFactory("myproject.model.pojos").openSession();

    TimeTreeConfiguration timeTreeConfiguration = TimeTreeConfiguration.defaultConfiguration();
    TimeTreeModule timeTreeModule = new TimeTreeModule("TT.1", timeTreeConfiguration, super.getGraphDatabaseService());

    TimeTreeProcedures.register(super.getGraphDatabaseService());

    GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(super.getGraphDatabaseService());
    runtime.registerModule(timeTreeModule);
    runtime.start();
}

Note the added line: TimeTreeProcedures.register(super.getGraphDatabaseService());



来源:https://stackoverflow.com/questions/40447328/testing-with-graphaware-timetree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!