Skip to content

Commit 528fa0e

Browse files
committed
fixed tests
1 parent 4bda644 commit 528fa0e

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

src/test/java/com/arangodb/ArangoGraphTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,15 @@ public void getInfo() throws InterruptedException, ExecutionException {
125125
assertThat(info.getOrphanCollections(), is(empty()));
126126

127127
if (arangoDB.getRole().get() != ServerRole.SINGLE) {
128-
for (final String collection : new String[] { EDGE_COL_1, EDGE_COL_2, VERTEX_COL_1, VERTEX_COL_2 }) {
128+
for (final String collection : new String[] { VERTEX_COL_1, VERTEX_COL_2 }) {
129129
final CollectionPropertiesEntity properties = db.collection(collection).getProperties().get();
130130
assertThat(properties.getReplicationFactor(), is(REPLICATION_FACTOR));
131131
assertThat(properties.getNumberOfShards(), is(NUMBER_OF_SHARDS));
132132
}
133+
for (final String collection : new String[] { EDGE_COL_1, EDGE_COL_2 }) {
134+
final CollectionPropertiesEntity properties = db.collection(collection).getProperties().get();
135+
assertThat(properties.getReplicationFactor(), is(REPLICATION_FACTOR));
136+
}
133137
}
134138
}
135139

@@ -234,13 +238,15 @@ public void smartGraph() throws InterruptedException, ExecutionException {
234238
edgeDefinitions
235239
.add(new EdgeDefinition().collection(EDGE_COL_2).from(VERTEX_COL_2).to(VERTEX_COL_1, VERTEX_COL_3));
236240
final GraphEntity graph = db.createGraph(GRAPH_NAME + "_smart", edgeDefinitions,
237-
new GraphCreateOptions().isSmart(true).smartGraphAttribute("test").numberOfShards(2)).get();
241+
new GraphCreateOptions().isSmart(true).smartGraphAttribute("test").replicationFactor(REPLICATION_FACTOR)
242+
.numberOfShards(NUMBER_OF_SHARDS))
243+
.get();
238244
assertThat(graph, is(notNullValue()));
239245
assertThat(graph.getIsSmart(), is(true));
240246
assertThat(graph.getSmartGraphAttribute(), is("test"));
241247
assertThat(graph.getNumberOfShards(), is(2));
242248
try {
243-
db.graph(GRAPH_NAME + "_smart").drop(true).get();
249+
db.graph(GRAPH_NAME + "_smart").drop().get();
244250
} catch (final Exception e) {
245251
}
246252
}

src/test/java/com/arangodb/example/graph/AQLActorsAndMoviesExample.java

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,75 +72,85 @@ public static void tearDown() throws InterruptedException, ExecutionException {
7272
}
7373

7474
/**
75+
* @throws ExecutionException
76+
* @throws InterruptedException
7577
* @see <a href=
7678
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#all-actors-who-acted-in-movie1-or-movie2">AQL
7779
* Example Queries on an Actors and Movies Database</a>
7880
*/
7981
@Test
80-
public void allActorsActsInMovie1or2() {
82+
public void allActorsActsInMovie1or2() throws InterruptedException, ExecutionException {
8183
final CompletableFuture<ArangoCursorAsync<String>> f = db.query(
8284
"WITH actors FOR x IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN x._id",
8385
null, null, String.class);
8486
f.whenComplete((cursor, ex) -> {
8587
assertThat(cursor.asListRemaining(),
8688
hasItems("actors/Keanu", "actors/Hugo", "actors/Emil", "actors/Carrie", "actors/Laurence"));
87-
});
89+
}).get();
8890
}
8991

9092
/**
93+
* @throws ExecutionException
94+
* @throws InterruptedException
9195
* @see <a href=
9296
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#all-actors-who-acted-in-movie1-or-movie2">AQL
9397
* Example Queries on an Actors and Movies Database</a>
9498
*/
9599
@Test
96-
public void allActorsActsInMovie1or2UnionDistinct() {
100+
public void allActorsActsInMovie1or2UnionDistinct() throws InterruptedException, ExecutionException {
97101
final CompletableFuture<ArangoCursorAsync<String>> f = db.query(
98102
"WITH actors FOR x IN UNION_DISTINCT ((FOR y IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id), (FOR y IN ANY 'movies/TheDevilsAdvocate' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id)) RETURN x",
99103
null, null, String.class);
100104
f.whenComplete((cursor, ex) -> {
101105
assertThat(cursor.asListRemaining(), hasItems("actors/Emil", "actors/Hugo", "actors/Carrie",
102106
"actors/Laurence", "actors/Keanu", "actors/Al", "actors/Charlize"));
103-
});
107+
}).get();
104108
}
105109

