2929
3030import java .util .*;
3131import java .util .concurrent .CompletableFuture ;
32+ import java .util .concurrent .CompletionException ;
3233import java .util .concurrent .ExecutionException ;
3334
3435import static org .hamcrest .CoreMatchers .notNullValue ;
@@ -331,7 +332,8 @@ public void updateDocumentIfMatchFail() throws InterruptedException, ExecutionEx
331332 final DocumentUpdateOptions options = new DocumentUpdateOptions ().ifMatch ("no" );
332333 db .collection (COLLECTION_NAME ).updateDocument (createResult .getKey (), doc , options ).get ();
333334 fail ();
334- } catch (final Exception e ) {
335+ } catch (final ExecutionException e ) {
336+ assertThat (e .getCause (), instanceOf (ArangoDBException .class ));
335337 }
336338 }
337339
@@ -508,7 +510,8 @@ public void updateDocumentIgnoreRevsFalse() throws InterruptedException, Executi
508510 final DocumentUpdateOptions options = new DocumentUpdateOptions ().ignoreRevs (false );
509511 db .collection (COLLECTION_NAME ).updateDocument (createResult .getKey (), doc , options ).get ();
510512 fail ();
511- } catch (final Exception e ) {
513+ } catch (final ExecutionException e ) {
514+ assertThat (e .getCause (), instanceOf (ArangoDBException .class ));
512515 }
513516 }
514517
@@ -581,7 +584,8 @@ public void replaceDocumentIfMatchFail() throws InterruptedException, ExecutionE
581584 final DocumentReplaceOptions options = new DocumentReplaceOptions ().ifMatch ("no" );
582585 db .collection (COLLECTION_NAME ).replaceDocument (createResult .getKey (), doc , options ).get ();
583586 fail ();
584- } catch (final Exception e ) {
587+ } catch (final ExecutionException e ) {
588+ assertThat (e .getCause (), instanceOf (ArangoDBException .class ));
585589 }
586590 }
587591
@@ -598,7 +602,8 @@ public void replaceDocumentIgnoreRevsFalse() throws InterruptedException, Execut
598602 final DocumentReplaceOptions options = new DocumentReplaceOptions ().ignoreRevs (false );
599603 db .collection (COLLECTION_NAME ).replaceDocument (createResult .getKey (), doc , options ).get ();
600604 fail ();
601- } catch (final Exception e ) {
605+ } catch (final ExecutionException e ) {
606+ assertThat (e .getCause (), instanceOf (ArangoDBException .class ));
602607 }
603608 }
604609
@@ -703,7 +708,8 @@ public void deleteDocumentIfMatchFail() throws InterruptedException, ExecutionEx
703708 try {
704709 db .collection (COLLECTION_NAME ).deleteDocument (createResult .getKey (), null , options ).get ();
705710 fail ();
706- } catch (final Exception e ) {
711+ } catch (final ExecutionException e ) {
712+ assertThat (e .getCause (), instanceOf (ArangoDBException .class ));
707713 }
708714 }
709715
@@ -843,9 +849,7 @@ public void createGeo2Index() throws ExecutionException, InterruptedException {
843849 } else {
844850 assertThat (indexResult .getType (), is (IndexType .geo2 ));
845851 }
846- } catch (InterruptedException e ) {
847- e .printStackTrace ();
848- } catch (ExecutionException e ) {
852+ } catch (InterruptedException | ExecutionException e ) {
849853 e .printStackTrace ();
850854 }
851855 }).get ();
@@ -1250,16 +1254,17 @@ public void importDocumentsDuplicateUpdate() throws InterruptedException, Execut
12501254 }
12511255
12521256 @ Test
1253- public void importDocumentsCompleteFail () {
1257+ public void importDocumentsCompleteFail () throws InterruptedException {
12541258 final Collection <BaseDocument > values = new ArrayList <>();
12551259 values .add (new BaseDocument ("1" ));
12561260 values .add (new BaseDocument ("2" ));
12571261 values .add (new BaseDocument ("2" ));
12581262 try {
12591263 db .collection (COLLECTION_NAME ).importDocuments (values , new DocumentImportOptions ().complete (true )).get ();
12601264 fail ();
1261- } catch (InterruptedException | ExecutionException e ) {
1262- assertThat (e .getMessage (), containsString ("1210" ));
1265+ } catch (ExecutionException e ) {
1266+ assertThat (e .getCause (), instanceOf (ArangoDBException .class ));
1267+ assertThat (((ArangoDBException ) e .getCause ()).getErrorNum (), is (1210 ));
12631268 }
12641269 }
12651270
@@ -1434,13 +1439,14 @@ public void importDocumentsJsonDuplicateUpdate() throws InterruptedException, Ex
14341439 }
14351440
14361441 @ Test
1437- public void importDocumentsJsonCompleteFail () {
1442+ public void importDocumentsJsonCompleteFail () throws InterruptedException {
14381443 final String values = "[{\" _key\" :\" 1\" },{\" _key\" :\" 2\" },{\" _key\" :\" 2\" }]" ;
14391444 try {
14401445 db .collection (COLLECTION_NAME ).importDocuments (values , new DocumentImportOptions ().complete (true )).get ();
14411446 fail ();
1442- } catch (InterruptedException | ExecutionException e ) {
1443- assertThat (e .getMessage (), containsString ("1210" ));
1447+ } catch (ExecutionException e ) {
1448+ assertThat (e .getCause (), instanceOf (ArangoDBException .class ));
1449+ assertThat (((ArangoDBException ) e .getCause ()).getErrorNum (), is (1210 ));
14441450 }
14451451 }
14461452
@@ -1887,7 +1893,8 @@ public void rename() throws InterruptedException, ExecutionException {
18871893 try {
18881894 db .collection (COLLECTION_NAME ).getInfo ().get ();
18891895 fail ();
1890- } catch (final Exception e ) {
1896+ } catch (final ExecutionException e ) {
1897+ assertThat (e .getCause (), instanceOf (ArangoDBException .class ));
18911898 }
18921899 } finally {
18931900 db .collection (COLLECTION_NAME + "1" ).rename (COLLECTION_NAME ).get ();
0 commit comments