Skip to content

Commit 9542d66

Browse files
authored
Merge pull request #295 from rashtao/feature/expose-arangodb-driver
ArangoDB: expose driver
2 parents 3c1ae94 + 3640d39 commit 9542d66

File tree

6 files changed

+58
-6
lines changed

6 files changed

+58
-6
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2022 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Michele Rastelli
14+
*/
15+
package org.eclipse.jnosql.databases.arangodb.communication;
16+
17+
import com.arangodb.ArangoDB;
18+
19+
public interface ArangoDBAccessor {
20+
21+
/**
22+
* Accessor for the underlying ArangoDB driver instance.
23+
*
24+
* @return the {@link ArangoDB} instance
25+
*/
26+
ArangoDB getArangoDB();
27+
28+
}

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBBucketManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* <p>{@link BucketManager#put(Iterable, Duration)}</p>
4141
* <p>{@link BucketManager#put(Iterable, Duration)}</p>
4242
*/
43-
public class ArangoDBBucketManager implements BucketManager {
43+
public class ArangoDBBucketManager implements BucketManager, ArangoDBAccessor {
4444

4545

4646
private static final String KEY = "_key";
@@ -145,4 +145,9 @@ public void put(KeyValueEntity entity, Duration ttl) throws NullPointerException
145145
throw new UnsupportedOperationException("ArangoDB does not support TTL");
146146
}
147147

148+
@Override
149+
public ArangoDB getArangoDB() {
150+
return arangoDB;
151+
}
152+
148153
}

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBDocumentManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* The ArangoDB implementation of {@link DatabaseManager}. This implementation does not support TTL methods in the context of
2424
* {@link DatabaseManager#insert(org.eclipse.jnosql.communication.semistructured.CommunicationEntity)}.
2525
*/
26-
public interface ArangoDBDocumentManager extends DatabaseManager {
26+
public interface ArangoDBDocumentManager extends DatabaseManager, ArangoDBAccessor {
2727

2828
/**
2929
* Executes an ArangoDB query using the ArangoDB Query Language (AQL).

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/DefaultArangoDBDocumentManager.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,15 @@ public Iterable<CommunicationEntity> insert(Iterable<CommunicationEntity> entiti
201201
.collect(Collectors.toList());
202202
}
203203

204+
@Override
205+
public ArangoDB getArangoDB() {
206+
return arangoDB;
207+
}
208+
204209
private void updateEntity(CommunicationEntity entity, String key, String id, String rev) {
205210
entity.add(Element.of(KEY, key));
206211
entity.add(Element.of(ID, id));
207212
entity.add(Element.of(REV, rev));
208213
}
209214

210-
ArangoDB getArangoDB() {
211-
return arangoDB;
212-
}
213-
214215
}

jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBDocumentManagerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,13 @@ void shouldIncludeSkip() {
322322
org.assertj.core.api.Assertions.assertThat(indexes).hasSize(15);
323323
}
324324

325+
@Test
326+
void shouldExposeArangoDB() {
327+
ArangoDB adb = entityManager.getArangoDB();
328+
assertThat(adb).isNotNull();
329+
assertThat(adb.getVersion()).isNotNull();
330+
}
331+
325332
private CommunicationEntity getEntity() {
326333
CommunicationEntity entity = CommunicationEntity.of(COLLECTION_NAME);
327334
Map<String, Object> map = new HashMap<>();

jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBKeyValueEntityManagerTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
package org.eclipse.jnosql.databases.arangodb.communication;
1717

18+
import com.arangodb.ArangoDB;
1819
import org.eclipse.jnosql.communication.Value;
1920
import org.eclipse.jnosql.communication.keyvalue.BucketManager;
2021
import org.eclipse.jnosql.communication.keyvalue.BucketManagerFactory;
@@ -118,4 +119,14 @@ public void shouldRemoveMultiKey() {
118119
Iterable<Value> users = values;
119120
assertEquals(0L, StreamSupport.stream(keyValueEntityManager.get(keys).spliterator(), false).count());
120121
}
122+
123+
@Test
124+
void getArangoDB() {
125+
assertThat(keyValueEntityManager).isInstanceOf(ArangoDBBucketManager.class);
126+
ArangoDBBucketManager adbAccessor = (ArangoDBBucketManager) keyValueEntityManager;
127+
ArangoDB adb = adbAccessor.getArangoDB();
128+
assertThat(adb).isNotNull();
129+
assertThat(adb.getVersion()).isNotNull();
130+
}
131+
121132
}

0 commit comments

Comments
 (0)