106110
/**
111+
* @throws ExecutionException
112+
* @throws InterruptedException
107113
* @see <a href=
108114
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#all-actors-who-acted-in-both-movie1-and-movie2-">AQL
109115
* Example Queries on an Actors and Movies Database</a>
110116
*/
111117
@Test
112-
public void allActorsActsInMovie1and2() {
118+
public void allActorsActsInMovie1and2() throws InterruptedException, ExecutionException {
113119
final CompletableFuture<ArangoCursorAsync<String>> f = db.query(
114120
"WITH actors FOR x IN INTERSECTION ((FOR y IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id), (FOR y IN ANY 'movies/TheDevilsAdvocate' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id)) RETURN x",
115121
null, null, String.class);
116122
f.whenComplete((cursor, ex) -> {
117123
assertThat(cursor.asListRemaining(), hasItems("actors/Keanu"));
118-
});
124+
}).get();
119125
}
120126

121127
/**
128+
* @throws ExecutionException
129+
* @throws InterruptedException
122130
* @see <a href=
123131
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#all-common-movies-between-actor1-and-actor2-">AQL
124132
* Example Queries on an Actors and Movies Database</a>
125133
*/
126134
@Test
127-
public void allMoviesBetweenActor1andActor2() {
135+
public void allMoviesBetweenActor1andActor2() throws InterruptedException, ExecutionException {
128136
final CompletableFuture<ArangoCursorAsync<String>> f = db.query(
129137
"WITH movies FOR x IN INTERSECTION ((FOR y IN ANY 'actors/Hugo' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id), (FOR y IN ANY 'actors/Keanu' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id)) RETURN x",
130138
null, null, String.class);
131139
f.whenComplete((cursor, ex) -> {
132140
assertThat(cursor.asListRemaining(),
133141
hasItems("movies/TheMatrixRevolutions", "movies/TheMatrixReloaded", "movies/TheMatrix"));
134-
});
142+
}).get();
135143
}
136144

137145
/**
146+
* @throws ExecutionException
147+
* @throws InterruptedException
138148
* @see <a href=
139149
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#all-actors-who-acted-in-3-or-more-movies-">AQL
140150
* Example Queries on an Actors and Movies Database</a>
141151
*/
142152
@Test
143-
public void allActorsWhoActedIn3orMoreMovies() {
153+
public void allActorsWhoActedIn3orMoreMovies() throws InterruptedException, ExecutionException {
144154
final CompletableFuture<ArangoCursorAsync<Actor>> f = db.query(
145155
"FOR x IN actsIn COLLECT actor = x._from WITH COUNT INTO counter FILTER counter >= 3 RETURN {actor: actor, movies: counter}",
146156
null, null, Actor.class);
@@ -149,32 +159,36 @@ public void allActorsWhoActedIn3orMoreMovies() {
149159
hasItems(new Actor("actors/Carrie", 3), new Actor("actors/CubaG", 4), new Actor("actors/Hugo", 3),
150160
new Actor("actors/Keanu", 4), new Actor("actors/Laurence", 3), new Actor("actors/MegR", 5),
151161
new Actor("actors/TomC", 3), new Actor("actors/TomH", 3)));
152-
});
162+
}).get();
153163
}
154164

155165
/**
166+
* @throws ExecutionException
167+
* @throws InterruptedException
156168
* @see <a href=
157169
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#all-movies-where-exactly-6-actors-acted-in-">AQL
158170
* Example Queries on an Actors and Movies Database</a>
159171
*/
160172
@Test
161-
public void allMoviesWhereExactly6ActorsActedIn() {
173+
public void allMoviesWhereExactly6ActorsActedIn() throws InterruptedException, ExecutionException {
162174
final CompletableFuture<ArangoCursorAsync<String>> f = db.query(
163175
"FOR x IN actsIn COLLECT movie = x._to WITH COUNT INTO counter FILTER counter == 6 RETURN movie", null,
164176
null, String.class);
165177
f.whenComplete((cursor, ex) -> {
166178
assertThat(cursor.asListRemaining(),
167179
hasItems("movies/SleeplessInSeattle", "movies/TopGun", "movies/YouveGotMail"));
168-
});
180+
}).get();
169181
}
170182

