|
28 | 28 | import static org.hamcrest.Matchers.is; |
29 | 29 | import static org.hamcrest.Matchers.not; |
30 | 30 | import static org.junit.Assert.assertThat; |
| 31 | +import static org.junit.Assert.assertTrue; |
31 | 32 | import static org.junit.Assert.fail; |
32 | 33 |
|
33 | 34 | import java.io.IOException; |
|
38 | 39 | import java.util.Iterator; |
39 | 40 | import java.util.Map; |
40 | 41 | import java.util.concurrent.CompletableFuture; |
| 42 | +import java.util.concurrent.CompletionException; |
41 | 43 | import java.util.concurrent.ExecutionException; |
42 | 44 | import java.util.concurrent.atomic.AtomicInteger; |
43 | 45 |
|
@@ -1029,6 +1031,26 @@ public void getDocument() throws InterruptedException, ExecutionException { |
1029 | 1031 | } |
1030 | 1032 | } |
1031 | 1033 |
|
| 1034 | + |
| 1035 | + @Test |
| 1036 | + public void shouldIncludeExceptionMessage() { |
| 1037 | + final String exceptionMessage = "My error context"; |
| 1038 | + final String action = "function (params) {" |
| 1039 | + + "throw '" + exceptionMessage + "';" |
| 1040 | + + "}"; |
| 1041 | + try { |
| 1042 | + db.transaction(action, VPackSlice.class, null).join(); |
| 1043 | + fail(); |
| 1044 | + } catch (final CompletionException e) { |
| 1045 | + Throwable cause = e.getCause(); |
| 1046 | + if (cause instanceof ArangoDBException) { |
| 1047 | + assertTrue(((ArangoDBException) cause).getException().equals(exceptionMessage)); |
| 1048 | + } else { |
| 1049 | + fail("Root cause expected to be an ArangoDBException"); |
| 1050 | + } |
| 1051 | + } |
| 1052 | + } |
| 1053 | + |
1032 | 1054 | @Test(expected = ArangoDBException.class) |
1033 | 1055 | public void getDocumentWrongId() throws InterruptedException, ExecutionException { |
1034 | 1056 | db.getDocument("123", BaseDocument.class).get(); |
|
0 commit comments