use of com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph in project blueprints by tinkerpop.
the class Neo4jBatchGraphTest method testAddingVerticesWithUserIdsThenSettingProperties.
public void testAddingVerticesWithUserIdsThenSettingProperties() {
List<Long> ids = new ArrayList<Long>(Arrays.asList(100L, 5L, 10L, 4L, 10000L));
final String directory = this.getWorkingDirectory();
final Neo4jBatchGraph batch = new Neo4jBatchGraph(directory);
for (final Long id : ids) {
Vertex v = batch.addVertex(id);
v.setProperty("theKey", id);
}
for (final Long id : ids) {
assertNotNull(batch.getVertex(id));
assertEquals(batch.getVertex(id).getProperty("theKey"), id);
}
assertNull(batch.getVertex(1L));
assertNull(batch.getVertex(2L));
assertNull(batch.getVertex(200000L));
batch.shutdown();
// native neo4j graph load
final Graph graph = new Neo4jGraph(directory);
assertEquals(count(graph.getVertices()), ids.size());
for (final Long id : ids) {
assertNotNull(graph.getVertex(id));
assertEquals(graph.getVertex(id).getProperty("theKey"), id);
assertEquals(graph.getVertex(id).getPropertyKeys().size(), 1);
}
assertNull(graph.getVertex(1L));
assertNull(graph.getVertex(2L));
assertNull(graph.getVertex(200000L));
graph.shutdown();
}
use of com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph in project blueprints by tinkerpop.
the class Neo4jBatchGraphTest method testAddingVerticesWithUserIdsAsStringsThenSettingProperties.
public void testAddingVerticesWithUserIdsAsStringsThenSettingProperties() {
List<Object> ids = new ArrayList<Object>(Arrays.asList(100L, 5.0d, "10", 4.0f, "10000.00"));
final String directory = this.getWorkingDirectory();
final Neo4jBatchGraph batch = new Neo4jBatchGraph(directory);
for (final Object id : ids) {
Vertex v = batch.addVertex(id);
v.setProperty("theKey", id);
}
for (final Object id : ids) {
assertNotNull(batch.getVertex(id));
assertEquals(batch.getVertex(id).getProperty("theKey"), id);
}
assertNull(batch.getVertex(1L));
assertNull(batch.getVertex(2L));
assertNull(batch.getVertex(200000L));
batch.shutdown();
// native neo4j graph load
final Graph graph = new Neo4jGraph(directory);
assertEquals(count(graph.getVertices()), ids.size());
assertNotNull(graph.getVertex(100l));
assertNotNull(graph.getVertex(5l));
assertNotNull(graph.getVertex(10l));
assertNotNull(graph.getVertex(4l));
assertNotNull(graph.getVertex(10000));
graph.shutdown();
}
use of com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph in project blueprints by tinkerpop.
the class Neo4jGraphSailTest method createGraph.
protected KeyIndexableGraph createGraph() throws Exception {
String directory = System.getProperty("neo4jGraphDirectory");
if (directory == null) {
directory = this.getWorkingDirectory();
}
Neo4jGraph g = new Neo4jGraph(directory);
g.setCheckElementsInTransaction(true);
return g;
}
Aggregations