3535import org .slf4j .Logger ;
3636import org .slf4j .LoggerFactory ;
3737
38+ import com .arangodb .entity .BaseDocument ;
3839import com .arangodb .entity .CollectionEntity ;
3940import com .arangodb .entity .DocumentEntity ;
4041import com .arangodb .entity .EntityFactory ;
@@ -78,8 +79,8 @@ public void before() throws ArangoException {
7879 // configure Gson to use our instance creator whenever documents of
7980 // TestInterface are requested
8081 testInstanceCreator = new TestInterfaceInstanceCreator ();
81- EntityFactory .configure (EntityFactory . getGsonBuilder (). registerTypeAdapter ( TestInterface . class ,
82- testInstanceCreator ));
82+ EntityFactory .configure (
83+ EntityFactory . getGsonBuilder (). registerTypeAdapter ( TestInterface . class , testInstanceCreator ));
8384
8485 logger .debug ("--" );
8586
@@ -258,12 +259,12 @@ public void test_partial_update() throws ArangoException {
258259 @ Test
259260 public void test_getDocuments () throws ArangoException {
260261 // create document
261- DocumentEntity <TestComplexEntity01 > doc1 = driver .createDocument (collectionName , new TestComplexEntity01 (
262- "test-user1" , "test-user1-desc" , 21 ), true , false );
263- DocumentEntity <TestComplexEntity01 > doc2 = driver .createDocument (collectionName , new TestComplexEntity01 (
264- "test-user2" , "test-user2-desc" , 22 ), true , false );
265- DocumentEntity <TestComplexEntity01 > doc3 = driver .createDocument (collectionName , new TestComplexEntity01 (
266- "test-user3" , "test-user3-desc" , 23 ), true , false );
262+ DocumentEntity <TestComplexEntity01 > doc1 = driver .createDocument (collectionName ,
263+ new TestComplexEntity01 ( "test-user1" , "test-user1-desc" , 21 ), true , false );
264+ DocumentEntity <TestComplexEntity01 > doc2 = driver .createDocument (collectionName ,
265+ new TestComplexEntity01 ( "test-user2" , "test-user2-desc" , 22 ), true , false );
266+ DocumentEntity <TestComplexEntity01 > doc3 = driver .createDocument (collectionName ,
267+ new TestComplexEntity01 ( "test-user3" , "test-user3-desc" , 23 ), true , false );
267268 assertThat (doc1 , is (notNullValue ()));
268269 assertThat (doc2 , is (notNullValue ()));
269270 assertThat (doc3 , is (notNullValue ()));
@@ -280,8 +281,8 @@ public void test_getDocuments() throws ArangoException {
280281 prefix = "/_api/document/" ;
281282 }
282283
283- List <String > list = Arrays .asList (prefix + doc1 .getDocumentHandle (), prefix + doc2 .getDocumentHandle (), prefix
284- + doc3 .getDocumentHandle ());
284+ List <String > list = Arrays .asList (prefix + doc1 .getDocumentHandle (), prefix + doc2 .getDocumentHandle (),
285+ prefix + doc3 .getDocumentHandle ());
285286
286287 assertTrue (documents .containsAll (list ));
287288 }
@@ -290,12 +291,12 @@ public void test_getDocuments() throws ArangoException {
290291 public void test_getDocuments_handle () throws ArangoException {
291292
292293 // create document
293- DocumentEntity <TestComplexEntity01 > doc1 = driver .createDocument (collectionName , new TestComplexEntity01 (
294- "test-user1" , "test-user1-desc" , 21 ), true , false );
295- DocumentEntity <TestComplexEntity01 > doc2 = driver .createDocument (collectionName , new TestComplexEntity01 (
296- "test-user2" , "test-user2-desc" , 22 ), true , false );
297- DocumentEntity <TestComplexEntity01 > doc3 = driver .createDocument (collectionName , new TestComplexEntity01 (
298- "test-user3" , "test-user3-desc" , 23 ), true , false );
294+ DocumentEntity <TestComplexEntity01 > doc1 = driver .createDocument (collectionName ,
295+ new TestComplexEntity01 ( "test-user1" , "test-user1-desc" , 21 ), true , false );
296+ DocumentEntity <TestComplexEntity01 > doc2 = driver .createDocument (collectionName ,
297+ new TestComplexEntity01 ( "test-user2" , "test-user2-desc" , 22 ), true , false );
298+ DocumentEntity <TestComplexEntity01 > doc3 = driver .createDocument (collectionName ,
299+ new TestComplexEntity01 ( "test-user3" , "test-user3-desc" , 23 ), true , false );
299300 assertThat (doc1 , is (notNullValue ()));
300301 assertThat (doc2 , is (notNullValue ()));
301302 assertThat (doc3 , is (notNullValue ()));
@@ -312,8 +313,8 @@ public void test_getDocuments_handle() throws ArangoException {
312313 prefix = "" ;
313314 }
314315
315- List <String > list = Arrays .asList (prefix + doc1 .getDocumentHandle (), prefix + doc2 .getDocumentHandle (), prefix
316- + doc3 .getDocumentHandle ());
316+ List <String > list = Arrays .asList (prefix + doc1 .getDocumentHandle (), prefix + doc2 .getDocumentHandle (),
317+ prefix + doc3 .getDocumentHandle ());
317318
318319 assertTrue (documents .containsAll (list ));
319320 }
@@ -340,8 +341,8 @@ public void test_get_document() throws ArangoException {
340341 @ Test
341342 public void test_get_document_with_instance_creator () throws ArangoException {
342343 // save an instance of TestInterfaceImpl with null as "name"
343- DocumentEntity <TestInterfaceImpl > doc = driver .createDocument (collectionName , new TestInterfaceImpl (null ),
344- null , false );
344+ DocumentEntity <TestInterfaceImpl > doc = driver .createDocument (collectionName , new TestInterfaceImpl (null ), null ,
345+ false );
345346
346347 assertThat (doc .getDocumentKey (), is (notNullValue ()));
347348 assertThat (doc .getDocumentHandle (), is (collectionName + "/" + doc .getDocumentKey ()));
@@ -470,8 +471,7 @@ public void test_checkDocument() throws ArangoException {
470471 @ Test
471472 public void test_check_document_doc_not_found () throws ArangoException {
472473
473- DocumentEntity <TestComplexEntity02 > doc = driver .createDocument (collectionName ,
474- new TestComplexEntity02 (1 , 2 , 3 ), null , null );
474+ driver .createDocument (collectionName , new TestComplexEntity02 (1 , 2 , 3 ), null , null );
475475
476476 try {
477477 driver .checkDocument (collectionName , 1 );
@@ -486,8 +486,7 @@ public void test_check_document_doc_not_found() throws ArangoException {
486486 public void test_delete () throws ArangoException {
487487 DocumentEntity <TestComplexEntity02 > doc = driver .createDocument (collectionName ,
488488 new TestComplexEntity02 (1 , 2 , 3 ));
489- DocumentEntity a = driver .deleteDocument (doc .getDocumentHandle ());
490-
489+ driver .deleteDocument (doc .getDocumentHandle ());
491490 }
492491
493492 @ Test
@@ -500,4 +499,25 @@ public void test_delete_doc_not_found() throws ArangoException {
500499 }
501500 }
502501
502+ @ Test
503+ public void test_BaseDocumentProperties () throws ArangoException {
504+ // create a document
505+ BaseDocument myObject = new BaseDocument ();
506+ myObject .setDocumentKey ("myKey" );
507+ myObject .addAttribute ("a" , "Foo" );
508+ myObject .addAttribute ("b" , 42 );
509+ driver .createDocument (collectionName , myObject );
510+
511+ // read a document
512+ DocumentEntity <BaseDocument > myDocument = null ;
513+ BaseDocument myObject2 = null ;
514+ myDocument = driver .getDocument (collectionName , "myKey" , BaseDocument .class );
515+ myObject2 = myDocument .getEntity ();
516+
517+ assertThat (myObject2 .getProperties ().get ("a" ), is (notNullValue ()));
518+ assertThat ((String ) myObject2 .getProperties ().get ("a" ), is ("Foo" ));
519+ assertThat (myObject2 .getProperties ().get ("b" ), is (notNullValue ()));
520+ assertThat ((Double ) myObject2 .getProperties ().get ("b" ), is (42.0 ));
521+ assertThat (myObject2 .getProperties ().get ("c" ), is (nullValue ()));
522+ }
503523}
0 commit comments