diff --git a/src/test/java/com/arangodb/ArangoCollectionTest.java b/src/test/java/com/arangodb/ArangoCollectionTest.java index b734f92..65ce226 100644 --- a/src/test/java/com/arangodb/ArangoCollectionTest.java +++ b/src/test/java/com/arangodb/ArangoCollectionTest.java @@ -35,6 +35,7 @@ import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; /** * @author Mark Vollmary @@ -161,9 +162,7 @@ public void getDocumentIfMatchFail() throws InterruptedException, ExecutionExcep assertThat(createResult.getKey(), is(notNullValue())); final DocumentReadOptions options = new DocumentReadOptions().ifMatch("no"); db.collection(COLLECTION_NAME).getDocument(createResult.getKey(), BaseDocument.class, options) - .whenComplete((doc, ex) -> { - assertThat(doc, is(nullValue())); - }) + .whenComplete((doc, ex) -> assertThat(doc, is(nullValue()))) .get(); } @@ -188,9 +187,7 @@ public void getDocumentIfNoneMatchFail() throws InterruptedException, ExecutionE assertThat(createResult.getKey(), is(notNullValue())); final DocumentReadOptions options = new DocumentReadOptions().ifNoneMatch(createResult.getRev()); db.collection(COLLECTION_NAME).getDocument(createResult.getKey(), BaseDocument.class, options) - .whenComplete((doc, ex) -> { - assertThat(doc, is(nullValue())); - }) + .whenComplete((doc, ex) -> assertThat(doc, is(nullValue()))) .get(); } @@ -208,9 +205,7 @@ public void getDocumentAsJson() throws InterruptedException, ExecutionException @Test public void getDocumentNotFound() throws InterruptedException, ExecutionException { db.collection(COLLECTION_NAME).getDocument("no", BaseDocument.class) - .whenComplete((doc, ex) -> { - assertThat(doc, is(nullValue())); - }) + .whenComplete((doc, ex) -> assertThat(doc, is(nullValue()))) .get(); } @@ -665,9 +660,7 @@ public void deleteDocument() throws InterruptedException, ExecutionException { .get(); db.collection(COLLECTION_NAME).deleteDocument(createResult.getKey(), null, null).get(); db.collection(COLLECTION_NAME).getDocument(createResult.getKey(), BaseDocument.class, null) - .whenComplete((document, ex) -> { - assertThat(document, is(nullValue())); - }) + .whenComplete((document, ex) -> assertThat(document, is(nullValue()))) .get(); } @@ -696,9 +689,7 @@ public void deleteDocumentIfMatch() throws InterruptedException, ExecutionExcept final DocumentDeleteOptions options = new DocumentDeleteOptions().ifMatch(createResult.getRev()); db.collection(COLLECTION_NAME).deleteDocument(createResult.getKey(), null, options).get(); db.collection(COLLECTION_NAME).getDocument(createResult.getKey(), BaseDocument.class, null) - .whenComplete((document, ex) -> { - assertThat(document, is(nullValue())); - }) + .whenComplete((document, ex) -> assertThat(document, is(nullValue()))) .get(); } @@ -788,7 +779,7 @@ public void deleteIndexByKey() throws InterruptedException, ExecutionException { @Test public void createHashIndex() throws InterruptedException, ExecutionException { - final boolean singleServer = arangoDB.getRole().get() == ServerRole.SINGLE; + final boolean singleServer = isSingleServer(); final Collection fields = new ArrayList<>(); fields.add("a"); fields.add("b"); @@ -814,14 +805,11 @@ public void createHashIndex() throws InterruptedException, ExecutionException { @Test public void createHashIndexWithOptions() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); final HashIndexOptions options = new HashIndexOptions(); options.name("myHashIndex"); - final Collection fields = new ArrayList(); + final Collection fields = new ArrayList<>(); fields.add("a"); fields.add("b"); final IndexEntity indexResult = db.collection(COLLECTION_NAME).ensureHashIndex(fields, options).get(); @@ -832,7 +820,7 @@ public void createHashIndexWithOptions() throws ExecutionException, InterruptedE assertThat(indexResult.getId(), startsWith(COLLECTION_NAME)); assertThat(indexResult.getIsNewlyCreated(), is(true)); assertThat(indexResult.getMinLength(), is(nullValue())); - if (arangoDB.getRole().get() == ServerRole.SINGLE) { + if (isSingleServer()) { assertThat(indexResult.getSelectivityEstimate(), is(1.)); } assertThat(indexResult.getSparse(), is(false)); @@ -863,14 +851,11 @@ public void createGeoIndex() throws InterruptedException, ExecutionException { @Test public void createGeoIndexWithOptions() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); final GeoIndexOptions options = new GeoIndexOptions(); options.name("myGeoIndex1"); - final Collection fields = new ArrayList(); + final Collection fields = new ArrayList<>(); fields.add("a"); final IndexEntity indexResult = db.collection(COLLECTION_NAME).ensureGeoIndex(fields, options).get(); assertThat(indexResult, is(notNullValue())); @@ -880,7 +865,7 @@ public void createGeoIndexWithOptions() throws ExecutionException, InterruptedEx assertThat(indexResult.getMinLength(), is(nullValue())); assertThat(indexResult.getSparse(), is(true)); assertThat(indexResult.getUnique(), is(false)); - if (requireVersion(3, 4)) { + if (isAtLeastVersion(3, 4)) { assertThat(indexResult.getType(), is(IndexType.geo)); } else { assertThat(indexResult.getType(), is(IndexType.geo1)); @@ -890,7 +875,7 @@ public void createGeoIndexWithOptions() throws ExecutionException, InterruptedEx @Test public void createGeo2Index() throws ExecutionException, InterruptedException { - final Collection fields = new ArrayList(); + final Collection fields = new ArrayList<>(); fields.add("a"); fields.add("b"); db.collection(COLLECTION_NAME).ensureGeoIndex(fields, null).whenComplete((indexResult, ex) -> { @@ -903,7 +888,7 @@ public void createGeo2Index() throws ExecutionException, InterruptedException { assertThat(indexResult.getSparse(), is(true)); assertThat(indexResult.getUnique(), is(false)); try { - if (requireVersion(3, 4)) { + if (isAtLeastVersion(3, 4)) { assertThat(indexResult.getType(), is(IndexType.geo)); } else { assertThat(indexResult.getType(), is(IndexType.geo2)); @@ -916,14 +901,11 @@ public void createGeo2Index() throws ExecutionException, InterruptedException { @Test public void createGeo2IndexWithOptions() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); final GeoIndexOptions options = new GeoIndexOptions(); options.name("myGeoIndex2"); - final Collection fields = new ArrayList(); + final Collection fields = new ArrayList<>(); fields.add("a"); fields.add("b"); final IndexEntity indexResult = db.collection(COLLECTION_NAME).ensureGeoIndex(fields, options).get(); @@ -935,7 +917,7 @@ public void createGeo2IndexWithOptions() throws ExecutionException, InterruptedE assertThat(indexResult.getMinLength(), is(nullValue())); assertThat(indexResult.getSparse(), is(true)); assertThat(indexResult.getUnique(), is(false)); - if (requireVersion(3, 4)) { + if (isAtLeastVersion(3, 4)) { assertThat(indexResult.getType(), is(IndexType.geo)); } else { assertThat(indexResult.getType(), is(IndexType.geo2)); @@ -945,7 +927,6 @@ public void createGeo2IndexWithOptions() throws ExecutionException, InterruptedE @Test public void createSkiplistIndex() throws InterruptedException, ExecutionException { - final boolean singleServer = arangoDB.getRole().get() == ServerRole.SINGLE; final Collection fields = new ArrayList<>(); fields.add("a"); fields.add("b"); @@ -959,9 +940,6 @@ public void createSkiplistIndex() throws InterruptedException, ExecutionExceptio assertThat(indexResult.getId(), startsWith(COLLECTION_NAME)); assertThat(indexResult.getIsNewlyCreated(), is(true)); assertThat(indexResult.getMinLength(), is(nullValue())); -// if (singleServer) { -// assertThat(indexResult.getSelectivityEstimate(), is(1.0)); -// } assertThat(indexResult.getSparse(), is(false)); assertThat(indexResult.getType(), is(IndexType.skiplist)); assertThat(indexResult.getUnique(), is(false)); @@ -971,14 +949,11 @@ public void createSkiplistIndex() throws InterruptedException, ExecutionExceptio @Test public void createSkiplistIndexWithOptions() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); final SkiplistIndexOptions options = new SkiplistIndexOptions(); options.name("mySkiplistIndex"); - final Collection fields = new ArrayList(); + final Collection fields = new ArrayList<>(); fields.add("a"); fields.add("b"); final IndexEntity indexResult = db.collection(COLLECTION_NAME).ensureSkiplistIndex(fields, options).get(); @@ -997,7 +972,6 @@ public void createSkiplistIndexWithOptions() throws ExecutionException, Interrup @Test public void createPersistentIndex() throws InterruptedException, ExecutionException { - final boolean singleServer = arangoDB.getRole().get() == ServerRole.SINGLE; final Collection fields = new ArrayList<>(); fields.add("a"); fields.add("b"); @@ -1011,9 +985,6 @@ public void createPersistentIndex() throws InterruptedException, ExecutionExcept assertThat(indexResult.getId(), startsWith(COLLECTION_NAME)); assertThat(indexResult.getIsNewlyCreated(), is(true)); assertThat(indexResult.getMinLength(), is(nullValue())); -// if (singleServer) { -// assertThat(indexResult.getSelectivityEstimate(), is(1.0)); -// } assertThat(indexResult.getSparse(), is(false)); assertThat(indexResult.getType(), is(IndexType.persistent)); assertThat(indexResult.getUnique(), is(false)); @@ -1023,14 +994,11 @@ public void createPersistentIndex() throws InterruptedException, ExecutionExcept @Test public void createPersistentIndexWithOptions() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); final PersistentIndexOptions options = new PersistentIndexOptions(); options.name("myPersistentIndex"); - final Collection fields = new ArrayList(); + final Collection fields = new ArrayList<>(); fields.add("a"); fields.add("b"); final IndexEntity indexResult = db.collection(COLLECTION_NAME).ensurePersistentIndex(fields, options).get(); @@ -1069,14 +1037,11 @@ public void createFulltextIndex() throws InterruptedException, ExecutionExceptio @Test public void createFulltextIndexWithOptions() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); final FulltextIndexOptions options = new FulltextIndexOptions(); options.name("myFulltextIndex"); - final Collection fields = new ArrayList(); + final Collection fields = new ArrayList<>(); fields.add("a"); final IndexEntity indexResult = db.collection(COLLECTION_NAME).ensureFulltextIndex(fields, options).get(); assertThat(indexResult, is(notNullValue())); @@ -1092,13 +1057,11 @@ public void createFulltextIndexWithOptions() throws ExecutionException, Interrup @Test public void createTtlIndexWithoutOptions() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - final Collection fields = new ArrayList(); + assumeTrue(isAtLeastVersion(3, 5)); + final Collection fields = new ArrayList<>(); fields.add("a"); try { - final IndexEntity indexResult = db.collection(COLLECTION_NAME).ensureTtlIndex(fields, null).get(); + db.collection(COLLECTION_NAME).ensureTtlIndex(fields, null).get(); fail(); } catch (ExecutionException e) { assertThat(e.getCause(), instanceOf(ArangoDBException.class)); @@ -1110,10 +1073,8 @@ public void createTtlIndexWithoutOptions() throws ExecutionException, Interrupte @Test public void createTtlIndexWithOptions() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - final Collection fields = new ArrayList(); + assumeTrue(isAtLeastVersion(3, 5)); + final Collection fields = new ArrayList<>(); fields.add("a"); final TtlIndexOptions options = new TtlIndexOptions(); @@ -1186,26 +1147,20 @@ public void getCount() throws InterruptedException, ExecutionException { db.collection(COLLECTION_NAME).insertDocument("{}", null).get(); db.collection(COLLECTION_NAME).count() - .whenComplete((count, ex) -> { - assertThat(count.getCount(), is(1L)); - }) + .whenComplete((count, ex) -> assertThat(count.getCount(), is(1L))) .get(); } @Test public void documentExists() throws InterruptedException, ExecutionException { db.collection(COLLECTION_NAME).documentExists("no", null) - .whenComplete((existsNot, ex) -> { - assertThat(existsNot, is(false)); - }) + .whenComplete((existsNot, ex) -> assertThat(existsNot, is(false))) .get(); db.collection(COLLECTION_NAME).insertDocument("{\"_key\":\"abc\"}", null).get(); db.collection(COLLECTION_NAME).documentExists("abc", null) - .whenComplete((exists, ex) -> { - assertThat(exists, is(true)); - }) + .whenComplete((exists, ex) -> assertThat(exists, is(true))) .get(); } @@ -1215,9 +1170,7 @@ public void documentExistsIfMatch() throws InterruptedException, ExecutionExcept .insertDocument("{\"_key\":\"abc\"}", null).get(); final DocumentExistsOptions options = new DocumentExistsOptions().ifMatch(createResult.getRev()); db.collection(COLLECTION_NAME).documentExists("abc", options) - .whenComplete((exists, ex) -> { - assertThat(exists, is(true)); - }) + .whenComplete((exists, ex) -> assertThat(exists, is(true))) .get(); } @@ -1226,9 +1179,7 @@ public void documentExistsIfMatchFail() throws InterruptedException, ExecutionEx db.collection(COLLECTION_NAME).insertDocument("{\"_key\":\"abc\"}", null).get(); final DocumentExistsOptions options = new DocumentExistsOptions().ifMatch("no"); db.collection(COLLECTION_NAME).documentExists("abc", options) - .whenComplete((exists, ex) -> { - assertThat(exists, is(false)); - }) + .whenComplete((exists, ex) -> assertThat(exists, is(false))) .get(); } @@ -1237,9 +1188,7 @@ public void documentExistsIfNoneMatch() throws InterruptedException, ExecutionEx db.collection(COLLECTION_NAME).insertDocument("{\"_key\":\"abc\"}", null).get(); final DocumentExistsOptions options = new DocumentExistsOptions().ifNoneMatch("no"); db.collection(COLLECTION_NAME).documentExists("abc", options) - .whenComplete((exists, ex) -> { - assertThat(exists, is(true)); - }) + .whenComplete((exists, ex) -> assertThat(exists, is(true))) .get(); } @@ -1249,9 +1198,7 @@ public void documentExistsIfNoneMatchFail() throws InterruptedException, Executi .insertDocument("{\"_key\":\"abc\"}", null).get(); final DocumentExistsOptions options = new DocumentExistsOptions().ifNoneMatch(createResult.getRev()); db.collection(COLLECTION_NAME).documentExists("abc", options) - .whenComplete((exists, ex) -> { - assertThat(exists, is(false)); - }) + .whenComplete((exists, ex) -> assertThat(exists, is(false))) .get(); } @@ -1524,8 +1471,8 @@ public void importDocumentsFromToPrefix() throws InterruptedException, Execution try { final Collection values = new ArrayList<>(); final String[] keys = {"1", "2"}; - for (int i = 0; i < keys.length; i++) { - values.add(new BaseEdgeDocument(keys[i], "from", "to")); + for (String s : keys) { + values.add(new BaseEdgeDocument(s, "from", "to")); } assertThat(values.size(), is(keys.length)); @@ -1533,9 +1480,9 @@ public void importDocumentsFromToPrefix() throws InterruptedException, Execution .importDocuments(values, new DocumentImportOptions().fromPrefix("foo").toPrefix("bar")).get(); assertThat(importResult, is(notNullValue())); assertThat(importResult.getCreated(), is(values.size())); - for (int i = 0; i < keys.length; i++) { + for (String key : keys) { BaseEdgeDocument doc; - doc = collection.getDocument(keys[i], BaseEdgeDocument.class).get(); + doc = collection.getDocument(key, BaseEdgeDocument.class).get(); assertThat(doc, is(notNullValue())); assertThat(doc.getFrom(), is("foo/from")); assertThat(doc.getTo(), is("bar/to")); @@ -1704,9 +1651,9 @@ public void importDocumentsJsonFromToPrefix() throws InterruptedException, Execu .importDocuments(values, new DocumentImportOptions().fromPrefix("foo").toPrefix("bar")).get(); assertThat(importResult, is(notNullValue())); assertThat(importResult.getCreated(), is(2)); - for (int i = 0; i < keys.length; i++) { + for (String key : keys) { BaseEdgeDocument doc; - doc = collection.getDocument(keys[i], BaseEdgeDocument.class).get(); + doc = collection.getDocument(key, BaseEdgeDocument.class).get(); assertThat(doc, is(notNullValue())); assertThat(doc.getFrom(), is("foo/from")); assertThat(doc.getTo(), is("bar/to")); @@ -2024,27 +1971,21 @@ public void replaceDocumentsWithoutKey() throws InterruptedException, ExecutionE @Test public void load() throws InterruptedException, ExecutionException { db.collection(COLLECTION_NAME).load() - .whenComplete((result, ex) -> { - assertThat(result.getName(), is(COLLECTION_NAME)); - }) + .whenComplete((result, ex) -> assertThat(result.getName(), is(COLLECTION_NAME))) .get(); } @Test public void unload() throws InterruptedException, ExecutionException { db.collection(COLLECTION_NAME).unload() - .whenComplete((result, ex) -> { - assertThat(result.getName(), is(COLLECTION_NAME)); - }) + .whenComplete((result, ex) -> assertThat(result.getName(), is(COLLECTION_NAME))) .get(); } @Test public void getInfo() throws InterruptedException, ExecutionException { db.collection(COLLECTION_NAME).getInfo() - .whenComplete((result, ex) -> { - assertThat(result.getName(), is(COLLECTION_NAME)); - }) + .whenComplete((result, ex) -> assertThat(result.getName(), is(COLLECTION_NAME))) .get(); } @@ -2081,37 +2022,28 @@ public void changeProperties() throws InterruptedException, ExecutionException { @Test public void rename() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() != ServerRole.SINGLE) { - return; - } + assumeTrue(isSingleServer()); + db.collection(COLLECTION_NAME).rename(COLLECTION_NAME + "1") + .whenComplete((result, ex) -> { + assertThat(result, is(notNullValue())); + assertThat(result.getName(), is(COLLECTION_NAME + "1")); + }) + .get(); + final CollectionEntity info = db.collection(COLLECTION_NAME + "1").getInfo().get(); + assertThat(info.getName(), is(COLLECTION_NAME + "1")); try { - db.collection(COLLECTION_NAME).rename(COLLECTION_NAME + "1") - .whenComplete((result, ex) -> { - assertThat(result, is(notNullValue())); - assertThat(result.getName(), is(COLLECTION_NAME + "1")); - }) - .get(); - final CollectionEntity info = db.collection(COLLECTION_NAME + "1").getInfo().get(); - assertThat(info.getName(), is(COLLECTION_NAME + "1")); - try { - db.collection(COLLECTION_NAME).getInfo().get(); - fail(); - } catch (final ExecutionException e) { - assertThat(e.getCause(), instanceOf(ArangoDBException.class)); - } - } finally { - db.collection(COLLECTION_NAME + "1").rename(COLLECTION_NAME).get(); + db.collection(COLLECTION_NAME).getInfo().get(); + fail(); + } catch (final ExecutionException e) { + assertThat(e.getCause(), instanceOf(ArangoDBException.class)); } + db.collection(COLLECTION_NAME + "1").rename(COLLECTION_NAME).get(); } @Test public void responsibleShard() throws ExecutionException, InterruptedException { - if (arangoDB.getRole().get() != ServerRole.COORDINATOR) { - return; - } - if (!requireVersion(3, 5)) { - return; - } + assumeTrue(isCluster()); + assumeTrue(isAtLeastVersion(3, 5)); ShardEntity shard = db.collection(COLLECTION_NAME).getResponsibleShard(new BaseDocument("testKey")).get(); assertThat(shard, is(notNullValue())); assertThat(shard.getShardId(), is(notNullValue())); diff --git a/src/test/java/com/arangodb/ArangoDBTest.java b/src/test/java/com/arangodb/ArangoDBTest.java index ec7e66d..103d36d 100644 --- a/src/test/java/com/arangodb/ArangoDBTest.java +++ b/src/test/java/com/arangodb/ArangoDBTest.java @@ -108,9 +108,7 @@ public void nestedGetVersion() { public void createDatabase() throws InterruptedException, ExecutionException { final ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().build(); arangoDB.createDatabase(BaseTest.TEST_DB) - .whenComplete((result, ex) -> { - assertThat(result, is(true)); - }) + .whenComplete((result, ex) -> assertThat(result, is(true))) .get(); arangoDB.db(BaseTest.TEST_DB).drop().get(); } @@ -121,9 +119,7 @@ public void deleteDatabase() throws InterruptedException, ExecutionException { final Boolean resultCreate = arangoDB.createDatabase(BaseTest.TEST_DB).get(); assertThat(resultCreate, is(true)); arangoDB.db(BaseTest.TEST_DB).drop() - .whenComplete((resultDelete, ex) -> { - assertThat(resultDelete, is(true)); - }) + .whenComplete((resultDelete, ex) -> assertThat(resultDelete, is(true))) .get(); } @@ -210,9 +206,7 @@ public void getUser() throws InterruptedException, ExecutionException { try { arangoDB.createUser(USER, PW, null).get(); arangoDB.getUser(USER) - .whenComplete((user, ex) -> { - assertThat(user.getUser(), is(USER)); - }) + .whenComplete((user, ex) -> assertThat(user.getUser(), is(USER))) .get(); } finally { arangoDB.deleteUser(USER).get(); diff --git a/src/test/java/com/arangodb/ArangoDatabaseTest.java b/src/test/java/com/arangodb/ArangoDatabaseTest.java index be8ac84..a44591f 100644 --- a/src/test/java/com/arangodb/ArangoDatabaseTest.java +++ b/src/test/java/com/arangodb/ArangoDatabaseTest.java @@ -29,7 +29,6 @@ import com.arangodb.velocypack.VPackBuilder; import com.arangodb.velocypack.VPackSlice; import com.arangodb.velocypack.exception.VPackException; -import org.junit.Assume; import org.junit.Ignore; import org.junit.Test; @@ -42,7 +41,9 @@ import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; /** * @author Mark Vollmary @@ -100,43 +101,30 @@ public void getAccessibleDatabases() throws InterruptedException, ExecutionExcep @Test public void createCollection() throws InterruptedException, ExecutionException { - try { - db.createCollection(COLLECTION_NAME, null) - .whenComplete((result, ex) -> { - assertThat(result, is(notNullValue())); - assertThat(result.getId(), is(notNullValue())); - }) - .get(); - } finally { - db.collection(COLLECTION_NAME).drop().get(); - } + db.createCollection(COLLECTION_NAME, null) + .whenComplete((result, ex) -> { + assertThat(result, is(notNullValue())); + assertThat(result.getId(), is(notNullValue())); + }) + .get(); + db.collection(COLLECTION_NAME).drop().get(); } @Test public void createCollectionWithReplicationFactor() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() == ServerRole.SINGLE) { - return; - } - try { - final CollectionEntity result = db - .createCollection(COLLECTION_NAME, new CollectionCreateOptions().replicationFactor(2)).get(); - assertThat(result, is(notNullValue())); - assertThat(result.getId(), is(notNullValue())); - assertThat(db.collection(COLLECTION_NAME).getProperties().get().getReplicationFactor(), is(2)); - } finally { - db.collection(COLLECTION_NAME).drop().get(); - } + assumeTrue(isCluster()); + final CollectionEntity result = db + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().replicationFactor(2)).get(); + assertThat(result, is(notNullValue())); + assertThat(result.getId(), is(notNullValue())); + assertThat(db.collection(COLLECTION_NAME).getProperties().get().getReplicationFactor(), is(2)); + db.collection(COLLECTION_NAME).drop().get(); } @Test public void createCollectionWithMinReplicationFactor() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - - if (arangoDB.getRole().get() == ServerRole.SINGLE) { - return; - } + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isCluster()); final CollectionEntity result = db.createCollection(COLLECTION_NAME, new CollectionCreateOptions().replicationFactor(2).minReplicationFactor(2)).get(); @@ -150,55 +138,40 @@ public void createCollectionWithMinReplicationFactor() throws ExecutionException @Test public void createCollectionWithNumberOfShards() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() == ServerRole.SINGLE) { - return; - } - try { - final CollectionEntity result = db - .createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2)).get(); - assertThat(result, is(notNullValue())); - assertThat(result.getId(), is(notNullValue())); - assertThat(db.collection(COLLECTION_NAME).getProperties().get().getNumberOfShards(), is(2)); - } finally { - db.collection(COLLECTION_NAME).drop().get(); - } + assumeTrue(isCluster()); + final CollectionEntity result = db + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2)).get(); + assertThat(result, is(notNullValue())); + assertThat(result.getId(), is(notNullValue())); + assertThat(db.collection(COLLECTION_NAME).getProperties().get().getNumberOfShards(), is(2)); + db.collection(COLLECTION_NAME).drop().get(); } @Test public void createCollectionWithNumberOfShardsAndShardKey() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() == ServerRole.SINGLE) { - return; - } - try { - final CollectionEntity result = db - .createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2).shardKeys("a")) - .get(); - assertThat(result, is(notNullValue())); - assertThat(result.getId(), is(notNullValue())); - final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get(); - assertThat(properties.getNumberOfShards(), is(2)); - assertThat(properties.getShardKeys().size(), is(1)); - } finally { - db.collection(COLLECTION_NAME).drop().get(); - } + assumeTrue(isCluster()); + final CollectionEntity result = db + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2).shardKeys("a")) + .get(); + assertThat(result, is(notNullValue())); + assertThat(result.getId(), is(notNullValue())); + final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get(); + assertThat(properties.getNumberOfShards(), is(2)); + assertThat(properties.getShardKeys().size(), is(1)); + db.collection(COLLECTION_NAME).drop().get(); } @Test public void createCollectionWithNumberOfShardsAndShardKeys() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() == ServerRole.SINGLE) { - return; - } - try { - final CollectionEntity result = db.createCollection(COLLECTION_NAME, - new CollectionCreateOptions().numberOfShards(2).shardKeys("a", "b")).get(); - assertThat(result, is(notNullValue())); - assertThat(result.getId(), is(notNullValue())); - final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get(); - assertThat(properties.getNumberOfShards(), is(2)); - assertThat(properties.getShardKeys().size(), is(2)); - } finally { - db.collection(COLLECTION_NAME).drop().get(); - } + assumeTrue(isCluster()); + final CollectionEntity result = db.createCollection(COLLECTION_NAME, + new CollectionCreateOptions().numberOfShards(2).shardKeys("a", "b")).get(); + assertThat(result, is(notNullValue())); + assertThat(result.getId(), is(notNullValue())); + final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get(); + assertThat(properties.getNumberOfShards(), is(2)); + assertThat(properties.getShardKeys().size(), is(2)); + db.collection(COLLECTION_NAME).drop().get(); } @Test @@ -215,9 +188,6 @@ public void deleteCollection() throws InterruptedException, ExecutionException { @Test public void deleteSystemCollection() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() != ServerRole.SINGLE) { - return; - } final String name = "_system_test"; db.createCollection(name, new CollectionCreateOptions().isSystem(true)).get(); db.collection(name).drop(true).get(); @@ -231,9 +201,6 @@ public void deleteSystemCollection() throws InterruptedException, ExecutionExcep @Test public void deleteSystemCollectionFail() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() != ServerRole.SINGLE) { - return; - } final String name = "_system_test"; db.createCollection(name, new CollectionCreateOptions().isSystem(true)).get(); try { @@ -253,20 +220,17 @@ public void deleteSystemCollectionFail() throws InterruptedException, ExecutionE @Test public void getIndex() throws InterruptedException, ExecutionException { - try { - db.createCollection(COLLECTION_NAME, null).get(); - final Collection fields = new ArrayList<>(); - fields.add("a"); - final IndexEntity createResult = db.collection(COLLECTION_NAME).ensureHashIndex(fields, null).get(); - db.getIndex(createResult.getId()) - .whenComplete((readResult, ex) -> { - assertThat(readResult.getId(), is(createResult.getId())); - assertThat(readResult.getType(), is(createResult.getType())); - }) - .get(); - } finally { - db.collection(COLLECTION_NAME).drop().get(); - } + db.createCollection(COLLECTION_NAME, null).get(); + final Collection fields = new ArrayList<>(); + fields.add("a"); + final IndexEntity createResult = db.collection(COLLECTION_NAME).ensureHashIndex(fields, null).get(); + db.getIndex(createResult.getId()) + .whenComplete((readResult, ex) -> { + assertThat(readResult.getId(), is(createResult.getId())); + assertThat(readResult.getType(), is(createResult.getType())); + }) + .get(); + db.collection(COLLECTION_NAME).drop().get(); } @Test @@ -433,7 +397,7 @@ public void query() throws InterruptedException, ExecutionException { .whenComplete((cursor, ex) -> { assertThat(cursor, is(notNullValue())); for (int i = 0; i < 10; i++, cursor.next()) { - assertThat(cursor.hasNext(), is(i != 10)); + assertThat(cursor.hasNext(), is(true)); } }) .get(); @@ -453,9 +417,7 @@ public void queryForEach() throws InterruptedException, ExecutionException { .whenComplete((cursor, ex) -> { assertThat(cursor, is(notNullValue())); final AtomicInteger i = new AtomicInteger(0); - cursor.forEachRemaining(e -> { - i.incrementAndGet(); - }); + cursor.forEachRemaining(e -> i.incrementAndGet()); assertThat(i.get(), is(10)); }) .get(); @@ -475,9 +437,7 @@ public void queryStream() throws InterruptedException, ExecutionException { .whenComplete((cursor, ex) -> { assertThat(cursor, is(notNullValue())); final AtomicInteger i = new AtomicInteger(0); - cursor.forEachRemaining(e -> { - i.incrementAndGet(); - }); + cursor.forEachRemaining(e -> i.incrementAndGet()); assertThat(i.get(), is(10)); }) .get(); @@ -498,7 +458,7 @@ public void queryWithCount() throws InterruptedException, ExecutionException { .whenComplete((cursor, ex) -> { assertThat(cursor, is(notNullValue())); for (int i = 0; i < 6; i++, cursor.next()) { - assertThat(cursor.hasNext(), is(i != 6)); + assertThat(cursor.hasNext(), is(true)); } assertThat(cursor.getCount(), is(6)); }) @@ -520,7 +480,7 @@ public void queryWithLimitAndFullCount() throws InterruptedException, ExecutionE .whenComplete((cursor, ex) -> { assertThat(cursor, is(notNullValue())); for (int i = 0; i < 5; i++, cursor.next()) { - assertThat(cursor.hasNext(), is(i != 5)); + assertThat(cursor.hasNext(), is(true)); } assertThat(cursor.getStats(), is(notNullValue())); assertThat(cursor.getStats().getFullCount(), is(10L)); @@ -542,7 +502,7 @@ public void queryWithBatchSize() throws InterruptedException, ExecutionException new AqlQueryOptions().batchSize(5).count(true), String.class).get(); assertThat(cursor, is(notNullValue())); for (int i = 0; i < 10; i++, cursor.next()) { - assertThat(cursor.hasNext(), is(i != 10)); + assertThat(cursor.hasNext(), is(true)); } } finally { db.collection(COLLECTION_NAME).drop().get(); @@ -560,9 +520,7 @@ public void queryStreamWithBatchSize() throws InterruptedException, ExecutionExc new AqlQueryOptions().batchSize(5).count(true), String.class).get(); assertThat(cursor, is(notNullValue())); final AtomicInteger i = new AtomicInteger(0); - cursor.streamRemaining().forEach(e -> { - i.incrementAndGet(); - }); + cursor.streamRemaining().forEach(e -> i.incrementAndGet()); assertThat(i.get(), is(10)); } finally { db.collection(COLLECTION_NAME).drop().get(); @@ -571,8 +529,6 @@ public void queryStreamWithBatchSize() throws InterruptedException, ExecutionExc /** * ignored. takes to long - * - * @throws ExecutionException */ @Test @Ignore @@ -589,7 +545,7 @@ public void queryWithTTL() throws InterruptedException, ExecutionException { new AqlQueryOptions().batchSize(5).ttl(ttl), String.class).get(); assertThat(cursor, is(notNullValue())); for (int i = 0; i < 10; i++, cursor.next()) { - assertThat(cursor.hasNext(), is(i != 10)); + assertThat(cursor.hasNext(), is(true)); if (i == 1) { Thread.sleep(wait * 1000); } @@ -627,9 +583,7 @@ public void changeQueryCache() throws InterruptedException, ExecutionException { @Test public void queryWithCache() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() != ServerRole.SINGLE) { - return; - } + assumeTrue(isSingleServer()); try { db.createCollection(COLLECTION_NAME, null).get(); for (int i = 0; i < 10; i++) { @@ -685,7 +639,7 @@ public void queryCursor() throws InterruptedException, ExecutionException { assertThat(cursor2.hasNext(), is(true)); for (int i = 0; i < batchSize; i++, cursor.next()) { - assertThat(cursor.hasNext(), is(i != batchSize)); + assertThat(cursor.hasNext(), is(true)); } } finally { db.collection(COLLECTION_NAME).drop().get(); @@ -731,7 +685,7 @@ public void queryWithBindVars() throws InterruptedException, ExecutionException .whenComplete((cursor, ex) -> { assertThat(cursor, is(notNullValue())); for (int i = 0; i < 5; i++, cursor.next()) { - assertThat(cursor.hasNext(), is(i != 5)); + assertThat(cursor.hasNext(), is(true)); } }) .get(); @@ -786,7 +740,7 @@ public void explainQuery() throws InterruptedException, ExecutionException { @Test public void parseQuery() throws InterruptedException, ExecutionException { - Assume.assumeTrue(requireVersion(3, 4)); + assumeTrue(isAtLeastVersion(3, 4)); arangoDB.db().parseQuery("for i in _apps return i") .whenComplete((parse, ex) -> { assertThat(parse, is(notNullValue())); @@ -859,7 +813,7 @@ public void createGetDeleteAqlFunction() throws InterruptedException, ExecutionE final Integer deleteCount = db.deleteAqlFunction("myfunctions::temperature::celsiustofahrenheit", null) .get(); // compatibility with ArangoDB < 3.4 - if (requireVersion(3, 4)) { + if (isAtLeastVersion(3, 4)) { assertThat(deleteCount, is(1)); } else { assertThat(deleteCount, is(nullValue())); @@ -921,9 +875,7 @@ public void getGraphs() throws InterruptedException, ExecutionException { public void transactionString() throws InterruptedException, ExecutionException { final TransactionOptions options = new TransactionOptions().params("test"); db.transaction("function (params) {return params;}", String.class, options) - .whenComplete((result, ex) -> { - assertThat(result, is("test")); - }) + .whenComplete((result, ex) -> assertThat(result, is("test"))) .get(); } @@ -931,9 +883,7 @@ public void transactionString() throws InterruptedException, ExecutionException public void transactionNumber() throws InterruptedException, ExecutionException { final TransactionOptions options = new TransactionOptions().params(5); db.transaction("function (params) {return params;}", Integer.class, options) - .whenComplete((result, ex) -> { - assertThat(result, is(5)); - }) + .whenComplete((result, ex) -> assertThat(result, is(5))) .get(); } @@ -976,6 +926,7 @@ public void transactionallowImplicit() throws InterruptedException, ExecutionExc } } + @SuppressWarnings({"WeakerAccess", "unused"}) protected static class TransactionTestEntity { private String value; @@ -1038,7 +989,7 @@ public void executeTraversal() throws InterruptedException, ExecutionException { assertThat(vertices.size(), is(4)); final Iterator verticesIterator = vertices.iterator(); - final Collection v = Arrays.asList(new String[]{"Alice", "Bob", "Charlie", "Dave"}); + final Collection v = Arrays.asList("Alice", "Bob", "Charlie", "Dave"); for (; verticesIterator.hasNext(); ) { assertThat(v.contains(verticesIterator.next().getKey()), is(true)); } @@ -1088,7 +1039,7 @@ public void shouldIncludeExceptionMessage() throws InterruptedException, Executi assertThat(e.getCause(), instanceOf(ArangoDBException.class)); ArangoDBException cause = ((ArangoDBException) e.getCause()); assertThat(cause.getErrorNum(), is(1650)); - if (requireVersion(3, 4)) { + if (isAtLeastVersion(3, 4)) { assertThat(cause.getErrorMessage(), is(exceptionMessage)); } } diff --git a/src/test/java/com/arangodb/ArangoGraphTest.java b/src/test/java/com/arangodb/ArangoGraphTest.java index d6ce62b..346739f 100644 --- a/src/test/java/com/arangodb/ArangoGraphTest.java +++ b/src/test/java/com/arangodb/ArangoGraphTest.java @@ -20,12 +20,11 @@ package com.arangodb; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; +import com.arangodb.entity.*; +import com.arangodb.model.GraphCreateOptions; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; import java.util.ArrayList; import java.util.Collection; @@ -33,16 +32,10 @@ import java.util.Iterator; import java.util.concurrent.ExecutionException; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.arangodb.entity.CollectionPropertiesEntity; -import com.arangodb.entity.EdgeDefinition; -import com.arangodb.entity.GraphEntity; -import com.arangodb.entity.License; -import com.arangodb.entity.ServerRole; -import com.arangodb.model.GraphCreateOptions; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeTrue; /** * @author Mark Vollmary @@ -100,25 +93,15 @@ public void create() throws InterruptedException, ExecutionException { @Test public void createWithReplicationAndMinReplicationFactor() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - - // if we do not have a cluster => exit - if (arangoDB.getRole().get() == ServerRole.SINGLE) { - return; - } - - try { - final Collection edgeDefinitions = new ArrayList(); - final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2)).get(); - assertThat(graph, is(notNullValue())); - assertThat(graph.getName(), is(GRAPH_NAME + "_1")); - assertThat(graph.getMinReplicationFactor(), is(2)); - assertThat(graph.getReplicationFactor(), is(2)); - } finally { - db.graph(GRAPH_NAME + "_1").drop(); - } + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isCluster()); + final Collection edgeDefinitions = new ArrayList<>(); + final GraphEntity graph = db.createGraph(GRAPH_NAME + "_1", edgeDefinitions, new GraphCreateOptions().isSmart(true).replicationFactor(2).minReplicationFactor(2)).get(); + assertThat(graph, is(notNullValue())); + assertThat(graph.getName(), is(GRAPH_NAME + "_1")); + assertThat(graph.getMinReplicationFactor(), is(2)); + assertThat(graph.getReplicationFactor(), is(2)); + db.graph(GRAPH_NAME + "_1").drop(); } @Test @@ -145,7 +128,7 @@ public void getInfo() throws InterruptedException, ExecutionException { assertThat(e2.getTo(), hasItems(VERTEX_COL_1, VERTEX_COL_3)); assertThat(info.getOrphanCollections(), is(empty())); - if (arangoDB.getRole().get() != ServerRole.SINGLE) { + if (isCluster()) { for (final String collection : new String[]{VERTEX_COL_1, VERTEX_COL_2}) { final CollectionPropertiesEntity properties = db.collection(collection).getProperties().get(); assertThat(properties.getReplicationFactor(), is(REPLICATION_FACTOR)); @@ -204,7 +187,7 @@ public void addEdgeDefinition() throws InterruptedException, ExecutionException assertThat(e.getTo(), hasItem(VERTEX_COL_2)); } } - if (arangoDB.getRole().get() != ServerRole.SINGLE) { + if (isCluster()) { final CollectionPropertiesEntity properties = db.collection(EDGE_COL_3).getProperties().get(); assertThat(properties.getReplicationFactor(), is(REPLICATION_FACTOR)); assertThat(properties.getNumberOfShards(), is(NUMBER_OF_SHARDS)); diff --git a/src/test/java/com/arangodb/ArangoRouteTest.java b/src/test/java/com/arangodb/ArangoRouteTest.java index 79e8d01..60d94ab 100644 --- a/src/test/java/com/arangodb/ArangoRouteTest.java +++ b/src/test/java/com/arangodb/ArangoRouteTest.java @@ -21,7 +21,6 @@ package com.arangodb; import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; @@ -31,7 +30,6 @@ import com.arangodb.entity.BaseDocument; import com.arangodb.internal.ArangoRequestParam; -import com.arangodb.velocystream.Response; /** * @author Mark Vollmary diff --git a/src/test/java/com/arangodb/ArangoSearchTest.java b/src/test/java/com/arangodb/ArangoSearchTest.java index 3831585..078d2b4 100644 --- a/src/test/java/com/arangodb/ArangoSearchTest.java +++ b/src/test/java/com/arangodb/ArangoSearchTest.java @@ -20,23 +20,22 @@ package com.arangodb; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.util.*; -import java.util.concurrent.ExecutionException; - +import com.arangodb.entity.ViewEntity; +import com.arangodb.entity.ViewType; import com.arangodb.entity.arangosearch.*; import com.arangodb.model.arangosearch.AnalyzerDeleteOptions; +import com.arangodb.model.arangosearch.ArangoSearchCreateOptions; +import com.arangodb.model.arangosearch.ArangoSearchPropertiesOptions; import org.junit.BeforeClass; import org.junit.Test; -import com.arangodb.entity.ServerRole; -import com.arangodb.entity.ViewEntity; -import com.arangodb.entity.ViewType; -import com.arangodb.model.arangosearch.ArangoSearchCreateOptions; -import com.arangodb.model.arangosearch.ArangoSearchPropertiesOptions; +import java.util.*; +import java.util.concurrent.ExecutionException; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; /** * @author Mark Vollmary @@ -49,25 +48,18 @@ public class ArangoSearchTest extends BaseTest { @BeforeClass public static void setup() throws InterruptedException, ExecutionException { - if (!requireVersion(arangoDB, 3, 4)) { - return; - } db.createArangoSearch(VIEW_NAME, new ArangoSearchCreateOptions()).get(); } @Test public void exists() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isAtLeastVersion(3, 4)); assertThat(db.arangoSearch(VIEW_NAME).exists().get(), is(true)); } @Test public void getInfo() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isAtLeastVersion(3, 4)); final ViewEntity info = db.arangoSearch(VIEW_NAME).getInfo().get(); assertThat(info, is(not(nullValue()))); assertThat(info.getId(), is(not(nullValue()))); @@ -77,9 +69,7 @@ public void getInfo() throws InterruptedException, ExecutionException { @Test public void drop() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isAtLeastVersion(3, 4)); final String name = VIEW_NAME + "_droptest"; db.createArangoSearch(name, new ArangoSearchCreateOptions()).get(); final ArangoViewAsync view = db.arangoSearch(name); @@ -89,12 +79,8 @@ public void drop() throws InterruptedException, ExecutionException { @Test public void rename() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() != ServerRole.SINGLE) { - return; - } - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 4)); final String name = VIEW_NAME + "_renametest"; final String newName = name + "_new"; db.createArangoSearch(name, new ArangoSearchCreateOptions()).get(); @@ -105,9 +91,7 @@ public void rename() throws InterruptedException, ExecutionException { @Test public void create() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isAtLeastVersion(3, 4)); final String name = VIEW_NAME + "_createtest"; final ViewEntity info = db.arangoSearch(name).create().get(); assertThat(info, is(not(nullValue()))); @@ -119,9 +103,7 @@ public void create() throws InterruptedException, ExecutionException { @Test public void createWithOptions() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isAtLeastVersion(3, 4)); final String name = VIEW_NAME + "_createtest_withotpions"; final ViewEntity info = db.arangoSearch(name).create(new ArangoSearchCreateOptions()).get(); assertThat(info, is(not(nullValue()))); @@ -133,9 +115,7 @@ public void createWithOptions() throws InterruptedException, ExecutionException @Test public void createWithPrimarySort() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } + assumeTrue(isAtLeastVersion(3, 5)); final String name = "createWithPrimarySort"; final ArangoSearchCreateOptions options = new ArangoSearchCreateOptions(); @@ -154,9 +134,7 @@ public void createWithPrimarySort() throws ExecutionException, InterruptedExcept @Test public void createWithCommitIntervalMsec() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } + assumeTrue(isAtLeastVersion(3, 5)); final String name = "createWithCommitIntervalMsec"; final ArangoSearchCreateOptions options = new ArangoSearchCreateOptions(); options.commitIntervalMsec(666666L); @@ -176,9 +154,7 @@ public void createWithCommitIntervalMsec() throws ExecutionException, Interrupte @Test public void getProperties() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isAtLeastVersion(3, 4)); final String name = VIEW_NAME + "_getpropertiestest"; final ArangoSearchAsync view = db.arangoSearch(name); view.create(new ArangoSearchCreateOptions()).get(); @@ -197,9 +173,7 @@ public void getProperties() throws InterruptedException, ExecutionException { @Test public void updateProperties() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isAtLeastVersion(3, 4)); db.createCollection("view_update_prop_test_collection").get(); final String name = VIEW_NAME + "_updatepropertiestest"; final ArangoSearchAsync view = db.arangoSearch(name); @@ -232,9 +206,7 @@ public void updateProperties() throws InterruptedException, ExecutionException { @Test public void replaceProperties() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } + assumeTrue(isAtLeastVersion(3, 4)); db.createCollection("view_replace_prop_test_collection").get(); final String name = VIEW_NAME + "_replacepropertiestest"; final ArangoSearchAsync view = db.arangoSearch(name); @@ -297,10 +269,7 @@ private void createGetAndDeleteAnalyzer(AnalyzerEntity options) throws Execution @Test public void identityAnalyzer() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); String name = "test-" + UUID.randomUUID().toString(); Set features = new HashSet<>(); @@ -319,10 +288,7 @@ public void identityAnalyzer() throws ExecutionException, InterruptedException { @Test public void delimiterAnalyzer() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); String name = "test-" + UUID.randomUUID().toString(); Set features = new HashSet<>(); @@ -341,10 +307,7 @@ public void delimiterAnalyzer() throws ExecutionException, InterruptedException @Test public void stemAnalyzer() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); String name = "test-" + UUID.randomUUID().toString(); Set features = new HashSet<>(); @@ -363,10 +326,7 @@ public void stemAnalyzer() throws ExecutionException, InterruptedException { @Test public void normAnalyzer() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); String name = "test-" + UUID.randomUUID().toString(); Set features = new HashSet<>(); @@ -390,10 +350,7 @@ public void normAnalyzer() throws ExecutionException, InterruptedException { @Test public void ngramAnalyzer() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); String name = "test-" + UUID.randomUUID().toString(); Set features = new HashSet<>(); @@ -417,10 +374,7 @@ public void ngramAnalyzer() throws ExecutionException, InterruptedException { @Test public void textAnalyzer() throws ExecutionException, InterruptedException { - if (!requireVersion(3, 5)) { - return; - } - + assumeTrue(isAtLeastVersion(3, 5)); String name = "test-" + UUID.randomUUID().toString(); Set features = new HashSet<>(); diff --git a/src/test/java/com/arangodb/ArangoViewTest.java b/src/test/java/com/arangodb/ArangoViewTest.java index b8e1239..8f1a390 100644 --- a/src/test/java/com/arangodb/ArangoViewTest.java +++ b/src/test/java/com/arangodb/ArangoViewTest.java @@ -20,83 +20,66 @@ package com.arangodb; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - -import java.util.concurrent.ExecutionException; - +import com.arangodb.entity.ViewEntity; +import com.arangodb.entity.ViewType; import org.junit.BeforeClass; import org.junit.Test; -import com.arangodb.entity.ServerRole; -import com.arangodb.entity.ViewEntity; -import com.arangodb.entity.ViewType; +import java.util.concurrent.ExecutionException; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeTrue; /** * @author Mark Vollmary - * */ public class ArangoViewTest extends BaseTest { - private static final String VIEW_NAME = "view_test"; + private static final String VIEW_NAME = "view_test"; - @BeforeClass - public static void setup() throws InterruptedException, ExecutionException { - if (!requireVersion(arangoDB, 3, 4)) { - return; - } - db.createView(VIEW_NAME, ViewType.ARANGO_SEARCH).get(); - } + @BeforeClass + public static void setup() throws InterruptedException, ExecutionException { + db.createView(VIEW_NAME, ViewType.ARANGO_SEARCH).get(); + } - @Test - public void exists() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } - assertThat(db.view(VIEW_NAME).exists().get(), is(true)); - } + @Test + public void exists() throws InterruptedException, ExecutionException { + assumeTrue(isAtLeastVersion(3, 4)); + assertThat(db.view(VIEW_NAME).exists().get(), is(true)); + } - @Test - public void getInfo() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } - final ViewEntity info = db.view(VIEW_NAME).getInfo().get(); - assertThat(info, is(not(nullValue()))); - assertThat(info.getId(), is(not(nullValue()))); - assertThat(info.getName(), is(VIEW_NAME)); - assertThat(info.getType(), is(ViewType.ARANGO_SEARCH)); - } + @Test + public void getInfo() throws InterruptedException, ExecutionException { + assumeTrue(isAtLeastVersion(3, 4)); + final ViewEntity info = db.view(VIEW_NAME).getInfo().get(); + assertThat(info, is(not(nullValue()))); + assertThat(info.getId(), is(not(nullValue()))); + assertThat(info.getName(), is(VIEW_NAME)); + assertThat(info.getType(), is(ViewType.ARANGO_SEARCH)); + } - @Test - public void drop() throws InterruptedException, ExecutionException { - if (!requireVersion(3, 4)) { - return; - } - final String name = VIEW_NAME + "_droptest"; - db.createView(name, ViewType.ARANGO_SEARCH).get(); - final ArangoViewAsync view = db.view(name); - view.drop().get(); - assertThat(view.exists().get(), is(false)); - } + @Test + public void drop() throws InterruptedException, ExecutionException { + assumeTrue(isAtLeastVersion(3, 4)); + final String name = VIEW_NAME + "_droptest"; + db.createView(name, ViewType.ARANGO_SEARCH).get(); + final ArangoViewAsync view = db.view(name); + view.drop().get(); + assertThat(view.exists().get(), is(false)); + } - @Test - public void rename() throws InterruptedException, ExecutionException { - if (arangoDB.getRole().get() != ServerRole.SINGLE) { - return; - } - if (!requireVersion(3, 4)) { - return; - } - final String name = VIEW_NAME + "_renametest"; - final String newName = name + "_new"; - db.createView(name, ViewType.ARANGO_SEARCH).get(); - db.view(name).rename(newName).get(); - assertThat(db.view(name).exists().get(), is(false)); - assertThat(db.view(newName).exists().get(), is(true)); - } + @Test + public void rename() throws InterruptedException, ExecutionException { + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 4)); + final String name = VIEW_NAME + "_renametest"; + final String newName = name + "_new"; + db.createView(name, ViewType.ARANGO_SEARCH).get(); + db.view(name).rename(newName).get(); + assertThat(db.view(name).exists().get(), is(false)); + assertThat(db.view(newName).exists().get(), is(true)); + } } diff --git a/src/test/java/com/arangodb/BaseTest.java b/src/test/java/com/arangodb/BaseTest.java index 4c5ec8b..c5ba726 100644 --- a/src/test/java/com/arangodb/BaseTest.java +++ b/src/test/java/com/arangodb/BaseTest.java @@ -20,21 +20,21 @@ package com.arangodb; -import java.util.concurrent.ExecutionException; - import com.arangodb.entity.ArangoDBEngine; import com.arangodb.entity.ServerRole; import org.junit.AfterClass; import org.junit.BeforeClass; +import java.util.concurrent.ExecutionException; + /** * @author Mark Vollmary */ public abstract class BaseTest { - protected static final String TEST_DB = "java_driver_test_db"; - protected static ArangoDBAsync arangoDB; - protected static ArangoDatabaseAsync db; + static final String TEST_DB = "java_driver_test_db"; + static ArangoDBAsync arangoDB; + static ArangoDatabaseAsync db; @BeforeClass public static void init() throws InterruptedException, ExecutionException { @@ -57,21 +57,26 @@ public static void shutdown() throws InterruptedException, ExecutionException { arangoDB = null; } - protected boolean requireVersion(final int major, final int minor) throws InterruptedException, ExecutionException { - return requireVersion(arangoDB, major, minor); - } - - protected static boolean requireVersion(final ArangoDBAsync arangoDB, final int major, final int minor) + private static boolean isAtLeastVersion(final ArangoDBAsync arangoDB, final int major, final int minor) throws InterruptedException, ExecutionException { final String[] split = arangoDB.getVersion().get().getVersion().split("\\."); - return Integer.valueOf(split[0]) >= major && Integer.valueOf(split[1]) >= minor; + return Integer.parseInt(split[0]) >= major && Integer.parseInt(split[1]) >= minor; } - protected boolean requireStorageEngine(ArangoDBEngine.StorageEngineName name) throws ExecutionException, InterruptedException { + boolean isAtLeastVersion(final int major, final int minor) throws InterruptedException, ExecutionException { + return isAtLeastVersion(arangoDB, major, minor); + } + + boolean isStorageEngine(ArangoDBEngine.StorageEngineName name) throws ExecutionException, InterruptedException { return name.equals(db.getEngine().get().getName()); } - protected boolean requireSingleServer() throws ExecutionException, InterruptedException { + boolean isSingleServer() throws ExecutionException, InterruptedException { return (arangoDB.getRole().get() == ServerRole.SINGLE); } + + boolean isCluster() throws ExecutionException, InterruptedException { + return arangoDB.getRole().get() == ServerRole.COORDINATOR; + } + } diff --git a/src/test/java/com/arangodb/ConcurrencyTest.java b/src/test/java/com/arangodb/ConcurrencyTest.java index cb2cb8d..f247fd9 100644 --- a/src/test/java/com/arangodb/ConcurrencyTest.java +++ b/src/test/java/com/arangodb/ConcurrencyTest.java @@ -51,7 +51,7 @@ public void initialize() { */ @Ignore @Test(timeout = 2000) - public void executorLimit() throws ExecutionException, InterruptedException { + public void executorLimit() { List> futures = IntStream.range(0, 20) .mapToObj(i -> arangoDB.getVersion() .whenComplete((dbVersion, ex) -> { diff --git a/src/test/java/com/arangodb/ConcurrentStreamTransactionsTest.java b/src/test/java/com/arangodb/ConcurrentStreamTransactionsTest.java index c4babf1..9f0f391 100644 --- a/src/test/java/com/arangodb/ConcurrentStreamTransactionsTest.java +++ b/src/test/java/com/arangodb/ConcurrentStreamTransactionsTest.java @@ -58,9 +58,9 @@ public void teardown() throws ExecutionException, InterruptedException { @Test public void conflictOnInsertDocumentWithNotYetCommittedTx() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity tx1 = db.beginStreamTransaction( new StreamTransactionOptions().readCollections(COLLECTION_NAME).writeCollections(COLLECTION_NAME)).get(); @@ -90,9 +90,9 @@ public void conflictOnInsertDocumentWithNotYetCommittedTx() throws ExecutionExce @Test public void conflictOnInsertDocumentWithAlreadyCommittedTx() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity tx1 = db.beginStreamTransaction( new StreamTransactionOptions().readCollections(COLLECTION_NAME).writeCollections(COLLECTION_NAME)).get(); diff --git a/src/test/java/com/arangodb/StreamTransactionTest.java b/src/test/java/com/arangodb/StreamTransactionTest.java index 84e31ab..8601780 100644 --- a/src/test/java/com/arangodb/StreamTransactionTest.java +++ b/src/test/java/com/arangodb/StreamTransactionTest.java @@ -61,9 +61,9 @@ public void teardown() throws ExecutionException, InterruptedException { @Test public void beginStreamTransaction() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity tx = db.beginStreamTransaction(null).get(); assertThat(tx.getId(), is(notNullValue())); @@ -73,9 +73,9 @@ public void beginStreamTransaction() throws ExecutionException, InterruptedExcep @Test public void beginStreamTransactionWithNonExistingCollectionsShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.beginStreamTransaction(new StreamTransactionOptions().writeCollections("notExistingCollection")).get(); @@ -87,9 +87,9 @@ public void beginStreamTransactionWithNonExistingCollectionsShouldThrow() throws @Test public void abortStreamTransaction() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity begunTx = db.beginStreamTransaction(null).get(); StreamTransactionEntity abortedTx = db.abortStreamTransaction(begunTx.getId()).get(); @@ -101,9 +101,9 @@ public void abortStreamTransaction() throws ExecutionException, InterruptedExcep @Test public void abortStreamTransactionTwice() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity begunTx = db.beginStreamTransaction(null).get(); db.abortStreamTransaction(begunTx.getId()).get(); @@ -112,9 +112,9 @@ public void abortStreamTransactionTwice() throws ExecutionException, Interrupted @Test public void abortStreamTransactionWhenTransactionIdDoesNotExistsShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.abortStreamTransaction("000000").get(); @@ -126,9 +126,9 @@ public void abortStreamTransactionWhenTransactionIdDoesNotExistsShouldThrow() th @Test public void abortStreamTransactionWithInvalidTransactionIdShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.abortStreamTransaction("invalidTransactionId").get(); @@ -140,9 +140,9 @@ public void abortStreamTransactionWithInvalidTransactionIdShouldThrow() throws E @Test public void abortCommittedStreamTransactionShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity createdTx = db.beginStreamTransaction(null).get(); db.commitStreamTransaction(createdTx.getId()).get(); @@ -157,9 +157,9 @@ public void abortCommittedStreamTransactionShouldThrow() throws ExecutionExcepti @Test public void getStreamTransaction() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity createdTx = db.beginStreamTransaction(null).get(); StreamTransactionEntity gotTx = db.getStreamTransaction(createdTx.getId()).get(); @@ -173,9 +173,9 @@ public void getStreamTransaction() throws ExecutionException, InterruptedExcepti @Test public void getStreamTransactionWhenTransactionIdDoesNotExistsShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.getStreamTransaction("000000").get(); @@ -187,9 +187,9 @@ public void getStreamTransactionWhenTransactionIdDoesNotExistsShouldThrow() thro @Test public void getStreamTransactionWithInvalidTransactionIdShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.getStreamTransaction("invalidTransactionId").get(); @@ -201,9 +201,9 @@ public void getStreamTransactionWithInvalidTransactionIdShouldThrow() throws Exe @Test public void commitStreamTransaction() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity createdTx = db.beginStreamTransaction(null).get(); StreamTransactionEntity committedTx = db.commitStreamTransaction(createdTx.getId()).get(); @@ -215,9 +215,9 @@ public void commitStreamTransaction() throws ExecutionException, InterruptedExce @Test public void commitStreamTransactionTwice() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity createdTx = db.beginStreamTransaction(null).get(); db.commitStreamTransaction(createdTx.getId()).get(); @@ -226,9 +226,9 @@ public void commitStreamTransactionTwice() throws ExecutionException, Interrupte @Test public void commitStreamTransactionWhenTransactionIdDoesNotExistsShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.commitStreamTransaction("000000").get(); @@ -240,9 +240,9 @@ public void commitStreamTransactionWhenTransactionIdDoesNotExistsShouldThrow() t @Test public void commitStreamTransactionWithInvalidTransactionIdShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.commitStreamTransaction("invalidTransactionId").get(); @@ -254,9 +254,9 @@ public void commitStreamTransactionWithInvalidTransactionIdShouldThrow() throws @Test public void commitAbortedStreamTransactionShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity createdTx = db.beginStreamTransaction(null).get(); db.abortStreamTransaction(createdTx.getId()).get(); @@ -271,9 +271,9 @@ public void commitAbortedStreamTransactionShouldThrow() throws ExecutionExceptio @Test public void getDocument() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity tx = db .beginStreamTransaction(new StreamTransactionOptions().readCollections(COLLECTION_NAME)).get(); @@ -291,9 +291,9 @@ public void getDocument() throws ExecutionException, InterruptedException { @Test public void getDocumentWithNonExistingTransactionIdShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.collection(COLLECTION_NAME) @@ -307,12 +307,12 @@ public void getDocumentWithNonExistingTransactionIdShouldThrow() throws Executio @Test public void insertDocumentWithNonExistingTransactionIdShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { - DocumentCreateEntity txDoc = db.collection(COLLECTION_NAME) + db.collection(COLLECTION_NAME) .insertDocument(new BaseDocument(), new DocumentCreateOptions().streamTransactionId("123456")).get(); fail(); } catch (ExecutionException e) { @@ -322,9 +322,9 @@ public void insertDocumentWithNonExistingTransactionIdShouldThrow() throws Execu @Test public void getDocumentWithInvalidTransactionIdShouldThrow() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); try { db.collection(COLLECTION_NAME) @@ -338,9 +338,9 @@ public void getDocumentWithInvalidTransactionIdShouldThrow() throws ExecutionExc @Test public void getStreamTransactions() throws ExecutionException, InterruptedException { - assumeTrue(requireSingleServer()); - assumeTrue(requireVersion(3, 5)); - assumeTrue(requireStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); + assumeTrue(isSingleServer()); + assumeTrue(isAtLeastVersion(3, 5)); + assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb)); StreamTransactionEntity tx1 = db.beginStreamTransaction(null).get(); StreamTransactionEntity tx2 = db.beginStreamTransaction(null).get(); diff --git a/src/test/java/com/arangodb/example/ExampleBase.java b/src/test/java/com/arangodb/example/ExampleBase.java index 0c2bf00..e4462da 100644 --- a/src/test/java/com/arangodb/example/ExampleBase.java +++ b/src/test/java/com/arangodb/example/ExampleBase.java @@ -34,10 +34,10 @@ */ public class ExampleBase { - protected static final String DB_NAME = "json_example_db"; + private static final String DB_NAME = "json_example_db"; protected static final String COLLECTION_NAME = "json_example_collection"; - protected static ArangoDBAsync arangoDB; + private static ArangoDBAsync arangoDB; protected static ArangoDatabaseAsync db; protected static ArangoCollectionAsync collection; diff --git a/src/test/java/com/arangodb/example/document/InsertDocumentExample.java b/src/test/java/com/arangodb/example/document/InsertDocumentExample.java index f8344e3..757ed81 100644 --- a/src/test/java/com/arangodb/example/document/InsertDocumentExample.java +++ b/src/test/java/com/arangodb/example/document/InsertDocumentExample.java @@ -40,9 +40,7 @@ public class InsertDocumentExample extends ExampleBase { @Test public void insertBean() throws ExecutionException, InterruptedException { collection.insertDocument(new TestEntity("bar")) - .whenComplete((doc, ex) -> { - assertThat(doc.getKey(), is(notNullValue())); - }) + .whenComplete((doc, ex) -> assertThat(doc.getKey(), is(notNullValue()))) .get(); } @@ -51,9 +49,7 @@ public void insertBaseDocument() throws ExecutionException, InterruptedException final BaseDocument value = new BaseDocument(); value.addAttribute("foo", "bar"); collection.insertDocument(value) - .whenComplete((doc, ex) -> { - assertThat(doc.getKey(), is(notNullValue())); - }) + .whenComplete((doc, ex) -> assertThat(doc.getKey(), is(notNullValue()))) .get(); } @@ -62,18 +58,14 @@ public void insertVPack() throws ExecutionException, InterruptedException { final VPackBuilder builder = new VPackBuilder(); builder.add(ValueType.OBJECT).add("foo", "bar").close(); collection.insertDocument(builder.slice()) - .whenComplete((doc, ex) -> { - assertThat(doc.getKey(), is(notNullValue())); - }) + .whenComplete((doc, ex) -> assertThat(doc.getKey(), is(notNullValue()))) .get(); } @Test public void insertJson() throws ExecutionException, InterruptedException { collection.insertDocument("{\"foo\":\"bar\"}") - .whenComplete((doc, ex) -> { - assertThat(doc.getKey(), is(notNullValue())); - }) + .whenComplete((doc, ex) -> assertThat(doc.getKey(), is(notNullValue()))) .get(); } diff --git a/src/test/java/com/arangodb/example/document/TestEntity.java b/src/test/java/com/arangodb/example/document/TestEntity.java index 774aef2..ee9beba 100644 --- a/src/test/java/com/arangodb/example/document/TestEntity.java +++ b/src/test/java/com/arangodb/example/document/TestEntity.java @@ -24,6 +24,7 @@ * @author Mark Vollmary * */ +@SuppressWarnings({"WeakerAccess", "unused"}) public class TestEntity { private String foo; diff --git a/src/test/java/com/arangodb/example/graph/AQLActorsAndMoviesExample.java b/src/test/java/com/arangodb/example/graph/AQLActorsAndMoviesExample.java index 5bf7bfc..9048242 100644 --- a/src/test/java/com/arangodb/example/graph/AQLActorsAndMoviesExample.java +++ b/src/test/java/com/arangodb/example/graph/AQLActorsAndMoviesExample.java @@ -45,6 +45,7 @@ * @see AQL Example Queries on an * Actors and Movies Database */ +@SuppressWarnings("JavaDoc") public class AQLActorsAndMoviesExample { private static final String TEST_DB = "actors_movies_test_db"; @@ -80,10 +81,8 @@ public void allActorsActsInMovie1or2() throws InterruptedException, ExecutionExc final CompletableFuture> f = db.query( "WITH actors FOR x IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN x._id", null, null, String.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), - hasItems("actors/Keanu", "actors/Hugo", "actors/Emil", "actors/Carrie", "actors/Laurence")); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), + hasItems("actors/Keanu", "actors/Hugo", "actors/Emil", "actors/Carrie", "actors/Laurence"))).get(); } /** @@ -98,10 +97,8 @@ public void allActorsActsInMovie1or2UnionDistinct() throws InterruptedException, final CompletableFuture> f = db.query( "WITH actors FOR x IN UNION_DISTINCT ((FOR y IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id), (FOR y IN ANY 'movies/TheDevilsAdvocate' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id)) RETURN x", null, null, String.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), hasItems("actors/Emil", "actors/Hugo", "actors/Carrie", - "actors/Laurence", "actors/Keanu", "actors/Al", "actors/Charlize")); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), hasItems("actors/Emil", "actors/Hugo", "actors/Carrie", + "actors/Laurence", "actors/Keanu", "actors/Al", "actors/Charlize"))).get(); } /** @@ -116,9 +113,7 @@ public void allActorsActsInMovie1and2() throws InterruptedException, ExecutionEx final CompletableFuture> f = db.query( "WITH actors FOR x IN INTERSECTION ((FOR y IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id), (FOR y IN ANY 'movies/TheDevilsAdvocate' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id)) RETURN x", null, null, String.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), hasItems("actors/Keanu")); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), hasItems("actors/Keanu"))).get(); } /** @@ -133,10 +128,8 @@ public void allMoviesBetweenActor1andActor2() throws InterruptedException, Execu final CompletableFuture> f = db.query( "WITH movies FOR x IN INTERSECTION ((FOR y IN ANY 'actors/Hugo' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id), (FOR y IN ANY 'actors/Keanu' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id)) RETURN x", null, null, String.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), - hasItems("movies/TheMatrixRevolutions", "movies/TheMatrixReloaded", "movies/TheMatrix")); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), + hasItems("movies/TheMatrixRevolutions", "movies/TheMatrixReloaded", "movies/TheMatrix"))).get(); } /** @@ -151,12 +144,10 @@ public void allActorsWhoActedIn3orMoreMovies() throws InterruptedException, Exec final CompletableFuture> f = db.query( "FOR x IN actsIn COLLECT actor = x._from WITH COUNT INTO counter FILTER counter >= 3 RETURN {actor: actor, movies: counter}", null, null, Actor.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), - hasItems(new Actor("actors/Carrie", 3), new Actor("actors/CubaG", 4), new Actor("actors/Hugo", 3), - new Actor("actors/Keanu", 4), new Actor("actors/Laurence", 3), new Actor("actors/MegR", 5), - new Actor("actors/TomC", 3), new Actor("actors/TomH", 3))); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), + hasItems(new Actor("actors/Carrie", 3), new Actor("actors/CubaG", 4), new Actor("actors/Hugo", 3), + new Actor("actors/Keanu", 4), new Actor("actors/Laurence", 3), new Actor("actors/MegR", 5), + new Actor("actors/TomC", 3), new Actor("actors/TomH", 3)))).get(); } /** @@ -171,10 +162,8 @@ public void allMoviesWhereExactly6ActorsActedIn() throws InterruptedException, E final CompletableFuture> f = db.query( "FOR x IN actsIn COLLECT movie = x._to WITH COUNT INTO counter FILTER counter == 6 RETURN movie", null, null, String.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), - hasItems("movies/SleeplessInSeattle", "movies/TopGun", "movies/YouveGotMail")); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), + hasItems("movies/SleeplessInSeattle", "movies/TopGun", "movies/YouveGotMail"))).get(); } /** @@ -189,17 +178,15 @@ public void theNumberOfActorsByMovie() throws InterruptedException, ExecutionExc final CompletableFuture> f = db.query( "FOR x IN actsIn COLLECT movie = x._to WITH COUNT INTO counter RETURN {movie: movie, actors: counter}", null, null, Movie.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), - hasItems(new Movie("movies/AFewGoodMen", 11), new Movie("movies/AsGoodAsItGets", 4), - new Movie("movies/JerryMaguire", 9), new Movie("movies/JoeVersustheVolcano", 3), - new Movie("movies/SleeplessInSeattle", 6), new Movie("movies/SnowFallingonCedars", 4), - new Movie("movies/StandByMe", 7), new Movie("movies/TheDevilsAdvocate", 3), - new Movie("movies/TheMatrix", 5), new Movie("movies/TheMatrixReloaded", 4), - new Movie("movies/TheMatrixRevolutions", 4), new Movie("movies/TopGun", 6), - new Movie("movies/WhatDreamsMayCome", 5), new Movie("movies/WhenHarryMetSally", 4), - new Movie("movies/YouveGotMail", 6))); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), + hasItems(new Movie("movies/AFewGoodMen", 11), new Movie("movies/AsGoodAsItGets", 4), + new Movie("movies/JerryMaguire", 9), new Movie("movies/JoeVersustheVolcano", 3), + new Movie("movies/SleeplessInSeattle", 6), new Movie("movies/SnowFallingonCedars", 4), + new Movie("movies/StandByMe", 7), new Movie("movies/TheDevilsAdvocate", 3), + new Movie("movies/TheMatrix", 5), new Movie("movies/TheMatrixReloaded", 4), + new Movie("movies/TheMatrixRevolutions", 4), new Movie("movies/TopGun", 6), + new Movie("movies/WhatDreamsMayCome", 5), new Movie("movies/WhenHarryMetSally", 4), + new Movie("movies/YouveGotMail", 6)))).get(); } /** @@ -214,28 +201,26 @@ public void theNumberOfMoviesByActor() throws InterruptedException, ExecutionExc final CompletableFuture> f = db.query( "FOR x IN actsIn COLLECT actor = x._from WITH COUNT INTO counter RETURN {actor: actor, movies: counter}", null, null, Actor.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), - hasItems(new Actor("actors/Al", 1), new Actor("actors/AnnabellaS", 1), new Actor("actors/AnthonyE", 1), - new Actor("actors/BillPull", 1), new Actor("actors/BillyC", 1), new Actor("actors/BonnieH", 1), - new Actor("actors/BrunoK", 1), new Actor("actors/Carrie", 3), new Actor("actors/CarrieF", 1), - new Actor("actors/Charlize", 1), new Actor("actors/ChristopherG", 1), new Actor("actors/CoreyF", 1), - new Actor("actors/CubaG", 4), new Actor("actors/DaveC", 1), new Actor("actors/DemiM", 1), - new Actor("actors/Emil", 1), new Actor("actors/EthanH", 1), new Actor("actors/GregK", 2), - new Actor("actors/HelenH", 1), new Actor("actors/Hugo", 3), new Actor("actors/JackN", 2), - new Actor("actors/JamesC", 1), new Actor("actors/JamesM", 1), new Actor("actors/JayM", 1), - new Actor("actors/JerryO", 2), new Actor("actors/JohnC", 1), new Actor("actors/JonathanL", 1), - new Actor("actors/JTW", 1), new Actor("actors/Keanu", 4), new Actor("actors/KellyM", 1), - new Actor("actors/KellyP", 1), new Actor("actors/KevinB", 1), new Actor("actors/KevinP", 1), - new Actor("actors/KieferS", 2), new Actor("actors/Laurence", 3), new Actor("actors/MarshallB", 1), - new Actor("actors/MaxS", 2), new Actor("actors/MegR", 5), new Actor("actors/Nathan", 1), - new Actor("actors/NoahW", 1), new Actor("actors/ParkerP", 1), new Actor("actors/ReginaK", 1), - new Actor("actors/ReneeZ", 1), new Actor("actors/RickY", 1), new Actor("actors/RitaW", 1), - new Actor("actors/RiverP", 1), new Actor("actors/Robin", 1), new Actor("actors/RosieO", 1), - new Actor("actors/SteveZ", 1), new Actor("actors/TomC", 3), new Actor("actors/TomH", 3), - new Actor("actors/TomS", 1), new Actor("actors/ValK", 1), new Actor("actors/VictorG", 1), - new Actor("actors/WernerH", 1), new Actor("actors/WilW", 1))); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), + hasItems(new Actor("actors/Al", 1), new Actor("actors/AnnabellaS", 1), new Actor("actors/AnthonyE", 1), + new Actor("actors/BillPull", 1), new Actor("actors/BillyC", 1), new Actor("actors/BonnieH", 1), + new Actor("actors/BrunoK", 1), new Actor("actors/Carrie", 3), new Actor("actors/CarrieF", 1), + new Actor("actors/Charlize", 1), new Actor("actors/ChristopherG", 1), new Actor("actors/CoreyF", 1), + new Actor("actors/CubaG", 4), new Actor("actors/DaveC", 1), new Actor("actors/DemiM", 1), + new Actor("actors/Emil", 1), new Actor("actors/EthanH", 1), new Actor("actors/GregK", 2), + new Actor("actors/HelenH", 1), new Actor("actors/Hugo", 3), new Actor("actors/JackN", 2), + new Actor("actors/JamesC", 1), new Actor("actors/JamesM", 1), new Actor("actors/JayM", 1), + new Actor("actors/JerryO", 2), new Actor("actors/JohnC", 1), new Actor("actors/JonathanL", 1), + new Actor("actors/JTW", 1), new Actor("actors/Keanu", 4), new Actor("actors/KellyM", 1), + new Actor("actors/KellyP", 1), new Actor("actors/KevinB", 1), new Actor("actors/KevinP", 1), + new Actor("actors/KieferS", 2), new Actor("actors/Laurence", 3), new Actor("actors/MarshallB", 1), + new Actor("actors/MaxS", 2), new Actor("actors/MegR", 5), new Actor("actors/Nathan", 1), + new Actor("actors/NoahW", 1), new Actor("actors/ParkerP", 1), new Actor("actors/ReginaK", 1), + new Actor("actors/ReneeZ", 1), new Actor("actors/RickY", 1), new Actor("actors/RitaW", 1), + new Actor("actors/RiverP", 1), new Actor("actors/Robin", 1), new Actor("actors/RosieO", 1), + new Actor("actors/SteveZ", 1), new Actor("actors/TomC", 3), new Actor("actors/TomH", 3), + new Actor("actors/TomS", 1), new Actor("actors/ValK", 1), new Actor("actors/VictorG", 1), + new Actor("actors/WernerH", 1), new Actor("actors/WilW", 1)))).get(); } /** @@ -250,17 +235,16 @@ public void theNumberOfMoviesActedInBetween2005and2010byActor() throws Interrupt final CompletableFuture> f = db.query( "FOR x IN actsIn FILTER x.year >= 1990 && x.year <= 1995 COLLECT actor = x._from WITH COUNT INTO counter RETURN {actor: actor, movies: counter}", null, null, Actor.class); - f.whenComplete((cursor, ex) -> { - assertThat(cursor.asListRemaining(), - hasItems(new Actor("actors/BillPull", 1), new Actor("actors/ChristopherG", 1), - new Actor("actors/CubaG", 1), new Actor("actors/DemiM", 1), new Actor("actors/JackN", 1), - new Actor("actors/JamesM", 1), new Actor("actors/JTW", 1), new Actor("actors/KevinB", 1), - new Actor("actors/KieferS", 1), new Actor("actors/MegR", 2), new Actor("actors/Nathan", 1), - new Actor("actors/NoahW", 1), new Actor("actors/RitaW", 1), new Actor("actors/RosieO", 1), - new Actor("actors/TomC", 1), new Actor("actors/TomH", 2), new Actor("actors/VictorG", 1))); - }).get(); + f.whenComplete((cursor, ex) -> assertThat(cursor.asListRemaining(), + hasItems(new Actor("actors/BillPull", 1), new Actor("actors/ChristopherG", 1), + new Actor("actors/CubaG", 1), new Actor("actors/DemiM", 1), new Actor("actors/JackN", 1), + new Actor("actors/JamesM", 1), new Actor("actors/JTW", 1), new Actor("actors/KevinB", 1), + new Actor("actors/KieferS", 1), new Actor("actors/MegR", 2), new Actor("actors/Nathan", 1), + new Actor("actors/NoahW", 1), new Actor("actors/RitaW", 1), new Actor("actors/RosieO", 1), + new Actor("actors/TomC", 1), new Actor("actors/TomH", 2), new Actor("actors/VictorG", 1)))).get(); } + @SuppressWarnings("WeakerAccess") public static class Actor { private String actor; private Integer movies; @@ -304,17 +288,13 @@ public boolean equals(final Object obj) { return false; } if (movies == null) { - if (other.movies != null) { - return false; - } - } else if (!movies.equals(other.movies)) { - return false; - } - return true; + return other.movies == null; + } else return movies.equals(other.movies); } } + @SuppressWarnings("WeakerAccess") public static class Movie { private String movie; private Integer actors; @@ -358,13 +338,8 @@ public boolean equals(final Object obj) { return false; } if (movie == null) { - if (other.movie != null) { - return false; - } - } else if (!movie.equals(other.movie)) { - return false; - } - return true; + return other.movie == null; + } else return movie.equals(other.movie); } } @@ -395,7 +370,7 @@ private static DocumentCreateEntity saveActor( return actors.insertDocument(value).get(); } - private static DocumentCreateEntity saveActsIn( + private static void saveActsIn( final ArangoCollectionAsync actsIn, final String actor, final String movie, @@ -406,7 +381,7 @@ private static DocumentCreateEntity saveActsIn( value.setTo(movie); value.addAttribute("roles", roles); value.addAttribute("year", year); - return actsIn.insertDocument(value).get(); + actsIn.insertDocument(value).get(); } private static void createData() throws InterruptedException, ExecutionException { diff --git a/src/test/java/com/arangodb/example/graph/BaseGraphTest.java b/src/test/java/com/arangodb/example/graph/BaseGraphTest.java index ea4e985..e82d1b8 100644 --- a/src/test/java/com/arangodb/example/graph/BaseGraphTest.java +++ b/src/test/java/com/arangodb/example/graph/BaseGraphTest.java @@ -30,7 +30,6 @@ import com.arangodb.ArangoDBAsync; import com.arangodb.ArangoDatabaseAsync; import com.arangodb.entity.EdgeDefinition; -import com.arangodb.entity.EdgeEntity; import com.arangodb.entity.VertexEntity; /** @@ -38,12 +37,12 @@ */ public abstract class BaseGraphTest { - protected static final String TEST_DB = "java_driver_graph_test_db"; - protected static ArangoDBAsync arangoDB; - protected static ArangoDatabaseAsync db; - protected static final String GRAPH_NAME = "traversalGraph"; - protected static final String EDGE_COLLECTION_NAME = "edges"; - protected static final String VERTEXT_COLLECTION_NAME = "circles"; + private static final String TEST_DB = "java_driver_graph_test_db"; + private static ArangoDBAsync arangoDB; + static ArangoDatabaseAsync db; + private static final String GRAPH_NAME = "traversalGraph"; + private static final String EDGE_COLLECTION_NAME = "edges"; + private static final String VERTEXT_COLLECTION_NAME = "circles"; @BeforeClass public static void init() throws InterruptedException, ExecutionException { @@ -101,9 +100,9 @@ private static void addExampleElements() throws InterruptedException, ExecutionE saveEdge(new CircleEdge(vJ.getId(), vK.getId(), false, true, "right_zup")); } - private static EdgeEntity saveEdge(final CircleEdge edge) + private static void saveEdge(final CircleEdge edge) throws InterruptedException, ExecutionException { - return db.graph(GRAPH_NAME).edgeCollection(EDGE_COLLECTION_NAME).insertEdge(edge).get(); + db.graph(GRAPH_NAME).edgeCollection(EDGE_COLLECTION_NAME).insertEdge(edge).get(); } private static VertexEntity createVertex(final Circle vertex) diff --git a/src/test/java/com/arangodb/example/graph/Circle.java b/src/test/java/com/arangodb/example/graph/Circle.java index 3c2e48f..72b5dd6 100644 --- a/src/test/java/com/arangodb/example/graph/Circle.java +++ b/src/test/java/com/arangodb/example/graph/Circle.java @@ -27,6 +27,7 @@ * @author a-brandt * */ +@SuppressWarnings({"WeakerAccess", "unused"}) public class Circle { @DocumentField(Type.ID) diff --git a/src/test/java/com/arangodb/example/graph/CircleEdge.java b/src/test/java/com/arangodb/example/graph/CircleEdge.java index dfcc0dc..8ebcc7a 100644 --- a/src/test/java/com/arangodb/example/graph/CircleEdge.java +++ b/src/test/java/com/arangodb/example/graph/CircleEdge.java @@ -27,6 +27,7 @@ * @author a-brandt * */ +@SuppressWarnings({"WeakerAccess", "unused"}) public class CircleEdge { @DocumentField(Type.ID) diff --git a/src/test/java/com/arangodb/example/graph/ShortestPathInAQLExample.java b/src/test/java/com/arangodb/example/graph/ShortestPathInAQLExample.java index 1882358..f86ad88 100644 --- a/src/test/java/com/arangodb/example/graph/ShortestPathInAQLExample.java +++ b/src/test/java/com/arangodb/example/graph/ShortestPathInAQLExample.java @@ -43,6 +43,7 @@ */ public class ShortestPathInAQLExample extends BaseGraphTest { + @SuppressWarnings({"WeakerAccess", "unused"}) public static class Pair { private String vertex; @@ -75,7 +76,7 @@ public void queryShortestPathFromAToD() throws InterruptedException, ExecutionEx assertThat(collection, hasItems("A", "B", "C", "D")); queryString = "WITH circles FOR v, e IN OUTBOUND SHORTEST_PATH 'circles/A' TO 'circles/D' edges RETURN {'vertex': v._key, 'edge': e._key}"; - cursor = db.query(queryString, null, null, Pair.class).get(); + db.query(queryString, null, null, Pair.class).get(); assertThat(collection.size(), is(4)); assertThat(collection, hasItems("A", "B", "C", "D")); } @@ -89,12 +90,12 @@ public void queryShortestPathByFilter() throws InterruptedException, ExecutionEx assertThat(collection, hasItems("A", "B", "C", "D")); queryString = "FOR a IN circles FILTER a._key == 'A' FOR d IN circles FILTER d._key == 'D' FOR v, e IN OUTBOUND SHORTEST_PATH a TO d edges RETURN {'vertex': v._key, 'edge': e._key}"; - cursor = db.query(queryString, null, null, Pair.class).get(); + db.query(queryString, null, null, Pair.class).get(); assertThat(collection.size(), is(4)); assertThat(collection, hasItems("A", "B", "C", "D")); } - protected Collection toVertexCollection(final ArangoCursorAsync cursor) { + private Collection toVertexCollection(final ArangoCursorAsync cursor) { final List result = new ArrayList<>(); for (; cursor.hasNext();) { final Pair pair = cursor.next(); diff --git a/src/test/java/com/arangodb/serde/CustomSerdeTest.java b/src/test/java/com/arangodb/serde/CustomSerdeTest.java index fc5bba9..6eeeaa9 100644 --- a/src/test/java/com/arangodb/serde/CustomSerdeTest.java +++ b/src/test/java/com/arangodb/serde/CustomSerdeTest.java @@ -45,7 +45,7 @@ */ public class CustomSerdeTest { - private static String COLLECTION_NAME = "collection"; + private static final String COLLECTION_NAME = "collection"; private ArangoDatabaseAsync db; private ArangoCollectionAsync collection;