24
24
import com .arangodb .entity .EdgeDefinition ;
25
25
import com .arangodb .entity .GraphEntity ;
26
26
import com .arangodb .model .GraphCreateOptions ;
27
+ import com .arangodb .model .VertexCollectionCreateOptions ;
27
28
import org .junit .BeforeClass ;
28
29
import org .junit .Test ;
29
30
import org .junit .runner .RunWith ;
@@ -185,6 +186,26 @@ public void addVertexCollection() {
185
186
graph .vertexCollection (VERTEX_COL_4 ).drop ();
186
187
}
187
188
189
+ @ Test
190
+ public void addSatelliteVertexCollection () {
191
+ assumeTrue (isCluster ());
192
+ assumeTrue (isEnterprise ());
193
+ assumeTrue (isAtLeastVersion (3 , 9 ));
194
+
195
+ String v1Name = "vertex-" + rnd ();
196
+
197
+ ArangoGraph g = db .graph (GRAPH_NAME + rnd ());
198
+ g .create (Collections .emptyList (), new GraphCreateOptions ().isSmart (true ).smartGraphAttribute ("test" ));
199
+ g .addVertexCollection (v1Name , new VertexCollectionCreateOptions ().satellites (v1Name ));
200
+
201
+ Collection <String > vertexCollections = g .getVertexCollections ();
202
+ assertThat (vertexCollections , hasItems (v1Name ));
203
+ assertThat (db .collection (v1Name ).getProperties ().getSatellite (), is (true ));
204
+
205
+ // revert
206
+ g .drop ();
207
+ }
208
+
188
209
@ Test
189
210
public void getEdgeCollections () {
190
211
final Collection <String > edgeCollections = graph .getEdgeDefinitions ();
@@ -223,6 +244,35 @@ public void addEdgeDefinition() {
223
244
graph .removeEdgeDefinition (EDGE_COL_3 );
224
245
}
225
246
247
+ @ Test
248
+ public void addSatelliteEdgeDefinition () {
249
+ assumeTrue (isCluster ());
250
+ assumeTrue (isEnterprise ());
251
+ assumeTrue (isAtLeastVersion (3 , 9 ));
252
+
253
+ String eName = "edge-" + rnd ();
254
+ String v1Name = "vertex-" + rnd ();
255
+ String v2Name = "vertex-" + rnd ();
256
+ EdgeDefinition ed = new EdgeDefinition ().collection (eName ).from (v1Name ).to (v2Name ).satellites (v1Name );
257
+
258
+ ArangoGraph g = db .graph (GRAPH_NAME + rnd ());
259
+ g .create (Collections .emptyList (), new GraphCreateOptions ().isSmart (true ).smartGraphAttribute ("test" ));
260
+ g .addEdgeDefinition (ed );
261
+ final GraphEntity ge = g .getInfo ();
262
+ assertThat (ge , is (notNullValue ()));
263
+ final Collection <EdgeDefinition > edgeDefinitions = ge .getEdgeDefinitions ();
264
+ assertThat (edgeDefinitions .size (), is (1 ));
265
+ EdgeDefinition e = edgeDefinitions .iterator ().next ();
266
+ assertThat (e .getCollection (), is (eName ));
267
+ assertThat (e .getFrom (), hasItem (v1Name ));
268
+ assertThat (e .getTo (), hasItem (v2Name ));
269
+
270
+ assertThat (db .collection (v1Name ).getProperties ().getSatellite (), is (true ));
271
+
272
+ // revert
273
+ g .drop ();
274
+ }
275
+
226
276
@ Test
227
277
public void replaceEdgeDefinition () {
228
278
final GraphEntity g = graph
@@ -277,6 +327,33 @@ public void smartGraph() {
277
327
assertThat (g .getNumberOfShards (), is (2 ));
278
328
}
279
329
330
+ @ Test
331
+ public void hybridSmartGraph () {
332
+ assumeTrue (isEnterprise ());
333
+ assumeTrue (isCluster ());
334
+ assumeTrue ((isAtLeastVersion (3 , 9 )));
335
+
336
+ final Collection <EdgeDefinition > edgeDefinitions = new ArrayList <>();
337
+ String eName = "hybridSmartGraph-edge-" + rnd ();
338
+ String v1Name = "hybridSmartGraph-vertex-" + rnd ();
339
+ String v2Name = "hybridSmartGraph-vertex-" + rnd ();
340
+ edgeDefinitions .add (new EdgeDefinition ().collection (eName ).from (v1Name ).to (v2Name ));
341
+
342
+ String graphId = GRAPH_NAME + rnd ();
343
+ final GraphEntity g = db .createGraph (graphId , edgeDefinitions , new GraphCreateOptions ()
344
+ .satellites (eName , v1Name )
345
+ .isSmart (true ).smartGraphAttribute ("test" ).replicationFactor (2 ).numberOfShards (2 ));
346
+
347
+ assertThat (g , is (notNullValue ()));
348
+ assertThat (g .getIsSmart (), is (true ));
349
+ assertThat (g .getSmartGraphAttribute (), is ("test" ));
350
+ assertThat (g .getNumberOfShards (), is (2 ));
351
+
352
+ assertThat (db .collection (eName ).getProperties ().getSatellite (), is (true ));
353
+ assertThat (db .collection (v1Name ).getProperties ().getSatellite (), is (true ));
354
+ assertThat (db .collection (v2Name ).getProperties ().getReplicationFactor (), is (2 ));
355
+ }
356
+
280
357
@ Test
281
358
public void disjointSmartGraph () {
282
359
assumeTrue (isEnterprise ());
@@ -297,6 +374,33 @@ public void disjointSmartGraph() {
297
374
assertThat (g .getNumberOfShards (), is (2 ));
298
375
}
299
376
377
+ @ Test
378
+ public void hybridDisjointSmartGraph () {
379
+ assumeTrue (isEnterprise ());
380
+ assumeTrue (isCluster ());
381
+ assumeTrue ((isAtLeastVersion (3 , 9 )));
382
+
383
+ final Collection <EdgeDefinition > edgeDefinitions = new ArrayList <>();
384
+ String eName = "hybridDisjointSmartGraph-edge-" + rnd ();
385
+ String v1Name = "hybridDisjointSmartGraph-vertex-" + rnd ();
386
+ String v2Name = "hybridDisjointSmartGraph-vertex-" + rnd ();
387
+ edgeDefinitions .add (new EdgeDefinition ().collection (eName ).from (v1Name ).to (v2Name ));
388
+
389
+ String graphId = GRAPH_NAME + rnd ();
390
+ final GraphEntity g = db .createGraph (graphId , edgeDefinitions , new GraphCreateOptions ()
391
+ .satellites (v1Name )
392
+ .isSmart (true ).isDisjoint (true ).smartGraphAttribute ("test" ).replicationFactor (2 ).numberOfShards (2 ));
393
+
394
+ assertThat (g , is (notNullValue ()));
395
+ assertThat (g .getIsSmart (), is (true ));
396
+ assertThat (g .getIsDisjoint (), is (true ));
397
+ assertThat (g .getSmartGraphAttribute (), is ("test" ));
398
+ assertThat (g .getNumberOfShards (), is (2 ));
399
+
400
+ assertThat (db .collection (v1Name ).getProperties ().getSatellite (), is (true ));
401
+ assertThat (db .collection (v2Name ).getProperties ().getReplicationFactor (), is (2 ));
402
+ }
403
+
300
404
@ Test
301
405
public void drop () {
302
406
final String edgeCollection = "edge_" + rnd ();
0 commit comments