1+ package com .arangodb ;
2+
3+ import org .junit .After ;
4+ import org .junit .Assert ;
5+ import org .junit .Before ;
6+ import org .junit .Test ;
7+
8+ import com .arangodb .entity .BaseDocument ;
9+ import com .arangodb .entity .CollectionOptions ;
10+ import com .arangodb .entity .CollectionType ;
11+ import com .arangodb .entity .DocumentEntity ;
12+
13+ /**
14+ * @author Mark - mark@arangodb.com
15+ *
16+ */
17+ public class ArangoDriverEdgeTest extends BaseTest {
18+
19+ final String collectionName = "unit_test_edge_collection_EdgeTest" ;
20+ final String collectionName2 = "unit_test_normal_collection_EdgeTest" ;
21+
22+ @ Before
23+ public void before () throws ArangoException {
24+ try {
25+ driver .deleteCollection (collectionName );
26+ } catch (final ArangoException e ) {
27+ }
28+ try {
29+ final CollectionOptions collectionOptions = new CollectionOptions ();
30+ collectionOptions .setType (CollectionType .EDGE );
31+ driver .createCollection (collectionName , collectionOptions );
32+ } catch (final ArangoException e ) {
33+ }
34+ try {
35+ driver .deleteCollection (collectionName2 );
36+ } catch (final ArangoException e ) {
37+ }
38+ try {
39+ driver .createCollection (collectionName2 );
40+ } catch (final ArangoException e ) {
41+ }
42+ }
43+
44+ @ After
45+ public void after () throws ArangoException {
46+ try {
47+ driver .deleteCollection (collectionName );
48+ } catch (final ArangoException e ) {
49+ }
50+ try {
51+ driver .deleteCollection (collectionName2 );
52+ } catch (final ArangoException e ) {
53+ }
54+ }
55+
56+ @ Test
57+ public void test_create_normal () throws ArangoException {
58+
59+ final TestComplexEntity01 value = new TestComplexEntity01 ("user" , "desc" , 42 );
60+ final DocumentEntity <TestComplexEntity01 > fromDoc = driver .createDocument (collectionName2 , value , true );
61+ final DocumentEntity <TestComplexEntity01 > toDoc = driver .createDocument (collectionName2 , value , true );
62+
63+ final BaseDocument baseDocument = new BaseDocument ();
64+ baseDocument .addAttribute (BaseDocument .FROM , fromDoc .getDocumentHandle ());
65+ baseDocument .addAttribute (BaseDocument .TO , toDoc .getDocumentHandle ());
66+
67+ final DocumentEntity <BaseDocument > doc = driver .createDocument (collectionName , baseDocument , true );
68+
69+ Assert .assertNotNull (doc .getDocumentKey ());
70+ Assert .assertEquals (collectionName + "/" + doc .getDocumentKey (), doc .getDocumentHandle ());
71+ Assert .assertNotEquals (0L , doc .getDocumentRevision ());
72+ Assert .assertEquals (fromDoc .getDocumentHandle (), doc .getEntity ().getAttribute (BaseDocument .FROM ));
73+ Assert .assertEquals (toDoc .getDocumentHandle (), doc .getEntity ().getAttribute (BaseDocument .TO ));
74+
75+ }
76+
77+ }
0 commit comments