Skip to content

Commit d92cf26

Browse files
author
michele
committed
fix tests v3.3
1 parent 4d5e976 commit d92cf26

File tree

8 files changed

+75
-36
lines changed

8 files changed

+75
-36
lines changed

src/test/java/com/arangodb/ArangoEdgeCollectionTest.java

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,7 @@
2020

2121
package com.arangodb;
2222

23-
import static org.hamcrest.Matchers.hasItem;
24-
import static org.hamcrest.Matchers.is;
25-
import static org.hamcrest.Matchers.not;
26-
import static org.hamcrest.Matchers.notNullValue;
27-
import static org.hamcrest.Matchers.nullValue;
28-
import static org.junit.Assert.assertThat;
29-
import static org.junit.Assert.fail;
30-
import static org.junit.Assume.assumeTrue;
31-
32-
import java.util.ArrayList;
33-
import java.util.Arrays;
34-
import java.util.Collection;
35-
23+
import com.arangodb.ArangoDB.Builder;
3624
import com.arangodb.entity.*;
3725
import com.arangodb.model.*;
3826
import org.junit.After;
@@ -41,7 +29,14 @@
4129
import org.junit.runner.RunWith;
4230
import org.junit.runners.Parameterized;
4331

44-
import com.arangodb.ArangoDB.Builder;
32+
import java.util.ArrayList;
33+
import java.util.Arrays;
34+
import java.util.Collection;
35+
36+
import static org.hamcrest.Matchers.*;
37+
import static org.junit.Assert.assertThat;
38+
import static org.junit.Assert.fail;
39+
import static org.junit.Assume.assumeTrue;
4540

