Skip to content

Commit 638baf4

Browse files
committed
serde serialization refactoring: graph API
1 parent f1ac12a commit 638baf4

File tree

11 files changed

+39
-17
lines changed

11 files changed

+39
-17
lines changed

src/main/java/com/arangodb/ArangoDB.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import com.arangodb.model.LogOptions;
3939
import com.arangodb.model.UserCreateOptions;
4040
import com.arangodb.model.UserUpdateOptions;
41-
import com.arangodb.serde.ArangoSerde;
4241
import com.arangodb.serde.DataType;
4342
import com.arangodb.serde.InternalSerde;
4443
import com.arangodb.util.ArangoCursorInitializer;

src/main/java/com/arangodb/entity/EdgeDefinition.java

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

2323
import java.util.Arrays;
2424
import java.util.Collection;
25+
import java.util.Collections;
2526

2627
/**
2728
* @author Mark Vollmary
@@ -32,7 +33,7 @@ public class EdgeDefinition {
3233
private String collection;
3334
private Collection<String> from;
3435
private Collection<String> to;
35-
private Options options;
36+
private final Options options = new Options();
3637

3738
public String getCollection() {
3839
return collection;
@@ -65,6 +66,10 @@ public Collection<String> getSatellites() {
6566
return options.satellites;
6667
}
6768

69+
public Options getOptions() {
70+
return options;
71+
}
72+
6873
/**
6974
* @param satellites collection names that will be used to create SatelliteCollections
7075
* for a Hybrid (Disjoint) SmartGraph (Enterprise Edition only). Each array element
@@ -73,12 +78,15 @@ public Collection<String> getSatellites() {
7378
* @since ArangoDB 3.9.0
7479
*/
7580
public EdgeDefinition satellites(final String... satellites) {
76-
options = new Options();
7781
options.satellites = Arrays.asList(satellites);
7882
return this;
7983
}
8084

8185
public static class Options {
82-
private Collection<String> satellites;
86+
private Collection<String> satellites = Collections.emptyList();
87+
88+
public Collection<String> getSatellites() {
89+
return satellites;
90+
}
8391
}
8492
}

src/main/java/com/arangodb/model/GraphCreateOptions.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
import java.util.Arrays;
2727
import java.util.Collection;
28+
import java.util.Collections;
29+
import java.util.Objects;
2830

2931
/**
3032
* @author Mark Vollmary
@@ -33,16 +35,16 @@
3335
public class GraphCreateOptions {
3436

3537
private String name;
36-
private Collection<EdgeDefinition> edgeDefinitions;
37-
private Collection<String> orphanCollections;
38+
private Collection<EdgeDefinition> edgeDefinitions = Collections.emptyList();
39+
private Collection<String> orphanCollections = Collections.emptyList();
3840
private Boolean isSmart;
3941
private SmartOptions options;
4042

4143
public GraphCreateOptions() {
4244
super();
4345
}
4446

45-
protected String getName() {
47+
public String getName() {
4648
return name;
4749
}
4850

@@ -64,6 +66,7 @@ public Collection<EdgeDefinition> getEdgeDefinitions() {
6466
* @return options
6567
*/
6668
protected GraphCreateOptions edgeDefinitions(final Collection<EdgeDefinition> edgeDefinitions) {
69+
Objects.requireNonNull(edgeDefinitions);
6770
this.edgeDefinitions = edgeDefinitions;
6871
return this;
6972
}

src/main/java/com/arangodb/model/StreamTransactionOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public StreamTransactionOptions() {
3939
collections = new TransactionCollectionOptions();
4040
}
4141

42+
public TransactionCollectionOptions getCollections() {
43+
return collections;
44+
}
45+
4246
public Integer getLockTimeout() {
4347
return lockTimeout;
4448
}

src/main/java/com/arangodb/model/TransactionCollectionOptions.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222

2323
import java.util.Arrays;
2424
import java.util.Collection;
25+
import java.util.Collections;
2526

