Skip to content

Commit b909837

Browse files
author
Mark
committed
fixed issue #43 (ArangoDriver.getAqlFunctions(String) does not uses the
defaultDatabase setting)
1 parent 77fd4cb commit b909837

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

ChangeLog

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
v2.7.5 (2016-XX-XX)
1+
v2.7.5 (2016-11-25)
22
---------------------------
3-
3+
* fixed issue #43 (ArangoDriver.getAqlFunctions(String) does not uses the defaultDatabase setting)
44

55
v2.7.4 (2016-04-15)
66
---------------------------

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5365,7 +5365,7 @@ public <V, E> ShortestPathEntity<V, E> graphGetShortestPath(
53655365
* @throws ArangoException
53665366
*/
53675367
public DefaultEntity createAqlFunction(String name, String code) throws ArangoException {
5368-
return aqlFunctionsDriver.createAqlFunction(name, code);
5368+
return aqlFunctionsDriver.createAqlFunction(getDefaultDatabase(), name, code);
53695369
}
53705370

53715371
/**
@@ -5377,7 +5377,7 @@ public DefaultEntity createAqlFunction(String name, String code) throws ArangoEx
53775377
* @throws ArangoException
53785378
*/
53795379
public AqlFunctionsEntity getAqlFunctions(String namespace) throws ArangoException {
5380-
return aqlFunctionsDriver.getAqlFunctions(namespace);
5380+
return aqlFunctionsDriver.getAqlFunctions(getDefaultDatabase(), namespace);
53815381
}
53825382

53835383
/**
@@ -5392,7 +5392,7 @@ public AqlFunctionsEntity getAqlFunctions(String namespace) throws ArangoExcepti
53925392
* @throws ArangoException
53935393
*/
53945394
public DefaultEntity deleteAqlFunction(String name, boolean isNameSpace) throws ArangoException {
5395-
return aqlFunctionsDriver.deleteAqlFunction(name, isNameSpace);
5395+
return aqlFunctionsDriver.deleteAqlFunction(getDefaultDatabase(), name, isNameSpace);
53965396
}
53975397

53985398
/**

src/main/java/com/arangodb/InternalAqlFunctionsDriver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* Created by fbartels on 10/27/14.
99
*/
1010
public interface InternalAqlFunctionsDriver extends BaseDriverInterface {
11-
DefaultEntity createAqlFunction(String name, String code) throws ArangoException;
11+
DefaultEntity createAqlFunction(String database, String name, String code) throws ArangoException;
1212

13-
AqlFunctionsEntity getAqlFunctions(String namespace) throws ArangoException;
13+
AqlFunctionsEntity getAqlFunctions(String database, String namespace) throws ArangoException;
1414

15-
DefaultEntity deleteAqlFunction(String name, boolean isNameSpace) throws ArangoException;
15+
DefaultEntity deleteAqlFunction(String database, String name, boolean isNameSpace) throws ArangoException;
1616
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,30 @@ public class InternalAqlFunctionsDriverImpl extends BaseArangoDriverImpl
3939
}
4040

4141
@Override
42-
public DefaultEntity createAqlFunction(String name, String code) throws ArangoException {
42+
public DefaultEntity createAqlFunction(String database, String name, String code) throws ArangoException {
4343
HttpResponseEntity res = httpManager.doPost(
44-
createEndpointUrl(configure.getDefaultDatabase(), API_AQLFUNCTION), null,
44+
createEndpointUrl(database, API_AQLFUNCTION), null,
4545
EntityFactory.toJsonString(new MapBuilder().put("name", name).put("code", code).get()));
4646
return createEntity(res, DefaultEntity.class, null, false);
4747
}
4848

4949
@Override
50-
public AqlFunctionsEntity getAqlFunctions(String namespace) throws ArangoException {
50+
public AqlFunctionsEntity getAqlFunctions(String database, String namespace) throws ArangoException {
5151

5252
String appendix = "";
5353
if (namespace != null) {
5454
appendix = "?namespace=" + namespace;
5555
}
56-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, API_AQLFUNCTION + appendix));
56+
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(database, API_AQLFUNCTION + appendix));
5757
return createEntity(res, AqlFunctionsEntity.class);
5858

5959
}
6060

6161
@Override
62-
public DefaultEntity deleteAqlFunction(String name, boolean isNameSpace) throws ArangoException {
62+
public DefaultEntity deleteAqlFunction(String database, String name, boolean isNameSpace) throws ArangoException {
6363

6464
HttpResponseEntity res = httpManager.doDelete(
65-
createEndpointUrl(configure.getDefaultDatabase(), API_AQLFUNCTION, name),
65+
createEndpointUrl(database, API_AQLFUNCTION, name),
6666
new MapBuilder().put("group", isNameSpace).get());
6767

6868
return createEntity(res, DefaultEntity.class);

src/test/java/com/arangodb/ArangoDriverAqlfunctionsTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
import java.util.Iterator;
2525

2626
import org.junit.After;
27+
import org.junit.Assert;
2728
import org.junit.Before;
2829
import org.junit.Test;
2930

3031
import com.arangodb.entity.AqlFunctionsEntity;
32+
import com.arangodb.entity.CollectionEntity;
3133
import com.arangodb.entity.DefaultEntity;
3234

3335
/**
@@ -57,6 +59,11 @@ public void after() {
5759
@Test
5860
public void test_AqlFunctions() throws ArangoException {
5961

62+
{
63+
CollectionEntity count = driver.getCollectionCount("_aqlfunctions");
64+
Assert.assertEquals(0, count.getCount());
65+
}
66+
6067
DefaultEntity res = driver.createAqlFunction(
6168
"someNamespace::testCode", "function (celsius) { return celsius * 2.8 + 32; }"
6269
);
@@ -83,6 +90,11 @@ public void test_AqlFunctions() throws ArangoException {
8390
assertThat(res.getCode(), is(201));
8491
assertThat(res.getErrorMessage(), is((String) null));
8592

93+
{
94+
CollectionEntity count = driver.getCollectionCount("_aqlfunctions");
95+
Assert.assertEquals(3, count.getCount());
96+
}
97+
8698
AqlFunctionsEntity r = driver.getAqlFunctions(null);
8799
assertThat(r.size() , is(3));
88100
assertTrue(r.getAqlFunctions().keySet().contains("anotherNamespace::testCode"));

0 commit comments

Comments
 (0)