com.arangodb.entity.GraphEntity Java Examples
The following examples show how to use
com.arangodb.entity.GraphEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void getInfo() { final GraphEntity info = graph.getInfo(); assertThat(info, is(notNullValue())); assertThat(info.getName(), is(GRAPH_NAME)); assertThat(info.getEdgeDefinitions().size(), is(2)); final Iterator<EdgeDefinition> iterator = info.getEdgeDefinitions().iterator(); final EdgeDefinition e1 = iterator.next(); assertThat(e1.getCollection(), is(EDGE_COL_1)); assertThat(e1.getFrom(), hasItem(VERTEX_COL_1)); assertThat(e1.getTo(), hasItem(VERTEX_COL_2)); final EdgeDefinition e2 = iterator.next(); assertThat(e2.getCollection(), is(EDGE_COL_2)); assertThat(e2.getFrom(), hasItem(VERTEX_COL_2)); assertThat(e2.getTo(), hasItems(VERTEX_COL_1, VERTEX_COL_3)); assertThat(info.getOrphanCollections(), is(empty())); if (isCluster()) { for (final String collection : new String[]{EDGE_COL_1, EDGE_COL_2, VERTEX_COL_1, VERTEX_COL_2}) { final CollectionPropertiesEntity properties = db.collection(collection).getProperties(); assertThat(properties.getReplicationFactor(), is(REPLICATION_FACTOR)); assertThat(properties.getNumberOfShards(), is(NUMBER_OF_SHARDS)); } } }
Example #2
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void smartGraph() throws InterruptedException, ExecutionException { assumeTrue(isCluster()); assumeTrue(isEnterprise()); for (final String collection : new String[]{EDGE_COL_1, EDGE_COL_2, VERTEX_COL_1, VERTEX_COL_2, VERTEX_COL_3, VERTEX_COL_4}) { if (db.collection(collection).exists().get()) { db.collection(collection).drop().get(); } } final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>(); edgeDefinitions.add(new EdgeDefinition().collection(EDGE_COL_1).from(VERTEX_COL_1).to(VERTEX_COL_2)); edgeDefinitions .add(new EdgeDefinition().collection(EDGE_COL_2).from(VERTEX_COL_2).to(VERTEX_COL_1, VERTEX_COL_3)); final GraphEntity graph = db.createGraph(GRAPH_NAME + "_smart", edgeDefinitions, new GraphCreateOptions().isSmart(true).smartGraphAttribute("test").replicationFactor(REPLICATION_FACTOR) .numberOfShards(NUMBER_OF_SHARDS)) .get(); assertThat(graph, is(notNullValue())); assertThat(graph.getIsSmart(), is(true)); assertThat(graph.getSmartGraphAttribute(), is("test")); assertThat(graph.getNumberOfShards(), is(2)); if (db.graph(GRAPH_NAME + "_smart").exists().get()) { db.graph(GRAPH_NAME + "_smart").drop().get(); } }
Example #3
Source File: ArangoGraphTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void smartGraph() throws InterruptedException, ExecutionException { assumeTrue(isCluster()); assumeTrue(isEnterprise()); for (final String collection : new String[]{EDGE_COL_1, EDGE_COL_2, VERTEX_COL_1, VERTEX_COL_2, VERTEX_COL_3, VERTEX_COL_4}) { if (db.collection(collection).exists().get()) { db.collection(collection).drop().get(); } } final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>(); edgeDefinitions.add(new EdgeDefinition().collection(EDGE_COL_1).from(VERTEX_COL_1).to(VERTEX_COL_2)); edgeDefinitions .add(new EdgeDefinition().collection(EDGE_COL_2).from(VERTEX_COL_2).to(VERTEX_COL_1, VERTEX_COL_3)); final GraphEntity graph = db.createGraph(GRAPH_NAME + "_smart", edgeDefinitions, new GraphCreateOptions().isSmart(true).smartGraphAttribute("test").replicationFactor(REPLICATION_FACTOR) .numberOfShards(NUMBER_OF_SHARDS)) .get(); assertThat(graph, is(notNullValue())); assertThat(graph.getIsSmart(), is(true)); assertThat(graph.getSmartGraphAttribute(), is("test")); assertThat(graph.getNumberOfShards(), is(2)); if (db.graph(GRAPH_NAME + "_smart").exists().get()) { db.graph(GRAPH_NAME + "_smart").drop().get(); } }
Example #4
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void smartGraph() { assumeTrue(isEnterprise()); assumeTrue(isCluster()); final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>(); edgeDefinitions.add(new EdgeDefinition().collection("smartGraph-edge-" + rnd()).from("smartGraph-vertex-" + rnd()).to("smartGraph-vertex-" + rnd())); String graphId = GRAPH_NAME + rnd(); final GraphEntity g = db.createGraph(graphId, edgeDefinitions, new GraphCreateOptions().isSmart(true).smartGraphAttribute("test").numberOfShards(2)); assertThat(g, is(notNullValue())); assertThat(g.getIsSmart(), is(true)); assertThat(g.getSmartGraphAttribute(), is("test")); assertThat(g.getNumberOfShards(), is(2)); }
Example #5
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void drop() { final String edgeCollection = "edge_" + rnd(); final String vertexCollection = "vertex_" + rnd(); final String graphId = GRAPH_NAME + rnd(); final GraphEntity result = db.graph(graphId).create(Collections .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection))); assertThat(result, is(notNullValue())); db.graph(graphId).drop(); assertThat(db.collection(edgeCollection).exists(), is(true)); assertThat(db.collection(vertexCollection).exists(), is(true)); }
Example #6
Source File: ArangoGraphTest.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
@Test public void dropPlusDropCollections() throws InterruptedException, ExecutionException { final String edgeCollection = "edge_dropC"; final String vertexCollection = "vertex_dropC"; final String graph = GRAPH_NAME + "_dropC"; final GraphEntity result = db.graph(graph).create(Collections .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection))) .get(); assertThat(result, is(notNullValue())); db.graph(graph).drop(true).get(); assertThat(db.collection(edgeCollection).exists().get(), is(false)); assertThat(db.collection(vertexCollection).exists().get(), is(false)); }
Example #7
Source File: ArangoGraphTest.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
@Test public void drop() throws InterruptedException, ExecutionException { final String edgeCollection = "edge_drop"; final String vertexCollection = "vertex_drop"; final String graph = GRAPH_NAME + "_drop"; final GraphEntity result = db.graph(graph).create(Collections .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection))) .get(); assertThat(result, is(notNullValue())); db.graph(graph).drop().get(); assertThat(db.collection(edgeCollection).exists().get(), is(true)); assertThat(db.collection(vertexCollection).exists().get(), is(true)); }
Example #8
Source File: ArangoGraphTest.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
@Test public void removeEdgeDefinition() throws InterruptedException, ExecutionException { final GraphEntity graph = db.graph(GRAPH_NAME).removeEdgeDefinition(EDGE_COL_1).get(); final Collection<EdgeDefinition> edgeDefinitions = graph.getEdgeDefinitions(); assertThat(edgeDefinitions.size(), is(1)); assertThat(edgeDefinitions.iterator().next().getCollection(), is(EDGE_COL_2)); setup(); }
Example #9
Source File: ArangoGraphTest.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
@Test public void addVertexCollection() throws InterruptedException, ExecutionException { final GraphEntity graph = db.graph(GRAPH_NAME).addVertexCollection(VERTEX_COL_4).get(); assertThat(graph, is(notNullValue())); final Collection<String> vertexCollections = db.graph(GRAPH_NAME).getVertexCollections().get(); assertThat(vertexCollections, hasItems(VERTEX_COL_1, VERTEX_COL_2, VERTEX_COL_3, VERTEX_COL_4)); setup(); }
Example #10
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void addVertexCollection() { final GraphEntity g = graph.addVertexCollection(VERTEX_COL_4); assertThat(g, is(notNullValue())); final Collection<String> vertexCollections = graph.getVertexCollections(); assertThat(vertexCollections, hasItems(VERTEX_COL_1, VERTEX_COL_2, VERTEX_COL_3, VERTEX_COL_4)); // revert graph.vertexCollection(VERTEX_COL_4).drop(); }
Example #11
Source File: ArangoGraphTest.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
@Test public void createWithReplicationAndMinReplicationFactor() throws ExecutionException, InterruptedException { assumeTrue(isAtLeastVersion(3, 5)); assumeTrue(isCluster()); final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>(); final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2)).get(); assertThat(graph, is(notNullValue())); assertThat(graph.getName(), is(GRAPH_NAME + "_1")); assertThat(graph.getMinReplicationFactor(), is(2)); assertThat(graph.getReplicationFactor(), is(2)); db.graph(GRAPH_NAME + "_1").drop(); }
Example #12
Source File: ArangoGraphTest.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
@Test public void create() throws InterruptedException, ExecutionException { try { final GraphEntity result = db.graph(GRAPH_NAME + "_1").create(null).get(); assertThat(result, is(notNullValue())); assertThat(result.getName(), is(GRAPH_NAME + "_1")); } finally { db.graph(GRAPH_NAME + "_1").drop().get(); } }
Example #13
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void removeEdgeDefinition() { final GraphEntity g = graph.removeEdgeDefinition(EDGE_COL_1); final Collection<EdgeDefinition> edgeDefinitions = g.getEdgeDefinitions(); assertThat(edgeDefinitions.size(), is(1)); assertThat(edgeDefinitions.iterator().next().getCollection(), is(EDGE_COL_2)); //revert graph.addEdgeDefinition(ed1); }
Example #14
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void dropPlusDropCollections() { final String edgeCollection = "edge_dropC" + rnd(); final String vertexCollection = "vertex_dropC" + rnd(); final String graphId = GRAPH_NAME + "_dropC" + rnd(); final GraphEntity result = db.graph(graphId).create(Collections .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection))); assertThat(result, is(notNullValue())); db.graph(graphId).drop(true); assertThat(db.collection(edgeCollection).exists(), is(false)); assertThat(db.collection(vertexCollection).exists(), is(false)); }
Example #15
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void create() throws InterruptedException, ExecutionException { try { final GraphEntity result = db.graph(GRAPH_NAME + "_1").create(null).get(); assertThat(result, is(notNullValue())); assertThat(result.getName(), is(GRAPH_NAME + "_1")); } finally { db.graph(GRAPH_NAME + "_1").drop().get(); } }
Example #16
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void createWithReplicationAndMinReplicationFactor() throws ExecutionException, InterruptedException { assumeTrue(isAtLeastVersion(3, 5)); assumeTrue(isCluster()); final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>(); final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2)).get(); assertThat(graph, is(notNullValue())); assertThat(graph.getName(), is(GRAPH_NAME + "_1")); assertThat(graph.getMinReplicationFactor(), is(2)); assertThat(graph.getReplicationFactor(), is(2)); db.graph(GRAPH_NAME + "_1").drop(); }
Example #17
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void createWithReplicationAndMinReplicationFactor() { assumeTrue(isAtLeastVersion(3, 5)); assumeTrue(isCluster()); final Collection<EdgeDefinition> edgeDefinitions = new ArrayList<>(); final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2)); assertThat(graph, is(notNullValue())); assertThat(graph.getName(), is(GRAPH_NAME + "_1")); assertThat(graph.getMinReplicationFactor(), is(2)); assertThat(graph.getReplicationFactor(), is(2)); db.graph(GRAPH_NAME + "_1").drop(); }
Example #18
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void addVertexCollection() throws InterruptedException, ExecutionException { final GraphEntity graph = db.graph(GRAPH_NAME).addVertexCollection(VERTEX_COL_4).get(); assertThat(graph, is(notNullValue())); final Collection<String> vertexCollections = db.graph(GRAPH_NAME).getVertexCollections().get(); assertThat(vertexCollections, hasItems(VERTEX_COL_1, VERTEX_COL_2, VERTEX_COL_3, VERTEX_COL_4)); setup(); }
Example #19
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void removeEdgeDefinition() throws InterruptedException, ExecutionException { final GraphEntity graph = db.graph(GRAPH_NAME).removeEdgeDefinition(EDGE_COL_1).get(); final Collection<EdgeDefinition> edgeDefinitions = graph.getEdgeDefinitions(); assertThat(edgeDefinitions.size(), is(1)); assertThat(edgeDefinitions.iterator().next().getCollection(), is(EDGE_COL_2)); setup(); }
Example #20
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void drop() throws InterruptedException, ExecutionException { final String edgeCollection = "edge_drop"; final String vertexCollection = "vertex_drop"; final String graph = GRAPH_NAME + "_drop"; final GraphEntity result = db.graph(graph).create(Collections .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection))) .get(); assertThat(result, is(notNullValue())); db.graph(graph).drop().get(); assertThat(db.collection(edgeCollection).exists().get(), is(true)); assertThat(db.collection(vertexCollection).exists().get(), is(true)); }
Example #21
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void dropPlusDropCollections() throws InterruptedException, ExecutionException { final String edgeCollection = "edge_dropC"; final String vertexCollection = "vertex_dropC"; final String graph = GRAPH_NAME + "_dropC"; final GraphEntity result = db.graph(graph).create(Collections .singleton(new EdgeDefinition().collection(edgeCollection).from(vertexCollection).to(vertexCollection))) .get(); assertThat(result, is(notNullValue())); db.graph(graph).drop(true).get(); assertThat(db.collection(edgeCollection).exists().get(), is(false)); assertThat(db.collection(vertexCollection).exists().get(), is(false)); }
Example #22
Source File: ArangoGraphAsyncImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<GraphEntity> create(final Collection<EdgeDefinition> edgeDefinitions) { return db().createGraph(name(), edgeDefinitions); }
Example #23
Source File: ArangoGraphTest.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Test public void getGraphs() throws InterruptedException, ExecutionException { final Collection<GraphEntity> graphs = db.getGraphs().get(); assertThat(graphs, is(notNullValue())); assertThat(graphs.size(), greaterThanOrEqualTo(1)); }
Example #24
Source File: ArangoGraphAsyncImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<GraphEntity> createGraph( final Collection<EdgeDefinition> edgeDefinitions, final GraphCreateOptions options) { return db().createGraph(name(), edgeDefinitions, options); }
Example #25
Source File: ArangoGraphAsyncImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<GraphEntity> getInfo() { return executor.execute(getInfoRequest(), getInfoResponseDeserializer()); }
Example #26
Source File: ArangoGraphImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Override public GraphEntity addVertexCollection(final String name) throws ArangoDBException { return executor.execute(addVertexCollectionRequest(name), addVertexCollectionResponseDeserializer()); }
Example #27
Source File: ArangoGraphImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Override public GraphEntity removeEdgeDefinition(final String definitionName) throws ArangoDBException { return executor.execute(removeEdgeDefinitionRequest(definitionName), removeEdgeDefinitionResponseDeserializer()); }
Example #28
Source File: ArangoGraphImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Override public GraphEntity replaceEdgeDefinition(final EdgeDefinition definition) throws ArangoDBException { return executor.execute(replaceEdgeDefinitionRequest(definition), replaceEdgeDefinitionResponseDeserializer()); }
Example #29
Source File: ArangoGraphImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Override public GraphEntity addEdgeDefinition(final EdgeDefinition definition) throws ArangoDBException { return executor.execute(addEdgeDefinitionRequest(definition), addEdgeDefinitionResponseDeserializer()); }
Example #30
Source File: ArangoGraphImpl.java From arangodb-java-driver with Apache License 2.0 | 4 votes |
@Override public GraphEntity getInfo() throws ArangoDBException { return executor.execute(getInfoRequest(), getInfoResponseDeserializer()); }