Skip to content

Commit e15b0b2

Browse files
author
mpv1989
committed
added transaction test
1 parent 9df320a commit e15b0b2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/test/java/com/arangodb/ArangoDatabaseTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,25 @@ public void transactionCollection() {
798798
assertThat(result, is("hello world"));
799799
}
800800

801+
@Test
802+
public void transactionInsertJson() {
803+
try {
804+
db.createCollection(COLLECTION_NAME);
805+
final TransactionOptions options = new TransactionOptions().params("{\"_key\":\"0\"}")
806+
.writeCollections(COLLECTION_NAME);
807+
//@formatter:off
808+
db.transaction("function (params) { "
809+
+ "var db = require('internal').db;"
810+
+ "db." + COLLECTION_NAME + ".save(JSON.parse(params));"
811+
+ "}", Void.class, options);
812+
//@formatter:on
813+
assertThat(db.collection(COLLECTION_NAME).count().getCount(), is(1L));
814+
assertThat(db.collection(COLLECTION_NAME).getDocument("0", String.class), is(notNullValue()));
815+
} finally {
816+
db.collection(COLLECTION_NAME).drop();
817+
}
818+
}
819+
801820
@Test
802821
public void transactionEmpty() {
803822
db.transaction("function () {}", null, null);

0 commit comments

Comments
 (0)