更新:我在 neo4j 时间树源中发现了一些类似的测试,但使用了 GraphAwareIntegrationTest,它扩展了 ServerIntegrationTest。所以我尝试使用以下方法为我的测试创建一个 GraphDatabaseService Bean,但仍然没有运气。我得到“没有ga.timetree.events.attach
为此数据库实例注册的名称的过程。” 这不可能吗?
@Bean
public GraphDatabaseService graphDatabaseService() {
GraphDatabaseService gds = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
Procedures procedures = (Procedures)((GraphDatabaseFacade) gds).getDependencyResolver().resolveDependency(Procedures.class);
try {
ClassPathProcedureUtils.registerAllProceduresAndFunctions(procedures);
}catch (Exception ex) {
log.error("error", ex);
}
return gds;
}
======================
与此问题类似,但我使用的是 Spring Boot 2、SDN5 和 neo4j 3.2.5、graphaware 和时间树。我有自动事件附件设置,我看到事件被保存到时间树中,但我无法使用使用密码的过程调用进行查询。我得到错误:
Caused by: org.neo4j.ogm.exception.CypherException: Error executing Cypher; Code: Neo.ClientError.Procedure.ProcedureNotFound; Description: There is no procedure with the name `ga.timetree.range` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
at org.neo4j.ogm.drivers.embedded.request.EmbeddedRequest.executeRequest(EmbeddedRequest.java:176)
我没有看到链接问题中回答的 TimeTreeProcedures 类。这在嵌入式/单元测试中是否仍受支持?
此外,如果支持,我想使用 CustomRootTimeTree。我可以在过程调用中定义自定义根树 ID 的任何帮助或指向密码的指针也将非常感激。谢谢你的帮助!
测试:
@Test
public void testSingleTimeTree() {
User user = new User("alper@alper.com", "alper", "alper");
userRepository.save(user);
Collection<User> found = userRepository.findByEmail("alper@alper.com");
user = found.iterator().next();
Workout workout = new Workout(new DateTime().plusMonths(2).getMillis());
workoutRepository.save(workout);
GraphUnit.printGraph(graphDb);
Iterable<Workout> workouts = workoutRepository.findWorkouts();
for(Workout workout1 : workouts) {
log.info("workout: {}", workout1);
}
}
回购(现在硬编码开始/结束):
public interface WorkoutRepository extends Neo4jRepository<Workout, Long> {
@Query("CALL ga.timetree.range({start: 1506826887000, end: 1512097287, create: false})")
Iterable<Workout> findWorkouts();
}
pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<spring-data-releasetrain.version>Kay-RELEASE</spring-data-releasetrain.version>
<!--<neo4j-ogm.version>3.0.0</neo4j-ogm.version>-->
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>${spring-data-releasetrain.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-embedded-driver</artifactId>
<version>${neo4j-ogm.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.2.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- added by me -->
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>3.2.5</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>graphaware-framework-embedded</artifactId>
<version>3.2.5.51</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>timetree</artifactId>
<version>3.2.1.51.27</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-graphdb-api</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-io</artifactId>
<version>3.2.5</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>tests</artifactId>
<version>3.2.5.51</version>
</dependency>
</dependencies>