Skip to content

Commit e76fc06

Browse files
author
Mark
committed
fixed issue 42: ArangoDriver.getAqlFunctions(String) does not uses the
defaultDatabase setting
1 parent 44a739d commit e76fc06

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v3.0.1 (2016-07-08)
2+
---------------------------
3+
* added flag complete and details in ImportOptions
4+
* fixed issue #43 (ArangoDriver.getAqlFunctions(String) does not uses the defaultDatabase setting)
5+
16
v3.0.0 (2016-06-17)
27
---------------------------
38
* removed ArangoDriver.EdgeEntity() (/_api/edge withdrawn in Server)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4596,7 +4596,7 @@ public <V, E> ShortestPathEntity<V, E> graphGetShortestPath(
45964596
* @throws ArangoException
45974597
*/
45984598
public DefaultEntity createAqlFunction(final String name, final String code) throws ArangoException {
4599-
return aqlFunctionsDriver.createAqlFunction(name, code);
4599+
return aqlFunctionsDriver.createAqlFunction(getDefaultDatabase(), name, code);
46004600
}
46014601

46024602
/**
@@ -4608,7 +4608,7 @@ public DefaultEntity createAqlFunction(final String name, final String code) thr
46084608
* @throws ArangoException
46094609
*/
46104610
public AqlFunctionsEntity getAqlFunctions(final String namespace) throws ArangoException {
4611-
return aqlFunctionsDriver.getAqlFunctions(namespace);
4611+
return aqlFunctionsDriver.getAqlFunctions(getDefaultDatabase(), namespace);
46124612
}
46134613

46144614
/**
@@ -4623,7 +4623,7 @@ public AqlFunctionsEntity getAqlFunctions(final String namespace) throws ArangoE
46234623
* @throws ArangoException
46244624
*/
46254625
public DefaultEntity deleteAqlFunction(final String name, final boolean isNameSpace) throws ArangoException {
4626-
return aqlFunctionsDriver.deleteAqlFunction(name, isNameSpace);
4626+
return aqlFunctionsDriver.deleteAqlFunction(getDefaultDatabase(), name, isNameSpace);
46274627
}
46284628

46294629
/**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
/**
88
* Created by fbartels on 10/27/14.
99
*/
10-
public interface InternalAqlFunctionsDriver extends BaseDriverInterface {
11-
DefaultEntity createAqlFunction(String name, String code) throws ArangoException;
10+
public interface InternalAqlFunctionsDriver extends BaseDriverInterface {
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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,28 @@ public class InternalAqlFunctionsDriverImpl extends BaseArangoDriverImpl
3939
}
4040

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

4948
@Override
50-
public AqlFunctionsEntity getAqlFunctions(String namespace) throws ArangoException {
49+
public AqlFunctionsEntity getAqlFunctions(String database, String namespace) throws ArangoException {
5150

5251
String appendix = "";
5352
if (namespace != null) {
5453
appendix = "?namespace=" + namespace;
5554
}
56-
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(null, API_AQLFUNCTION + appendix));
55+
HttpResponseEntity res = httpManager.doGet(createEndpointUrl(database, API_AQLFUNCTION + appendix));
5756
return createEntity(res, AqlFunctionsEntity.class);
5857

5958
}
6059

6160
@Override
62-
public DefaultEntity deleteAqlFunction(String name, boolean isNameSpace) throws ArangoException {
61+
public DefaultEntity deleteAqlFunction(String database, String name, boolean isNameSpace) throws ArangoException {
6362

64-
HttpResponseEntity res = httpManager.doDelete(
65-
createEndpointUrl(configure.getDefaultDatabase(), API_AQLFUNCTION, name),
63+
HttpResponseEntity res = httpManager.doDelete(createEndpointUrl(database, API_AQLFUNCTION, name),
6664
new MapBuilder().put("group", isNameSpace).get());
6765

6866
return createEntity(res, DefaultEntity.class);

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

Lines changed: 11 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
/**
@@ -51,6 +53,10 @@ public void after() {
5153

5254
@Test
5355
public void test_AqlFunctions() throws ArangoException {
56+
{
57+
final CollectionEntity count = driver.getCollectionCount("_aqlfunctions");
58+
Assert.assertEquals(0, count.getCount());
59+
}
5460

5561
DefaultEntity res = driver.createAqlFunction("someNamespace::testCode",
5662
"function (celsius) { return celsius * 2.8 + 32; }");
@@ -74,6 +80,11 @@ public void test_AqlFunctions() throws ArangoException {
7480
assertThat(res.getCode(), is(201));
7581
assertThat(res.getErrorMessage(), is((String) null));
7682

83+
{
84+
final CollectionEntity count = driver.getCollectionCount("_aqlfunctions");
85+
Assert.assertEquals(3, count.getCount());
86+
}
87+
7788
AqlFunctionsEntity r = driver.getAqlFunctions(null);
7889
assertThat(r.size(), is(3));
7990
assertTrue(r.getAqlFunctions().keySet().contains("anotherNamespace::testCode"));

0 commit comments

Comments
 (0)