4641
/**
4742
* @author Mark Vollmary
@@ -266,9 +261,14 @@ public void replaceEdgeIfMatchFail() {
266261
db.graph(GRAPH_NAME).edgeCollection(EDGE_COLLECTION_NAME).replaceEdge(createResult.getKey(), doc, options);
267262
fail();
268263
} catch (final ArangoDBException e) {
269-
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
270-
// assertThat(e.getResponseCode(), is(412));
271-
assertThat(e.getErrorNum(), is(1200));
264+
if (isAtLeastVersion(3, 4)) {
265+
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
266+
// assertThat(e.getResponseCode(), is(412));
267+
assertThat(e.getErrorNum(), is(1200));
268+
} else {
269+
assertThat(e.getResponseCode(), is(412));
270+
assertThat(e.getErrorNum(), is(1903));
271+
}
272272
}
273273
}
274274

@@ -351,9 +351,14 @@ public void updateEdgeIfMatchFail() {
351351
db.graph(GRAPH_NAME).edgeCollection(EDGE_COLLECTION_NAME).updateEdge(createResult.getKey(), doc, options);
352352
fail();
353353
} catch (final ArangoDBException e) {
354-
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
355-
// assertThat(e.getResponseCode(), is(412));
356-
assertThat(e.getErrorNum(), is(1200));
354+
if (isAtLeastVersion(3, 4)) {
355+
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
356+
// assertThat(e.getResponseCode(), is(412));
357+
assertThat(e.getErrorNum(), is(1200));
358+
} else {
359+
assertThat(e.getResponseCode(), is(412));
360+
assertThat(e.getErrorNum(), is(1903));
361+
}
357362
}
358363
}
359364

@@ -430,9 +435,14 @@ public void deleteEdgeIfMatchFail() {
430435
db.graph(GRAPH_NAME).edgeCollection(EDGE_COLLECTION_NAME).deleteEdge(createResult.getKey(), options);
431436
fail();
432437
} catch (final ArangoDBException e) {
433-
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
434-
// assertThat(e.getResponseCode(), is(412));
435-
assertThat(e.getErrorNum(), is(1200));
438+
if (isAtLeastVersion(3, 4)) {
439+
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
440+
// assertThat(e.getResponseCode(), is(412));
441+
assertThat(e.getErrorNum(), is(1200));
442+
} else {
443+
assertThat(e.getResponseCode(), is(412));
444+
assertThat(e.getErrorNum(), is(1903));
445+
}
436446
}
437447
}
438448
}

src/test/java/com/arangodb/ArangoSearchTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public ArangoSearchTest(final Builder builder) {
5353

5454
@After
5555
public void teardown() {
56+
if (!isAtLeastVersion(3, 4))
57+
return;
5658
if (db.collection("view_update_prop_test_collection").exists())
5759
db.collection("view_update_prop_test_collection").drop();
5860
if (db.collection("view_replace_prop_test_collection").exists())

src/test/java/com/arangodb/ArangoVertexCollectionTest.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,14 @@ public void replaceVertexIfMatchFail() {
261261
db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).replaceVertex(createResult.getKey(), doc, options);
262262
fail();
263263
} catch (final ArangoDBException e) {
264-
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
265-
// assertThat(e.getResponseCode(), is(412));
266-
assertThat(e.getErrorNum(), is(1200));
264+
if (isAtLeastVersion(3, 4)) {
265+
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
266+
// assertThat(e.getResponseCode(), is(412));
267+
assertThat(e.getErrorNum(), is(1200));
268+
} else {
269+
assertThat(e.getResponseCode(), is(412));
270+
assertThat(e.getErrorNum(), is(1903));
271+
}
267272
}
268273
}
269274

@@ -350,9 +355,14 @@ public void updateVertexIfMatchFail() {
350355
db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).updateVertex(createResult.getKey(), doc, options);
351356
fail();
352357
} catch (final ArangoDBException e) {
353-
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
354-
// assertThat(e.getResponseCode(), is(412));
355-
assertThat(e.getErrorNum(), is(1200));
358+
if (isAtLeastVersion(3, 4)) {
359+
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
360+
// assertThat(e.getResponseCode(), is(412));
361+
assertThat(e.getErrorNum(), is(1200));
362+
} else {
363+
assertThat(e.getResponseCode(), is(412));
364+
assertThat(e.getErrorNum(), is(1903));
365+
}
356366
}
357367
}
358368

@@ -434,9 +444,14 @@ public void deleteVertexIfMatchFail() {
434444
db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).deleteVertex(createResult.getKey(), options);
435445
fail();
436446
} catch (final ArangoDBException e) {
437-
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
438-
// assertThat(e.getResponseCode(), is(412));
439-
assertThat(e.getErrorNum(), is(1200));
447+
if (isAtLeastVersion(3, 4)) {
448+
// FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK
449+
// assertThat(e.getResponseCode(), is(412));
450+
assertThat(e.getErrorNum(), is(1200));
451+
} else {
452+
assertThat(e.getResponseCode(), is(412));
453+
assertThat(e.getErrorNum(), is(1903));
454+
}
440455
}
441456
}
442457
}

src/test/java/com/arangodb/ArangoViewTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public ArangoViewTest(final Builder builder) {
4646

4747
@After
4848
public void teardown() {
49+
if (!isAtLeastVersion(3, 4))
50+
return;
4951
if (db.view(VIEW_NAME).exists())
5052
db.view(VIEW_NAME).drop();
5153
}

src/test/java/com/arangodb/async/ArangoSearchTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public class ArangoSearchTest extends BaseTest {
4848

4949
@BeforeClass
5050
public static void setup() throws InterruptedException, ExecutionException {
51+
if (!isAtLeastVersion(arangoDB, 3, 4))
52+
return;
5153
db.createArangoSearch(VIEW_NAME, new ArangoSearchCreateOptions()).get();
5254
}
5355

src/test/java/com/arangodb/async/ArangoViewTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class ArangoViewTest extends BaseTest {
4141

4242
@BeforeClass
4343
public static void setup() throws InterruptedException, ExecutionException {
44+
if (!isAtLeastVersion(arangoDB, 3, 4))
45+
return;
4446
db.createView(VIEW_NAME, ViewType.ARANGO_SEARCH).get();
4547
}
4648

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ public static void shutdown() throws InterruptedException, ExecutionException {
5858
arangoDB = null;
5959
}
6060

61-
private static boolean isAtLeastVersion(final ArangoDBAsync arangoDB, final int major, final int minor)
61+
protected static boolean isAtLeastVersion(final ArangoDBAsync arangoDB, final int major, final int minor)
6262
throws InterruptedException, ExecutionException {
6363
final String[] split = arangoDB.getVersion().get().getVersion().split("\\.");
6464
return Integer.parseInt(split[0]) >= major && Integer.parseInt(split[1]) >= minor;
6565
}
6666

67-
boolean isAtLeastVersion(final int major, final int minor) throws InterruptedException, ExecutionException {
67+
protected boolean isAtLeastVersion(final int major, final int minor) throws InterruptedException, ExecutionException {
6868
return isAtLeastVersion(arangoDB, major, minor);
6969
}
7070

src/test/java/com/arangodb/async/debug/ConsolidationIntervalMsec.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.arangodb.async.ArangoDBAsync;
2424
import com.arangodb.async.ArangoDatabaseAsync;
25+
import com.arangodb.async.BaseTest;
2526
import com.arangodb.entity.ViewEntity;
2627
import com.arangodb.entity.ViewType;
2728
import com.arangodb.entity.arangosearch.ArangoSearchPropertiesEntity;
@@ -30,18 +31,23 @@
3031
import com.arangodb.model.arangosearch.ArangoSearchCreateOptions;
3132
import org.junit.Test;
3233

34+
import java.util.concurrent.ExecutionException;
35+
3336
import static org.hamcrest.Matchers.is;
3437
import static org.junit.Assert.assertThat;
38+
import static org.junit.Assume.assumeTrue;
3539

3640
/**
3741
* @author Michele Rastelli
3842
* <p>
3943
* https://github.com/arangodb/arangodb-java-driver-async/issues/15
4044
*/
41-
public class ConsolidationIntervalMsec {
45+
public class ConsolidationIntervalMsec extends BaseTest {
4246

4347
@Test
44-
public void consolidationIntervalMsec() {
48+
public void consolidationIntervalMsec() throws ExecutionException, InterruptedException {
49+
assumeTrue(isAtLeastVersion(3, 4));
50+
4551
ArangoDBAsync arango = new ArangoDBAsync.Builder()
4652
.user("root")
4753
.password("test")

0 commit comments

Comments
 (0)