Skip to content

Commit

Permalink
Merge pull request #295 from rashtao/feature/expose-arangodb-driver
Browse files Browse the repository at this point in the history
ArangoDB: expose driver
  • Loading branch information
otaviojava authored Nov 13, 2024
2 parents 3c1ae94 + 3640d39 commit 9542d66
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*
* Contributors:
*
* Michele Rastelli
*/
package org.eclipse.jnosql.databases.arangodb.communication;

import com.arangodb.ArangoDB;

public interface ArangoDBAccessor {

/**
* Accessor for the underlying ArangoDB driver instance.
*
* @return the {@link ArangoDB} instance
*/
ArangoDB getArangoDB();

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* <p>{@link BucketManager#put(Iterable, Duration)}</p>
* <p>{@link BucketManager#put(Iterable, Duration)}</p>
*/
public class ArangoDBBucketManager implements BucketManager {
public class ArangoDBBucketManager implements BucketManager, ArangoDBAccessor {


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

@Override
public ArangoDB getArangoDB() {
return arangoDB;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* The ArangoDB implementation of {@link DatabaseManager}. This implementation does not support TTL methods in the context of
* {@link DatabaseManager#insert(org.eclipse.jnosql.communication.semistructured.CommunicationEntity)}.
*/
public interface ArangoDBDocumentManager extends DatabaseManager {
public interface ArangoDBDocumentManager extends DatabaseManager, ArangoDBAccessor {

/**
* Executes an ArangoDB query using the ArangoDB Query Language (AQL).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,15 @@ public Iterable<CommunicationEntity> insert(Iterable<CommunicationEntity> entiti
.collect(Collectors.toList());
}

@Override
public ArangoDB getArangoDB() {
return arangoDB;
}

private void updateEntity(CommunicationEntity entity, String key, String id, String rev) {
entity.add(Element.of(KEY, key));
entity.add(Element.of(ID, id));
entity.add(Element.of(REV, rev));
}

ArangoDB getArangoDB() {
return arangoDB;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ void shouldIncludeSkip() {
org.assertj.core.api.Assertions.assertThat(indexes).hasSize(15);
}

@Test
void shouldExposeArangoDB() {
ArangoDB adb = entityManager.getArangoDB();
assertThat(adb).isNotNull();
assertThat(adb.getVersion()).isNotNull();
}

private CommunicationEntity getEntity() {
CommunicationEntity entity = CommunicationEntity.of(COLLECTION_NAME);
Map<String, Object> map = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

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

import com.arangodb.ArangoDB;
import org.eclipse.jnosql.communication.Value;
import org.eclipse.jnosql.communication.keyvalue.BucketManager;
import org.eclipse.jnosql.communication.keyvalue.BucketManagerFactory;
Expand Down Expand Up @@ -118,4 +119,14 @@ public void shouldRemoveMultiKey() {
Iterable<Value> users = values;
assertEquals(0L, StreamSupport.stream(keyValueEntityManager.get(keys).spliterator(), false).count());
}

@Test
void getArangoDB() {
assertThat(keyValueEntityManager).isInstanceOf(ArangoDBBucketManager.class);
ArangoDBBucketManager adbAccessor = (ArangoDBBucketManager) keyValueEntityManager;
ArangoDB adb = adbAccessor.getArangoDB();
assertThat(adb).isNotNull();
assertThat(adb.getVersion()).isNotNull();
}

}

0 comments on commit 9542d66

Please sign in to comment.