Skip to content

Commit 5a5fa0e

Browse files
committed
added Neo4j and TinkerGraph to the test matrix
1 parent 1444421 commit 5a5fa0e

23 files changed

+448
-132
lines changed

jnosql-tinkerpop/pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,30 @@
5353
<version>${tinkerpop.version}</version>
5454
<scope>provided</scope>
5555
</dependency>
56+
<dependency>
57+
<groupId>org.apache.tinkerpop</groupId>
58+
<artifactId>neo4j-gremlin</artifactId>
59+
<version>${tinkerpop.version}</version>
60+
<scope>test</scope>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.neo4j</groupId>
64+
<artifactId>neo4j-tinkerpop-api-impl</artifactId>
65+
<version>${neo4j.connector.version}</version>
66+
<scope>test</scope>
67+
<exclusions>
68+
<exclusion>
69+
<groupId>org.slf4j</groupId>
70+
<artifactId>slf4j-nop</artifactId>
71+
</exclusion>
72+
</exclusions>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.apache.tinkerpop</groupId>
76+
<artifactId>tinkergraph-gremlin</artifactId>
77+
<version>${tinkerpop.version}</version>
78+
<scope>provided</scope>
79+
</dependency>
5680
<dependency>
5781
<groupId>com.arangodb</groupId>
5882
<artifactId>arangodb-tinkerpop-provider</artifactId>
@@ -69,6 +93,19 @@
6993

