Skip to content

Commit 79aa0f0

Browse files
author
a-brandt
committed
changes and fixes for ArangoDB 2.6
1 parent 151136e commit 79aa0f0

File tree

7 files changed

+54
-33
lines changed

7 files changed

+54
-33
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import com.arangodb.entity.BatchResponseEntity;
3232
import com.arangodb.entity.BooleanResultEntity;
3333
import com.arangodb.entity.CollectionEntity;
34-
import com.arangodb.entity.CollectionKeyOption;
3534
import com.arangodb.entity.CollectionOptions;
3635
import com.arangodb.entity.CollectionsEntity;
3736
import com.arangodb.entity.CursorEntity;
@@ -2115,7 +2114,8 @@ public CursorEntity<?> validateQuery(String query) throws ArangoException {
21152114
* @param calcCount
21162115
* if set to true the result count is returned
21172116
* @param batchSize
2118-
* the batch size of the result cursor
2117+
* the batch size of the result cursor (The batch size has to be
2118+
* greater than 0)
21192119
* @param fullCount
21202120
* if set to true, then all results before the final LIMIT will
21212121
* be counted
@@ -2150,7 +2150,8 @@ public <T> CursorEntity<T> executeQuery(
21502150
* @param calcCount
21512151
* if set to true the result count is returned
21522152
* @param batchSize
2153-
* the batch size of the result cursor
2153+
* the batch size of the result cursor (The batch size has to be
2154+
* greater than 0)
21542155
* @param <T>
21552156
* @return <T> CursorEntity<T>
21562157
* @throws ArangoException
@@ -2209,7 +2210,8 @@ public DefaultEntity finishQuery(long cursorId) throws ArangoException {
22092210
* @param calcCount
22102211
* if set to true the result count is returned
22112212
* @param batchSize
2212-
* the batch size of the result cursor
2213+
* the batch size of the result cursor (The batch size has to be
2214+
* greater than 0)
22132215
* @param fullCount
22142216
* if set to true, then all results before the final LIMIT will
22152217
* be counted
@@ -2245,7 +2247,8 @@ public <T> CursorResultSet<T> executeQueryWithResultSet(
22452247
* @param calcCount
22462248
* if set to true the result count is returned
22472249
* @param batchSize
2248-
* the batch size of the result cursor
2250+
* the batch size of the result cursor (The batch size has to be
2251+
* greater than 0)
22492252
* @return CursorResultSet<T>
22502253
* @throws ArangoException
22512254
* @Deprecated As of release 2.5.4, replaced by
@@ -2276,7 +2279,8 @@ public <T> CursorResultSet<T> executeQueryWithResultSet(
22762279
* @param calcCount
22772280
* if set to true the result count is returned
22782281
* @param batchSize
2279-
* the batch size of the result cursor
2282+
* the batch size of the result cursor (The batch size has to be
2283+
* greater than 0)
22802284
* @param fullCount
22812285
* if set to true, then all results before the final LIMIT will
22822286
* be counted

src/main/java/com/arangodb/util/AqlQueryOptions.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public AqlQueryOptions setCount(Boolean count) {
4242
/**
4343
* maximum number of result documents to be transferred from the server to
4444
* the client in one roundtrip (optional). If this attribute is not set, a
45-
* server-controlled default value will be used.
45+
* server-controlled default value will be used. The batch size has to be
46+
* greater than 0.
4647
*
4748
* @return maximum number of result documents
4849
*/
@@ -53,7 +54,8 @@ public Integer getBatchSize() {
5354
/**
5455
* maximum number of result documents to be transferred from the server to
5556
* the client in one roundtrip (optional). If this attribute is not set, a
56-
* server-controlled default value will be used.
57+
* server-controlled default value will be used. The batch size has to be
58+
* greater than 0.
5759
*
5860
* @param batchSize
5961
* maximum number of result documents

src/test/java/com/arangodb/ArangoDriverCursorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public void test_executeQueryUniqueResult() throws ArangoException {
234234
// 全件とれる範囲
235235
{
236236
CursorEntity<TestComplexEntity01> result = driver.<TestComplexEntity01> executeQuery(query, bindVars,
237-
TestComplexEntity01.class, true, 0);
237+
TestComplexEntity01.class, true, 2);
238238
assertThat(result.size(), is(2));
239239
assertThat(result.getCount(), is(2));
240240
String msg = "";
@@ -251,7 +251,7 @@ public void test_executeQueryUniqueResult() throws ArangoException {
251251
query = "FOR t IN unit_test_query_test FILTER t.age == @age LIMIT 2 RETURN t";
252252
{
253253
CursorEntity<TestComplexEntity01> result = driver.<TestComplexEntity01> executeQuery(query, bindVars,
254-
TestComplexEntity01.class, true, 0);
254+
TestComplexEntity01.class, true, 2);
255255
assertThat(result.size(), is(1));
256256
assertThat(result.getCount(), is(1));
257257
TestComplexEntity01 entity = result.getUniqueResult();

src/test/java/com/arangodb/ArangoDriverDocumentCursorEntityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void test_executeQueryUniqueResult() throws ArangoException {
188188

189189
// 全件とれる範囲
190190
{
191-
CursorEntity<?> result = driver.executeCursorEntityQuery(query, bindVars, true, 0, false,
191+
CursorEntity<?> result = driver.executeCursorEntityQuery(query, bindVars, true, 2, false,
192192
DocumentEntity.class, TestComplexEntity01.class);
193193
assertThat(result.size(), is(2));
194194
assertThat(result.getCount(), is(2));
@@ -206,7 +206,7 @@ public void test_executeQueryUniqueResult() throws ArangoException {
206206
query = "FOR t IN unit_test_query_test FILTER t.age == @age LIMIT 2 RETURN t";
207207
{
208208
CursorEntity<DocumentEntity<TestComplexEntity01>> result = driver.executeCursorEntityQuery(query, bindVars,
209-
true, 0, false, DocumentEntity.class, TestComplexEntity01.class);
209+
true, 2, false, DocumentEntity.class, TestComplexEntity01.class);
210210
assertThat(result.size(), is(1));
211211
assertThat(result.getCount(), is(1));
212212
DocumentEntity<TestComplexEntity01> uniqueResult = result.getUniqueResult();

src/test/java/com/arangodb/ArangoDriverDocumentTest.java

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
import static org.hamcrest.CoreMatchers.not;
2222
import static org.hamcrest.CoreMatchers.notNullValue;
2323
import static org.hamcrest.CoreMatchers.nullValue;
24+
import static org.junit.Assert.assertEquals;
2425
import static org.junit.Assert.assertThat;
26+
import static org.junit.Assert.assertTrue;
2527
import static org.junit.Assert.fail;
2628

2729
import java.util.Arrays;
28-
import java.util.Set;
29-
import java.util.TreeSet;
30+
import java.util.List;
3031

3132
import org.junit.After;
3233
import org.junit.Before;
@@ -267,15 +268,22 @@ public void test_getDocuments() throws ArangoException {
267268
assertThat(doc2, is(notNullValue()));
268269
assertThat(doc3, is(notNullValue()));
269270

270-
//
271-
Set<String> tree = new TreeSet<String>(Arrays.asList("/_api/document/" + doc1.getDocumentHandle(),
272-
"/_api/document/" + doc2.getDocumentHandle(), "/_api/document/" + doc3.getDocumentHandle()));
273-
274271
// get documents
275-
Set<String> docIds = new TreeSet<String>(driver.getDocuments(collectionName));
276-
assertThat(docIds.size(), is(3));
272+
List<String> documents = driver.getDocuments(collectionName);
273+
assertEquals(3, documents.size());
274+
275+
String prefix;
276+
if (documents.get(0).startsWith("/_db/")) {
277+
// since ArangoDB 2.6
278+
prefix = "/_db/" + DATABASE_NAME + "/_api/document/";
279+
} else {
280+
prefix = "/_api/document/";
281+
}
282+
283+
List<String> list = Arrays.asList(prefix + doc1.getDocumentHandle(), prefix + doc2.getDocumentHandle(), prefix
284+
+ doc3.getDocumentHandle());
277285

278-
assertThat(docIds, is(tree));
286+
assertTrue(documents.containsAll(list));
279287
}
280288

281289
@Test
@@ -292,15 +300,22 @@ public void test_getDocuments_handle() throws ArangoException {
292300
assertThat(doc2, is(notNullValue()));
293301
assertThat(doc3, is(notNullValue()));
294302

295-
//
296-
Set<String> tree = new TreeSet<String>(Arrays.asList(doc1.getDocumentHandle(), doc2.getDocumentHandle(),
297-
doc3.getDocumentHandle()));
298-
299303
// get documents
300-
Set<String> docIds = new TreeSet<String>(driver.getDocuments(collectionName, true));
301-
assertThat(docIds.size(), is(3));
302-
assertThat(docIds, is(tree));
304+
List<String> documents = driver.getDocuments(collectionName, true);
305+
assertEquals(3, documents.size());
306+
307+
String prefix;
308+
if (documents.get(0).startsWith("/_db/")) {
309+
// since ArangoDB 2.6
310+
prefix = "/_db/" + DATABASE_NAME + "/_api/document/";
311+
} else {
312+
prefix = "";
313+
}
314+
315+
List<String> list = Arrays.asList(prefix + doc1.getDocumentHandle(), prefix + doc2.getDocumentHandle(), prefix
316+
+ doc3.getDocumentHandle());
303317

318+
assertTrue(documents.containsAll(list));
304319
}
305320

306321
@Test

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void test_create_normal() throws ArangoException {
7272
DocumentEntity<TestComplexEntity01> toDoc = driver.createDocument(collectionName2, value, true, true);
7373

7474
EdgeEntity<TestComplexEntity01> doc = driver.createEdge(
75-
databaseName,
75+
DATABASE_NAME,
7676
collectionName,
7777
value,
7878
fromDoc.getDocumentHandle(),

src/test/java/com/arangodb/BaseTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
public abstract class BaseTest {
3535

3636
protected static ArangoConfigure configure;
37-
protected static final String databaseName = "unitTestDatabase";
37+
protected static final String DATABASE_NAME = "unitTestDatabase";
3838

3939
// Suite.classを使った場合、Parametersがテストクラスの数だけ最初に一気に連続で呼ばれる。
4040
// そのため、単純にクラス変数にconfigureを保持すると、AfterClassの時に別のテストケースのものを終了してしまう。
@@ -59,11 +59,11 @@ public static Collection<Object[]> getParameterizedDrivers() {
5959
configure.setConnectRetryCount(2);
6060
configure.init();
6161
ArangoDriver driver = new ArangoDriver(configure);
62-
ArangoDriver driverMDB = new ArangoDriver(configure, databaseName);
62+
ArangoDriver driverMDB = new ArangoDriver(configure, DATABASE_NAME);
6363

6464
// create mydb
6565
try {
66-
driver.createDatabase(databaseName);
66+
driver.createDatabase(DATABASE_NAME);
6767
} catch (ArangoException e) {
6868
}
6969

@@ -85,7 +85,7 @@ public BaseTest(ArangoConfigure configure, ArangoDriver driver) {
8585
BaseTest.configure = configure;
8686

8787
try {
88-
driver.createDatabase(databaseName);
88+
driver.createDatabase(DATABASE_NAME);
8989
} catch (ArangoException e) {
9090
}
9191

0 commit comments

Comments
 (0)