Skip to content

Commit 6185cb4

Browse files
author
Achim Brandt
committed
fixed issue #19
1 parent 22304f6 commit 6185cb4

File tree

3 files changed

+72
-78
lines changed

3 files changed

+72
-78
lines changed

src/main/java/com/arangodb/ArangoDriver.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,9 @@ public <T> T getBatchResponseByRequestId(String requestId) throws ArangoExceptio
466466
try {
467467
this.httpManager.setPreDefinedResponse(batchResponseEntity.getHttpResponseEntity());
468468

469-
T result = (T) batchResponseEntity
470-
.getInvocationObject()
471-
.getMethod()
472-
.invoke(batchResponseEntity.getInvocationObject().getArangoDriver(),
473-
batchResponseEntity.getInvocationObject().getArgs());
469+
T result = (T) batchResponseEntity.getInvocationObject().getMethod().invoke(
470+
batchResponseEntity.getInvocationObject().getArangoDriver(),
471+
batchResponseEntity.getInvocationObject().getArgs());
474472
this.httpManager.setPreDefinedResponse(null);
475473
return result;
476474
} catch (InvocationTargetException e) {
@@ -937,7 +935,8 @@ public <T> DocumentEntity<T> createDocument(String collectionName, T value) thro
937935
* @throws ArangoException
938936
* @see CollectionKeyOption#allowUserKeys
939937
*/
940-
public DocumentEntity<?> createDocument(long collectionId, String documentKey, Object value) throws ArangoException {
938+
public DocumentEntity<?> createDocument(long collectionId, String documentKey, Object value)
939+
throws ArangoException {
941940
return createDocument(String.valueOf(collectionId), documentKey, value, null, null);
942941
}
943942

@@ -1065,8 +1064,8 @@ public <T> DocumentEntity<T> createDocument(
10651064
T value,
10661065
Boolean createCollection,
10671066
Boolean waitForSync) throws ArangoException {
1068-
return documentDriver.createDocument(getDefaultDatabase(), collectionName, documentKey, value,
1069-
createCollection, waitForSync);
1067+
return documentDriver.createDocument(getDefaultDatabase(), collectionName, documentKey, value, createCollection,
1068+
waitForSync);
10701069
}
10711070

10721071
/**
@@ -1115,7 +1114,8 @@ public <T> DocumentEntity<T> replaceDocument(String collectionName, long documen
11151114
* @return DocumentEntity<?>
11161115
* @throws ArangoException
11171116
*/
1118-
public <T> DocumentEntity<T> replaceDocument(long collectionId, String documentKey, T value) throws ArangoException {
1117+
public <T> DocumentEntity<T> replaceDocument(long collectionId, String documentKey, T value)
1118+
throws ArangoException {
11191119
return replaceDocument(createDocumentHandle(collectionId, documentKey), value, null, null, null);
11201120
}
11211121

@@ -1346,8 +1346,8 @@ public DocumentEntity<?> updateDocument(long collectionId, long documentId, Obje
13461346
*/
13471347
public DocumentEntity<?> updateDocument(String collectionName, long documentId, Object value)
13481348
throws ArangoException {
1349-
return updateDocument(createDocumentHandle(collectionName, String.valueOf(documentId)), value, null, null,
1350-
null, null);
1349+
return updateDocument(createDocumentHandle(collectionName, String.valueOf(documentId)), value, null, null, null,
1350+
null);
13511351
}
13521352

13531353
/**
@@ -1362,7 +1362,8 @@ public DocumentEntity<?> updateDocument(String collectionName, long documentId,
13621362
* @return DocumentEntity<?>
13631363
* @throws ArangoException
13641364
*/
1365-
public DocumentEntity<?> updateDocument(long collectionId, String documentKey, Object value) throws ArangoException {
1365+
public DocumentEntity<?> updateDocument(long collectionId, String documentKey, Object value)
1366+
throws ArangoException {
13661367
return updateDocument(createDocumentHandle(collectionId, documentKey), value, null, null, null, null);
13671368
}
13681369

@@ -1433,8 +1434,8 @@ public DocumentEntity<?> updateDocument(long collectionId, long documentId, Obje
14331434
*/
14341435
public DocumentEntity<?> updateDocument(String collectionName, long documentId, Object value, Boolean keepNull)
14351436
throws ArangoException {
1436-
return updateDocument(createDocumentHandle(collectionName, String.valueOf(documentId)), value, null, null,
1437-
null, keepNull);
1437+
return updateDocument(createDocumentHandle(collectionName, String.valueOf(documentId)), value, null, null, null,
1438+
keepNull);
14381439
}
14391440

14401441
/**
@@ -1807,7 +1808,8 @@ public long checkDocument(String documentHandle) throws ArangoException {
18071808
* @return a DocumentEntity object
18081809
* @throws ArangoException
18091810
*/
1810-
public <T> DocumentEntity<T> getDocument(long collectionId, long documentId, Class<T> clazz) throws ArangoException {
1811+
public <T> DocumentEntity<T> getDocument(long collectionId, long documentId, Class<T> clazz)
1812+
throws ArangoException {
18111813
return getDocument(createDocumentHandle(collectionId, String.valueOf(documentId)), clazz);
18121814
}
18131815

@@ -2566,8 +2568,8 @@ public IndexEntity createSkipListIndex(String collectionName, boolean unique, St
25662568
*/
25672569
public IndexEntity createSkipListIndex(String collectionName, boolean unique, boolean sparse, String... fields)
25682570
throws ArangoException {
2569-
return indexDriver
2570-
.createIndex(getDefaultDatabase(), collectionName, IndexType.SKIPLIST, unique, sparse, fields);
2571+
return indexDriver.createIndex(getDefaultDatabase(), collectionName, IndexType.SKIPLIST, unique, sparse,
2572+
fields);
25712573
}
25722574

25732575
/**
@@ -3310,8 +3312,8 @@ public <T> CursorEntity<DocumentEntity<T>> executeSimpleRangeWithDocument(
33103312
int skip,
33113313
int limit,
33123314
Class<T> clazz) throws ArangoException {
3313-
return simpleDriver.executeSimpleRangeWithDocument(getDefaultDatabase(), collectionName, attribute, left,
3314-
right, closed, skip, limit, clazz);
3315+
return simpleDriver.executeSimpleRangeWithDocument(getDefaultDatabase(), collectionName, attribute, left, right,
3316+
closed, skip, limit, clazz);
33153317
}
33163318

33173319
/**
@@ -4237,8 +4239,8 @@ public GraphEntity createGraph(
42374239
List<EdgeDefinitionEntity> edgeDefinitions,
42384240
List<String> orphanCollections,
42394241
Boolean waitForSync) throws ArangoException {
4240-
return graphDriver
4241-
.createGraph(getDefaultDatabase(), graphName, edgeDefinitions, orphanCollections, waitForSync);
4242+
return graphDriver.createGraph(getDefaultDatabase(), graphName, edgeDefinitions, orphanCollections,
4243+
waitForSync);
42424244
}
42434245

42444246
/**
@@ -4255,8 +4257,8 @@ public GraphEntity createGraph(GraphEntity graph, Boolean waitForSync) throws Ar
42554257
String graphName = graph.getName();
42564258
List<EdgeDefinitionEntity> edgeDefinitions = graph.getEdgeDefinitions();
42574259
List<String> orphanCollections = graph.getOrphanCollections();
4258-
return graphDriver
4259-
.createGraph(getDefaultDatabase(), graphName, edgeDefinitions, orphanCollections, waitForSync);
4260+
return graphDriver.createGraph(getDefaultDatabase(), graphName, edgeDefinitions, orphanCollections,
4261+
waitForSync);
42604262
}
42614263

42624264
/**
@@ -4612,8 +4614,8 @@ public DeletedEntity graphDeleteVertex(
46124614
*/
46134615
public <T> VertexEntity<T> graphReplaceVertex(String graphName, String collectionName, String key, T vertex)
46144616
throws ArangoException {
4615-
return graphDriver
4616-
.replaceVertex(getDefaultDatabase(), graphName, collectionName, key, vertex, null, null, null);
4617+
return graphDriver.replaceVertex(getDefaultDatabase(), graphName, collectionName, key, vertex, null, null,
4618+
null);
46174619
}
46184620

46194621
/**
@@ -4891,8 +4893,8 @@ public DeletedEntity graphDeleteEdge(String graphName, String edgeCollectionName
48914893
*/
48924894
public DeletedEntity graphDeleteEdge(String graphName, String edgeCollectionName, String key, Boolean waitForSync)
48934895
throws ArangoException {
4894-
return graphDriver
4895-
.deleteEdge(getDefaultDatabase(), graphName, edgeCollectionName, key, waitForSync, null, null);
4896+
return graphDriver.deleteEdge(getDefaultDatabase(), graphName, edgeCollectionName, key, waitForSync, null,
4897+
null);
48964898
}
48974899

48984900
/**
@@ -5434,8 +5436,6 @@ public TransactionResultEntity executeTransaction(TransactionEntity transactionE
54345436
/**
54355437
* Create an edge in an edge collection.
54365438
*
5437-
* @param graphName
5438-
* the graph name
54395439
* @param collectionName
54405440
* name of the edge collection
54415441
* @param object
@@ -5452,15 +5452,15 @@ public TransactionResultEntity executeTransaction(TransactionEntity transactionE
54525452
* @throws ArangoException
54535453
*/
54545454
public <T> EdgeEntity<T> createEdge(
5455-
String graphName,
54565455
String collectionName,
54575456
T object,
54585457
String from,
54595458
String to,
54605459
Boolean createCollection,
54615460
Boolean waitForSync) throws ArangoException {
54625461

5463-
return this.edgeDriver.createEdge(graphName, collectionName, object, from, to, createCollection, waitForSync);
5462+
return this.edgeDriver.createEdge(getDefaultDatabase(), collectionName, object, from, to, createCollection,
5463+
waitForSync);
54645464
}
54655465

54665466
/**

src/main/java/com/arangodb/impl/InternalEdgeDriverImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class InternalEdgeDriverImpl extends BaseArangoDriverWithCursorImpl imple
3838

3939
@Override
4040
public <T> EdgeEntity<T> createEdge(
41-
String graphName,
41+
String database,
4242
String collectionName,
4343
T object,
4444
String from,
@@ -51,7 +51,7 @@ public <T> EdgeEntity<T> createEdge(
5151

5252
String body = EntityFactory.toJsonString(object);
5353

54-
HttpResponseEntity response = httpManager.doPost(createEndpointUrl(graphName, "/_api/edge"), params, body);
54+
HttpResponseEntity response = httpManager.doPost(createEndpointUrl(database, "/_api/edge"), params, body);
5555

5656
@SuppressWarnings("unchecked")
5757
EdgeEntity<T> edgeEntity = createEntity(response, EdgeEntity.class);

src/test/java/com/arangodb/ArangoDriverEdgeTest.java

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,57 +33,51 @@
3333
*/
3434
public class ArangoDriverEdgeTest extends BaseTest {
3535

36-
public ArangoDriverEdgeTest(ArangoConfigure configure, ArangoDriver driver) {
37-
super(configure, driver);
38-
}
36+
public ArangoDriverEdgeTest(ArangoConfigure configure, ArangoDriver driver) {
37+
super(configure, driver);
38+
}
3939

40-
final String collectionName = "unit_test_edge_collection_EdgeTest";
41-
final String collectionName2 = "unit_test_normal_collection_EdgeTest";
40+
final String collectionName = "unit_test_edge_collection_EdgeTest";
41+
final String collectionName2 = "unit_test_normal_collection_EdgeTest";
4242

43-
@Before
44-
public void before() throws ArangoException {
45-
try {
46-
driver.deleteCollection(collectionName);
47-
} catch (ArangoException e) {
48-
}
49-
try {
50-
driver.deleteCollection(collectionName2);
51-
} catch (ArangoException e) {
52-
}
53-
}
43+
@Before
44+
public void before() throws ArangoException {
45+
try {
46+
driver.deleteCollection(collectionName);
47+
} catch (ArangoException e) {
48+
}
49+
try {
50+
driver.deleteCollection(collectionName2);
51+
} catch (ArangoException e) {
52+
}
53+
}
5454

55-
@After
56-
public void after() throws ArangoException {
57-
try {
58-
driver.deleteCollection(collectionName);
59-
} catch (ArangoException e) {
60-
}
61-
try {
62-
driver.deleteCollection(collectionName2);
63-
} catch (ArangoException e) {
64-
}
65-
}
55+
@After
56+
public void after() throws ArangoException {
57+
try {
58+
driver.deleteCollection(collectionName);
59+
} catch (ArangoException e) {
60+
}
61+
try {
62+
driver.deleteCollection(collectionName2);
63+
} catch (ArangoException e) {
64+
}
65+
}
6666

67-
@Test
68-
public void test_create_normal() throws ArangoException {
67+
@Test
68+
public void test_create_normal() throws ArangoException {
6969

70-
TestComplexEntity01 value = new TestComplexEntity01("user", "desc", 42);
71-
DocumentEntity<TestComplexEntity01> fromDoc = driver.createDocument(collectionName2, value, true, true);
72-
DocumentEntity<TestComplexEntity01> toDoc = driver.createDocument(collectionName2, value, true, true);
73-
74-
EdgeEntity<TestComplexEntity01> doc = driver.createEdge(
75-
DATABASE_NAME,
76-
collectionName,
77-
value,
78-
fromDoc.getDocumentHandle(),
79-
toDoc.getDocumentHandle(),
80-
true,
81-
true);
70+
TestComplexEntity01 value = new TestComplexEntity01("user", "desc", 42);
71+
DocumentEntity<TestComplexEntity01> fromDoc = driver.createDocument(collectionName2, value, true, true);
72+
DocumentEntity<TestComplexEntity01> toDoc = driver.createDocument(collectionName2, value, true, true);
8273

83-
assertThat(doc.getDocumentKey(), is(notNullValue()));
84-
assertThat(doc.getDocumentHandle(), is(collectionName + "/" + doc.getDocumentKey()));
85-
assertThat(doc.getDocumentRevision(), is(not(0L)));
74+
EdgeEntity<TestComplexEntity01> doc = driver.createEdge(collectionName, value, fromDoc.getDocumentHandle(),
75+
toDoc.getDocumentHandle(), true, true);
8676

87-
}
77+
assertThat(doc.getDocumentKey(), is(notNullValue()));
78+
assertThat(doc.getDocumentHandle(), is(collectionName + "/" + doc.getDocumentKey()));
79+
assertThat(doc.getDocumentRevision(), is(not(0L)));
80+
81+
}
8882

8983
}

0 commit comments

Comments
 (0)