7094
<build>
7195
<plugins>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-surefire-plugin</artifactId>
99+
<configuration>
100+
<excludes>
101+
<!--
102+
Allow discovery of static inner test classes by overriding excludes rules.
103+
By default **/*$* is excluded.
104+
-->
105+
<exclude/>
106+
</excludes>
107+
</configuration>
108+
</plugin>
72109
<plugin>
73110
<groupId>org.antlr</groupId>
74111
<artifactId>antlr4-maven-plugin</artifactId>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2022 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
* Michele Rastelli
15+
*/
16+
package org.eclipse.jnosql.databases.tinkerpop.cdi;
17+
18+
import com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph;
19+
import org.apache.commons.configuration2.BaseConfiguration;
20+
import org.apache.commons.configuration2.Configuration;
21+
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph;
22+
import org.apache.tinkerpop.gremlin.structure.Graph;
23+
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
24+
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
25+
import org.testcontainers.containers.GenericContainer;
26+
import org.testcontainers.containers.wait.strategy.Wait;
27+
28+
import java.io.File;
29+
import java.util.function.Supplier;
30+
import java.util.logging.Logger;
31+
32+
import static java.lang.System.currentTimeMillis;
33+
34+
public enum TestGraphSupplier implements Supplier<Graph> {
35+
36+
NEO4J {
37+
private static final Logger LOGGER = Logger.getLogger(TestGraphSupplier.class.getName());
38+
39+
@Override
40+
public Graph get() {
41+
String directory = new File("").getAbsolutePath() + "/target/neo4j-graph/" + currentTimeMillis();
42+
LOGGER.info("Starting Neo4j at directory: " + directory);
43+
return Neo4jGraph.open(directory);
44+
}
45+
},
46+
47+
ARANGODB {
48+
private final GenericContainer<?> arangodb =
49+
new GenericContainer<>("arangodb/arangodb:latest")
50+
.withExposedPorts(8529)
51+
.withEnv("ARANGO_NO_AUTH", "1")
52+
.waitingFor(Wait.forHttp("/")
53+
.forStatusCode(200));
54+
55+
{
56+
arangodb.start();
57+
}
58+
59+
@Override
60+
public Graph get() {
61+
Configuration configuration = new BaseConfiguration();
62+
configuration.addProperty("gremlin.graph", ArangoDBGraph.class.getName());
63+
configuration.addProperty("gremlin.arangodb.conf.graph.enableDataDefinition", true);
64+
configuration.addProperty("gremlin.arangodb.conf.driver.hosts", arangodb.getHost() + ":" + arangodb.getFirstMappedPort());
65+
return GraphFactory.open(configuration);
66+
}
67+
},
68+
69+
TINKER_GRAPH {
70+
@Override
71+
public Graph get() {
72+
return TinkerGraph.open();
73+
}
74+
}
75+
76+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2022 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
* Michele Rastelli
15+
*/
16+
package org.eclipse.jnosql.databases.tinkerpop.cdi.arangodb;
17+
18+
import jakarta.annotation.PostConstruct;
19+
import jakarta.annotation.Priority;
20+
import jakarta.enterprise.context.ApplicationScoped;
21+
import jakarta.enterprise.inject.Alternative;
22+
import jakarta.enterprise.inject.Disposes;
23+
import jakarta.enterprise.inject.Produces;
24+
import jakarta.interceptor.Interceptor;
25+
import org.apache.tinkerpop.gremlin.structure.Graph;
26+
import org.eclipse.jnosql.databases.tinkerpop.cdi.TestGraphSupplier;
27+
28+
import java.util.function.Supplier;
29+
import java.util.logging.Logger;
30+
31+
@ApplicationScoped
32+
@Alternative
33+
@Priority(Interceptor.Priority.APPLICATION)
34+
public class ArangoDBGraphProducer implements Supplier<Graph> {
35+
36+
private static final Logger LOGGER = Logger.getLogger(ArangoDBGraphProducer.class.getName());
37+
38+
private Graph graph;
39+
40+
@PostConstruct
41+
public void init() {
42+
graph = TestGraphSupplier.ARANGODB.get();
43+
LOGGER.info("Graph database created");
44+
}
45+
46+
@Produces
47+
@ApplicationScoped
48+
@Override
49+
public Graph get() {
50+
return graph;
51+
}
52+
53+
public void dispose(@Disposes Graph graph) throws Exception {
54+
LOGGER.info("Graph database closing");
55+
graph.close();
56+
LOGGER.info("Graph Database closed");
57+
}
58+
59+
}
Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,20 @@
1212
*
1313
* Otavio Santana
1414
*/
15-
package org.eclipse.jnosql.databases.tinkerpop.mapping;
15+
package org.eclipse.jnosql.databases.tinkerpop.cdi.mock;
1616

17-
import jakarta.annotation.PostConstruct;
1817
import jakarta.annotation.Priority;
1918
import jakarta.enterprise.context.ApplicationScoped;
2019
import jakarta.enterprise.inject.Alternative;
21-
import jakarta.enterprise.inject.Disposes;
2220
import jakarta.enterprise.inject.Produces;
2321
import jakarta.interceptor.Interceptor;
2422
import org.apache.tinkerpop.gremlin.structure.Graph;
2523
import org.apache.tinkerpop.gremlin.structure.Vertex;
26-
import org.eclipse.jnosql.databases.tinkerpop.communication.GraphSupplier;
2724
import org.eclipse.jnosql.mapping.Database;
2825
import org.eclipse.jnosql.mapping.DatabaseType;
2926
import org.mockito.Mockito;
3027

3128
import java.util.Collections;
32-
import java.util.function.Supplier;
33-
import java.util.logging.Logger;
3429

3530
import static java.util.Collections.singleton;
3631
import static org.mockito.Mockito.mock;
@@ -39,46 +34,22 @@
3934
@ApplicationScoped
4035
@Alternative
4136
@Priority(Interceptor.Priority.APPLICATION)
42-
public class GraphProducer implements Supplier<Graph> {
43-
44-
private static final Logger LOGGER = Logger.getLogger(GraphProducer.class.getName());
45-
46-
private Graph graph;
47-
48-
@PostConstruct
49-
public void init() {
50-
graph = GraphSupplier.INSTANCE.get();
51-
LOGGER.info("Graph database created");
52-
}
53-
54-
@Produces
55-
@ApplicationScoped
56-
@Override
57-
public Graph get() {
58-
return graph;
59-
}
60-
37+
public class MockGraphProducer {
6138

6239
@Produces
6340
@ApplicationScoped
6441
@Database(value = DatabaseType.GRAPH, provider = "graphRepositoryMock")
6542
public Graph getGraphMock() {
66-
6743
Graph graphMock = mock(Graph.class);
6844
Vertex vertex = mock(Vertex.class);
6945
when(vertex.label()).thenReturn("Person");
70-
when(vertex.id()).thenReturn("10L");
71-
when(graphMock.vertices("10L")).thenReturn(Collections.emptyIterator());
46+
when(vertex.id()).thenReturn("10");
47+
when(graphMock.vertices("10")).thenReturn(Collections.emptyIterator());
7248
when(vertex.keys()).thenReturn(singleton("name"));
7349
when(vertex.value("name")).thenReturn("nameMock");
7450
when(graphMock.addVertex(Mockito.anyString())).thenReturn(vertex);
7551
when(graphMock.vertices(Mockito.any())).thenReturn(Collections.emptyIterator());
7652
return graphMock;
7753
}
7854

79-
public void dispose(@Disposes Graph graph) throws Exception {
80-
LOGGER.info("Graph database closing");
81-
graph.close();
82-
LOGGER.info("Graph Database closed");
83-
}
8455
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2022 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
* Michele Rastelli
15+
*/
16+
package org.eclipse.jnosql.databases.tinkerpop.cdi.neo4j;
17+
18+
import jakarta.annotation.PostConstruct;
19+
import jakarta.annotation.Priority;
20+
import jakarta.enterprise.context.ApplicationScoped;
21+
import jakarta.enterprise.inject.Alternative;
22+
import jakarta.enterprise.inject.Disposes;
23+
import jakarta.enterprise.inject.Produces;
24+
import jakarta.interceptor.Interceptor;
25+
import org.apache.tinkerpop.gremlin.structure.Graph;
26+
import org.eclipse.jnosql.databases.tinkerpop.cdi.TestGraphSupplier;
27+
28+
import java.util.function.Supplier;
29+
import java.util.logging.Logger;
30+
31+
@ApplicationScoped
32+
@Alternative
33+
@Priority(Interceptor.Priority.APPLICATION)
34+
public class Neo4jGraphProducer implements Supplier<Graph> {
35+
36+
private static final Logger LOGGER = Logger.getLogger(Neo4jGraphProducer.class.getName());
37+
38+
private Graph graph;
39+
40+
@PostConstruct
41+
public void init() {
42+
graph = TestGraphSupplier.NEO4J.get();
43+
LOGGER.info("Graph database created");
44+
}
45+
46+
@Produces
47+
@ApplicationScoped
48+
@Override
49+
public Graph get() {
50+
return graph;
51+
}
52+
53+
public void dispose(@Disposes Graph graph) throws Exception {
54+
LOGGER.info("Graph database closing");
55+
graph.close();
56+
LOGGER.info("Graph Database closed");
57+
}
58+
59+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2022 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
* Michele Rastelli
15+
*/
16+
package org.eclipse.jnosql.databases.tinkerpop.cdi.tinkergraph;
17+
18+
import jakarta.annotation.Priority;
19+
import jakarta.enterprise.context.ApplicationScoped;
20+
import jakarta.enterprise.inject.Alternative;
21+
import jakarta.enterprise.inject.Disposes;
22+
import jakarta.enterprise.inject.Produces;
23+
import jakarta.interceptor.Interceptor;
24+
import org.apache.tinkerpop.gremlin.structure.Graph;
25+
import org.eclipse.jnosql.databases.tinkerpop.cdi.TestGraphSupplier;
26+
27+
import java.util.function.Supplier;
28+
29+
30+
@ApplicationScoped
31+
@Alternative
32+
@Priority(Interceptor.Priority.APPLICATION)
33+
public class TinkerGraphProducer implements Supplier<Graph> {
34+
35+
@Produces
36+
@ApplicationScoped
37+
@Override
38+
public Graph get() {
39+
return TestGraphSupplier.TINKER_GRAPH.get();
40+
}
41+
42+
public void dispose(@Disposes Graph graph) throws Exception {
43+
graph.close();
44+
}
45+
46+
}

0 commit comments

Comments
 (0)