Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 61 additions & 129 deletions src/test/java/com/arangodb/ArangoCollectionTest.java

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions src/test/java/com/arangodb/ArangoDBTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
Expand Down
197 changes: 74 additions & 123 deletions src/test/java/com/arangodb/ArangoDatabaseTest.java

Large diffs are not rendered by default.

57 changes: 20 additions & 37 deletions src/test/java/com/arangodb/ArangoGraphTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,22 @@

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;
import java.util.Collections;
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
Expand Down Expand Up @@ -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<EdgeDefinition> edgeDefinitions = new ArrayList<EdgeDefinition>();
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<EdgeDefinition> 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
Expand All @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/com/arangodb/ArangoRouteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -31,7 +30,6 @@

import com.arangodb.entity.BaseDocument;
import com.arangodb.internal.ArangoRequestParam;
import com.arangodb.velocystream.Response;

/**
* @author Mark Vollmary
Expand Down
104 changes: 29 additions & 75 deletions src/test/java/com/arangodb/ArangoSearchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())));
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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())));
Expand All @@ -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())));
Expand All @@ -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();

Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<AnalyzerFeature> features = new HashSet<>();
Expand All @@ -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<AnalyzerFeature> features = new HashSet<>();
Expand All @@ -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<AnalyzerFeature> features = new HashSet<>();
Expand All @@ -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<AnalyzerFeature> features = new HashSet<>();
Expand All @@ -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<AnalyzerFeature> features = new HashSet<>();
Expand All @@ -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<AnalyzerFeature> features = new HashSet<>();
Expand Down
Loading