2627
/**
2728
* @author Mark Vollmary
2829
* @author Michele Rastelli
2930
*/
3031
public class TransactionCollectionOptions {
3132

32-
private Collection<String> read;
33-
private Collection<String> write;
34-
private Collection<String> exclusive;
33+
private Collection<String> read = Collections.emptyList();
34+
private Collection<String> write = Collections.emptyList();
35+
private Collection<String> exclusive = Collections.emptyList();
3536
private Boolean allowImplicit;
3637

3738
public Collection<String> getRead() {

src/main/java/com/arangodb/model/VertexCollectionCreateOptions.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
public class VertexCollectionCreateOptions {
3030

3131
private String collection;
32-
private Options options;
32+
private final Options options = new Options();;
3333

3434
public VertexCollectionCreateOptions() {
3535
super();
3636
}
3737

38-
protected String getCollection() {
38+
public String getCollection() {
3939
return collection;
4040
}
4141

@@ -60,13 +60,16 @@ public Collection<String> getSatellites() {
6060
* @since ArangoDB 3.9.0
6161
*/
6262
public VertexCollectionCreateOptions satellites(final String... satellites) {
63-
options = new Options();
6463
options.satellites = Arrays.asList(satellites);
6564
return this;
6665
}
6766

6867
public static class Options {
6968
private Collection<String> satellites;
69+
70+
public Collection<String> getSatellites() {
71+
return satellites;
72+
}
7073
}
7174

7275
}

src/test/java/com/arangodb/ArangoDBTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.arangodb.velocystream.Response;
3232
import org.junit.jupiter.api.AfterAll;
3333
import org.junit.jupiter.api.BeforeAll;
34+
import org.junit.jupiter.api.Disabled;
3435
import org.junit.jupiter.api.Test;
3536
import org.junit.jupiter.params.ParameterizedTest;
3637
import org.junit.jupiter.params.provider.MethodSource;
@@ -591,6 +592,7 @@ void accessMultipleDatabases(ArangoDB arangoDB) {
591592

592593
@ParameterizedTest(name = "{index}")
593594
@MethodSource("arangos")
595+
@Disabled("Manual execution only")
594596
void queueTime(ArangoDB arangoDB) throws InterruptedException, ExecutionException {
595597
List<CompletableFuture<Void>> futures = IntStream.range(0, 80)
596598
.mapToObj(i -> CompletableFuture.runAsync(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.arangodb.velocypack.exception.VPackException;
2929
import com.arangodb.velocystream.Request;
3030
import com.arangodb.velocystream.RequestType;
31+
import org.junit.jupiter.api.Disabled;
3132
import org.junit.jupiter.api.Test;
3233
import org.junit.jupiter.api.Timeout;
3334

@@ -501,6 +502,7 @@ void setLogLevel() throws InterruptedException, ExecutionException {
501502
}
502503

503504
@Test
505+
@Disabled("Manual execution only")
504506
void queueTime() throws InterruptedException, ExecutionException {
505507
List<CompletableFuture<ArangoCursorAsync<Void>>> reqs = IntStream.range(0, 80)
506508
.mapToObj(__ -> arangoDB.db().query("RETURN SLEEP(1)", Void.class))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ void createGetDeleteAqlFunctionWithNamespace() throws InterruptedException, Exec
847847
@Test
848848
void createGraph() throws InterruptedException, ExecutionException {
849849
try {
850-
db.createGraph(GRAPH_NAME, null, null)
850+
db.createGraph(GRAPH_NAME, Collections.emptyList(), null)
851851
.whenComplete((result, ex) -> {
852852
assertThat(result).isNotNull();
853853
assertThat(result.getName()).isEqualTo(GRAPH_NAME);
@@ -861,7 +861,7 @@ void createGraph() throws InterruptedException, ExecutionException {
861861
@Test
862862
void getGraphs() throws InterruptedException, ExecutionException {
863863
try {
864-
db.createGraph(GRAPH_NAME, null, null).get();
864+
db.createGraph(GRAPH_NAME, Collections.emptyList(), null).get();
865865
db.getGraphs()
866866
.whenComplete((graphs, ex) -> {
867867
assertThat(graphs).isNotNull();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void teardown() throws InterruptedException, ExecutionException {
8585
@Test
8686
void create() throws InterruptedException, ExecutionException {
8787
try {
88-
final GraphEntity result = db.graph(GRAPH_NAME + "_1").create(null).get();
88+
final GraphEntity result = db.graph(GRAPH_NAME + "_1").create(Collections.emptyList()).get();
8989
assertThat(result).isNotNull();
9090
assertThat(result.getName()).isEqualTo(GRAPH_NAME + "_1");
9191
} finally {

0 commit comments

Comments
 (0)