171183
/**
184+
* @throws ExecutionException
185+
* @throws InterruptedException
172186
* @see <a href=
173187
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#the-number-of-actors-by-movie-">AQL
174188
* Example Queries on an Actors and Movies Database</a>
175189
*/
176190
@Test
177-
public void theNumberOfActorsByMovie() {
191+
public void theNumberOfActorsByMovie() throws InterruptedException, ExecutionException {
178192
final CompletableFuture<ArangoCursorAsync<Movie>> f = db.query(
179193
"FOR x IN actsIn COLLECT movie = x._to WITH COUNT INTO counter RETURN {movie: movie, actors: counter}",
180194
null, null, Movie.class);
@@ -188,16 +202,18 @@ public void theNumberOfActorsByMovie() {
188202
new Movie("movies/TheMatrixRevolutions", 4), new Movie("movies/TopGun", 6),
189203
new Movie("movies/WhatDreamsMayCome", 5), new Movie("movies/WhenHarryMetSally", 4),
190204
new Movie("movies/YouveGotMail", 6)));
191-
});
205+
}).get();
192206
}
193207

194208
/**
209+
* @throws ExecutionException
210+
* @throws InterruptedException
195211
* @see <a href=
196212
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#the-number-of-movies-by-actor-">AQL
197213
* Example Queries on an Actors and Movies Database</a>
198214
*/
199215
@Test
200-
public void theNumberOfMoviesByActor() {
216+
public void theNumberOfMoviesByActor() throws InterruptedException, ExecutionException {
201217
final CompletableFuture<ArangoCursorAsync<Actor>> f = db.query(
202218
"FOR x IN actsIn COLLECT actor = x._from WITH COUNT INTO counter RETURN {actor: actor, movies: counter}",
203219
null, null, Actor.class);
@@ -222,16 +238,18 @@ public void theNumberOfMoviesByActor() {
222238
new Actor("actors/SteveZ", 1), new Actor("actors/TomC", 3), new Actor("actors/TomH", 3),
223239
new Actor("actors/TomS", 1), new Actor("actors/ValK", 1), new Actor("actors/VictorG", 1),
224240
new Actor("actors/WernerH", 1), new Actor("actors/WilW", 1)));
225-
});
241+
}).get();
226242
}
227243

228244
/**
245+
* @throws ExecutionException
246+
* @throws InterruptedException
229247
* @see <a href=
230248
* "https://docs.arangodb.com/current/cookbook/Graph/ExampleActorsAndMovies.html#the-number-of-movies-acted-in-between-2005-and-2010-by-actor-">AQL
231249
* Example Queries on an Actors and Movies Database</a>
232250
*/
233251
@Test
234-
public void theNumberOfMoviesActedInBetween2005and2010byActor() {
252+
public void theNumberOfMoviesActedInBetween2005and2010byActor() throws InterruptedException, ExecutionException {
235253
final CompletableFuture<ArangoCursorAsync<Actor>> f = db.query(
236254
"FOR x IN actsIn FILTER x.year >= 1990 && x.year <= 1995 COLLECT actor = x._from WITH COUNT INTO counter RETURN {actor: actor, movies: counter}",
237255
null, null, Actor.class);
@@ -243,7 +261,7 @@ public void theNumberOfMoviesActedInBetween2005and2010byActor() {
243261
new Actor("actors/KieferS", 1), new Actor("actors/MegR", 2), new Actor("actors/Nathan", 1),
244262
new Actor("actors/NoahW", 1), new Actor("actors/RitaW", 1), new Actor("actors/RosieO", 1),
245263
new Actor("actors/TomC", 1), new Actor("actors/TomH", 2), new Actor("actors/VictorG", 1)));
246-
});
264+
}).get();
247265
}
248266

249267
public static class Actor {

0 commit comments

Comments
 (0)