20
20
import static org .junit .Assert .assertThat ;
21
21
22
22
import org .junit .After ;
23
+ import org .junit .Assert ;
23
24
import org .junit .Before ;
24
25
import org .junit .Test ;
25
26
27
+ import com .arangodb .entity .BaseEntity ;
26
28
import com .arangodb .entity .TransactionEntity ;
27
29
import com .arangodb .entity .TransactionResultEntity ;
28
30
33
35
public class ArangoDriverTransactionTest extends BaseTest {
34
36
35
37
private static final String SOME_COLLECTION = "someCollection" ;
38
+ private static final String SOME_OTHER_COLLECTION = "someOtherCollection" ;
36
39
37
40
public class ParamObject {
38
41
private String a = "a" ;
@@ -77,6 +80,16 @@ public void setup() throws ArangoException {
77
80
driver .createCollection (SOME_COLLECTION );
78
81
} catch (final ArangoException e ) {
79
82
83
+ }
84
+ try {
85
+ driver .deleteCollection (SOME_OTHER_COLLECTION );
86
+ } catch (final ArangoException e ) {
87
+
88
+ }
89
+ try {
90
+ driver .createCollection (SOME_OTHER_COLLECTION );
91
+ } catch (final ArangoException e ) {
92
+
80
93
}
81
94
}
82
95
@@ -86,6 +99,11 @@ public void teardown() throws ArangoException {
86
99
driver .deleteCollection (SOME_COLLECTION );
87
100
} catch (final ArangoException e ) {
88
101
102
+ }
103
+ try {
104
+ driver .deleteCollection (SOME_OTHER_COLLECTION );
105
+ } catch (final ArangoException e ) {
106
+
89
107
}
90
108
}
91
109
@@ -137,4 +155,30 @@ public void test_Transaction() throws ArangoException {
137
155
138
156
}
139
157
158
+ @ Test
159
+ public void allowImplicit () throws ArangoException {
160
+ TransactionEntity transaction = driver
161
+ .createTransaction ("function (params) {" + "var db = require('internal').db;"
162
+ + "return {'a':db.someCollection.all().toArray()[0], 'b':db.someOtherCollection.all().toArray()[0]};"
163
+ + "}" );
164
+ transaction .addReadCollection (SOME_COLLECTION );
165
+ {
166
+ TransactionResultEntity result = driver .executeTransaction (transaction );
167
+ assertThat (result .getStatusCode (), is (200 ));
168
+ assertThat (result .getCode (), is (200 ));
169
+ assertThat (result .isError (), is (false ));
170
+ }
171
+ {
172
+ transaction .setAllowImplicit (false );
173
+ try {
174
+ driver .executeTransaction (transaction );
175
+ Assert .fail ();
176
+ } catch (ArangoException e ) {
177
+ final BaseEntity result = e .getEntity ();
178
+ assertThat (result .getStatusCode (), is (400 ));
179
+ assertThat (result .getCode (), is (400 ));
180
+ assertThat (result .isError (), is (true ));
181
+ }
182
+ }
183
+ }
140
184
}
0 commit comments