@@ -351,6 +351,42 @@ void createCollectionWithJsonSchema(ArangoDatabase db) {
351
351
assertThat (e .getErrorNum ()).isEqualTo (1620 );
352
352
}
353
353
354
+ @ ParameterizedTest (name = "{index}" )
355
+ @ MethodSource ("dbs" )
356
+ void createCollectionWithComputedFields (ArangoDatabase db ) {
357
+ assumeTrue (isAtLeastVersion (3 , 10 ));
358
+ String cName = "collection-" + rnd ();
359
+ ComputedValue cv = new ComputedValue ()
360
+ .name ("foo" )
361
+ .expression ("RETURN 11" )
362
+ .overwrite (false )
363
+ .computeOn (ComputedValue .ComputeOn .insert )
364
+ .keepNull (false )
365
+ .failOnWarning (true );
366
+
367
+ final CollectionEntity result = db .createCollection (cName , new CollectionCreateOptions ().computedValues (cv ));
368
+
369
+ assertThat (result ).isNotNull ();
370
+ assertThat (result .getComputedValues ())
371
+ .hasSize (1 )
372
+ .contains (cv );
373
+
374
+ ComputedValue cv2 = new ComputedValue ()
375
+ .name ("bar" )
376
+ .expression ("RETURN 22" )
377
+ .overwrite (true )
378
+ .computeOn (ComputedValue .ComputeOn .update , ComputedValue .ComputeOn .replace )
379
+ .keepNull (true )
380
+ .failOnWarning (false );
381
+
382
+ db .collection (cName ).changeProperties (new CollectionPropertiesOptions ().computedValues (cv2 ));
383
+
384
+ CollectionPropertiesEntity props = db .collection (cName ).getProperties ();
385
+ assertThat (props .getComputedValues ())
386
+ .hasSize (1 )
387
+ .contains (cv2 );
388
+ }
389
+
354
390
@ ParameterizedTest (name = "{index}" )
355
391
@ MethodSource ("dbs" )
356
392
void deleteCollection (ArangoDatabase db ) {
@@ -718,15 +754,17 @@ void queryWithCache(ArangoDatabase db) {
718
754
@ ParameterizedTest (name = "{index}" )
719
755
@ MethodSource ("dbs" )
720
756
void queryWithMemoryLimit (ArangoDatabase db ) {
721
- Throwable thrown = catchThrowable (() -> db .query ("RETURN 1..100000" , null , new AqlQueryOptions ().memoryLimit (32 * 1024L ), String .class ));
757
+ Throwable thrown = catchThrowable (() -> db .query ("RETURN 1..100000" , null ,
758
+ new AqlQueryOptions ().memoryLimit (32 * 1024L ), String .class ));
722
759
assertThat (thrown ).isInstanceOf (ArangoDBException .class );
723
760
assertThat (((ArangoDBException ) thrown ).getErrorNum ()).isEqualTo (32 );
724
761
}
725
762
726
763
@ ParameterizedTest (name = "{index}" )
727
764
@ MethodSource ("dbs" )
728
765
void queryWithFailOnWarningTrue (ArangoDatabase db ) {
729
- Throwable thrown = catchThrowable (() -> db .query ("RETURN 1 / 0" , null , new AqlQueryOptions ().failOnWarning (true ), String .class ));
766
+ Throwable thrown = catchThrowable (() -> db .query ("RETURN 1 / 0" , null ,
767
+ new AqlQueryOptions ().failOnWarning (true ), String .class ));
730
768
assertThat (thrown ).isInstanceOf (ArangoDBException .class );
731
769
}
732
770
@@ -742,7 +780,8 @@ void queryWithFailOnWarningFalse(ArangoDatabase db) {
742
780
@ MethodSource ("dbs" )
743
781
void queryWithTimeout (ArangoDatabase db ) {
744
782
assumeTrue (isAtLeastVersion (3 , 6 ));
745
- Throwable thrown = catchThrowable (() -> db .query ("RETURN SLEEP(1)" , null , new AqlQueryOptions ().maxRuntime (0.1 ), String .class ).next ());
783
+ Throwable thrown = catchThrowable (() -> db .query ("RETURN SLEEP(1)" , null ,
784
+ new AqlQueryOptions ().maxRuntime (0.1 ), String .class ).next ());
746
785
assertThat (thrown ).isInstanceOf (ArangoDBException .class );
747
786
assertThat (((ArangoDBException ) thrown ).getResponseCode ()).isEqualTo (410 );
748
787
}
@@ -1098,7 +1137,8 @@ void createGraphReplicationFaktor(ArangoDatabase db) {
1098
1137
final String edgeCollection = "edge-" + rnd ();
1099
1138
final String fromCollection = "from-" + rnd ();
1100
1139
final String toCollection = "to-" + rnd ();
1101
- final Collection <EdgeDefinition > edgeDefinitions = Collections .singletonList (new EdgeDefinition ().collection (edgeCollection ).from (fromCollection ).to (toCollection ));
1140
+ final Collection <EdgeDefinition > edgeDefinitions =
1141
+ Collections .singletonList (new EdgeDefinition ().collection (edgeCollection ).from (fromCollection ).to (toCollection ));
1102
1142
final GraphEntity result = db .createGraph (name , edgeDefinitions , new GraphCreateOptions ().replicationFactor (2 ));
1103
1143
assertThat (result ).isNotNull ();
1104
1144
for (final String collection : Arrays .asList (edgeCollection , fromCollection , toCollection )) {
@@ -1115,7 +1155,8 @@ void createGraphNumberOfShards(ArangoDatabase db) {
1115
1155
final String edgeCollection = "edge-" + rnd ();
1116
1156
final String fromCollection = "from-" + rnd ();
1117
1157
final String toCollection = "to-" + rnd ();
1118
- final Collection <EdgeDefinition > edgeDefinitions = Collections .singletonList (new EdgeDefinition ().collection (edgeCollection ).from (fromCollection ).to (toCollection ));
1158
+ final Collection <EdgeDefinition > edgeDefinitions =
1159
+ Collections .singletonList (new EdgeDefinition ().collection (edgeCollection ).from (fromCollection ).to (toCollection ));
1119
1160
final GraphEntity result = db
1120
1161
.createGraph (name , edgeDefinitions , new GraphCreateOptions ().numberOfShards (2 ));
1121
1162
assertThat (result ).isNotNull ();
@@ -1322,8 +1363,10 @@ void executeTraversal(ArangoDatabase db) {
1322
1363
db .collection (ENAMES ).insertDocument (edge , null );
1323
1364
}
1324
1365
1325
- final TraversalOptions options = new TraversalOptions ().edgeCollection (ENAMES ).startVertex (CNAME1 + "/" + k1 ).direction (Direction .outbound );
1326
- final TraversalEntity <BaseDocument , BaseEdgeDocument > traversal = db .executeTraversal (BaseDocument .class , BaseEdgeDocument .class , options );
1366
+ final TraversalOptions options =
1367
+ new TraversalOptions ().edgeCollection (ENAMES ).startVertex (CNAME1 + "/" + k1 ).direction (Direction .outbound );
1368
+ final TraversalEntity <BaseDocument , BaseEdgeDocument > traversal = db .executeTraversal (BaseDocument .class ,
1369
+ BaseEdgeDocument .class , options );
1327
1370
assertThat (traversal ).isNotNull ();
1328
1371
1329
1372
final Collection <BaseDocument > vertices = traversal .getVertices ();
0 commit comments