Skip to content

Commit bf6fcab

Browse files
committed
test utils refactoring
1 parent f4e90cc commit bf6fcab

12 files changed

+91
-93
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void getVersion(ArangoDB arangoDB) {
8484
@ParameterizedTest(name = "{index}")
8585
@MethodSource("arangos")
8686
void createAndDeleteDatabase(ArangoDB arangoDB) {
87-
final String dbName = "testDB-" + TestUtils.generateRandomDbName(supportsExtendedDbNames());
87+
final String dbName = rndDbName();
8888
final Boolean resultCreate;
8989
resultCreate = arangoDB.createDatabase(dbName);
9090
assertThat(resultCreate).isTrue();
@@ -113,7 +113,7 @@ void createWithNotNormalizedName(ArangoDB arangoDB) {
113113
void createDatabaseWithOptions(ArangoDB arangoDB) {
114114
assumeTrue(isCluster());
115115
assumeTrue(isAtLeastVersion(3, 6));
116-
final String dbName = "testDB-" + TestUtils.generateRandomDbName(supportsExtendedDbNames());
116+
final String dbName = rndDbName();
117117
final Boolean resultCreate = arangoDB.createDatabase(new DBCreateOptions()
118118
.name(dbName)
119119
.options(new DatabaseOptions()
@@ -140,7 +140,7 @@ void createDatabaseWithOptionsSatellite(ArangoDB arangoDB) {
140140
assumeTrue(isEnterprise());
141141
assumeTrue(isAtLeastVersion(3, 6));
142142

143-
final String dbName = "testDB-" + TestUtils.generateRandomDbName(supportsExtendedDbNames());
143+
final String dbName = rndDbName();
144144
final Boolean resultCreate = arangoDB.createDatabase(new DBCreateOptions()
145145
.name(dbName)
146146
.options(new DatabaseOptions()
@@ -163,7 +163,7 @@ void createDatabaseWithOptionsSatellite(ArangoDB arangoDB) {
163163
@ParameterizedTest(name = "{index}")
164164
@MethodSource("arangos")
165165
void createDatabaseWithUsers(ArangoDB arangoDB) throws InterruptedException {
166-
final String dbName = "testDB-" + TestUtils.generateRandomDbName(supportsExtendedDbNames());
166+
final String dbName = rndDbName();
167167
final Map<String, Object> extra = Collections.singletonMap("key", "value");
168168
final Boolean resultCreate = arangoDB.createDatabase(new DBCreateOptions()
169169
.name(dbName)

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void getAccessibleDatabases(ArangoDatabase db) {
9898
@ParameterizedTest(name = "{index}")
9999
@MethodSource("dbs")
100100
void createCollection(ArangoDatabase db) {
101-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
101+
String name = rndName();
102102
final CollectionEntity result = db.createCollection(name, null);
103103
assertThat(result).isNotNull();
104104
assertThat(result.getId()).isNotNull();
@@ -121,7 +121,7 @@ void createCollectionWithNotNormalizedName(ArangoDatabase db) {
121121
@MethodSource("dbs")
122122
void createCollectionWithReplicationFactor(ArangoDatabase db) {
123123
assumeTrue(isCluster());
124-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
124+
String name = rndName();
125125
final CollectionEntity result = db
126126
.createCollection(name, new CollectionCreateOptions().replicationFactor(2));
127127
assertThat(result).isNotNull();
@@ -136,7 +136,7 @@ void createCollectionWithWriteConcern(ArangoDatabase db) {
136136
assumeTrue(isAtLeastVersion(3, 5));
137137
assumeTrue(isCluster());
138138

139-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
139+
String name = rndName();
140140
final CollectionEntity result = db.createCollection(name,
141141
new CollectionCreateOptions().replicationFactor(2).writeConcern(2));
142142
assertThat(result).isNotNull();
@@ -152,7 +152,7 @@ void createSatelliteCollection(ArangoDatabase db) {
152152
assumeTrue(isEnterprise());
153153
assumeTrue(isCluster());
154154

155-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
155+
String name = rndName();
156156
final CollectionEntity result = db
157157
.createCollection(name, new CollectionCreateOptions().replicationFactor(ReplicationFactor.ofSatellite()));
158158

@@ -166,7 +166,7 @@ void createSatelliteCollection(ArangoDatabase db) {
166166
@MethodSource("dbs")
167167
void createCollectionWithNumberOfShards(ArangoDatabase db) {
168168
assumeTrue(isCluster());
169-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
169+
String name = rndName();
170170
final CollectionEntity result = db
171171
.createCollection(name, new CollectionCreateOptions().numberOfShards(2));
172172

@@ -182,7 +182,7 @@ void createCollectionWithShardingStrategys(ArangoDatabase db) {
182182
assumeTrue(isAtLeastVersion(3, 4));
183183
assumeTrue(isCluster());
184184

185-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
185+
String name = rndName();
186186
final CollectionEntity result = db.createCollection(name, new CollectionCreateOptions()
187187
.shardingStrategy(ShardingStrategy.COMMUNITY_COMPAT.getInternalName()));
188188

@@ -199,10 +199,10 @@ void createCollectionWithSmartJoinAttribute(ArangoDatabase db) {
199199
assumeTrue(isEnterprise());
200200
assumeTrue(isCluster());
201201

202-
String fooName = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
202+
String fooName = rndName();
203203
db.collection(fooName).create();
204204

205-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
205+
String name = rndName();
206206
final CollectionEntity result = db.createCollection(name,
207207
new CollectionCreateOptions().smartJoinAttribute("test123").distributeShardsLike(fooName).shardKeys("_key:"));
208208
assertThat(result).isNotNull();
@@ -217,7 +217,7 @@ void createCollectionWithSmartJoinAttributeWrong(ArangoDatabase db) {
217217
assumeTrue(isEnterprise());
218218
assumeTrue(isCluster());
219219

220-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
220+
String name = rndName();
221221

222222
try {
223223
db.createCollection(name, new CollectionCreateOptions().smartJoinAttribute("test123"));
@@ -232,7 +232,7 @@ void createCollectionWithSmartJoinAttributeWrong(ArangoDatabase db) {
232232
void createCollectionWithNumberOfShardsAndShardKey(ArangoDatabase db) {
233233
assumeTrue(isCluster());
234234

235-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
235+
String name = rndName();
236236
final CollectionEntity result = db
237237
.createCollection(name, new CollectionCreateOptions().numberOfShards(2).shardKeys("a"));
238238
assertThat(result).isNotNull();
@@ -246,7 +246,7 @@ void createCollectionWithNumberOfShardsAndShardKey(ArangoDatabase db) {
246246
@MethodSource("dbs")
247247
void createCollectionWithNumberOfShardsAndShardKeys(ArangoDatabase db) {
248248
assumeTrue(isCluster());
249-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
249+
String name = rndName();
250250
final CollectionEntity result = db.createCollection(name,
251251
new CollectionCreateOptions().numberOfShards(2).shardKeys("a", "b"));
252252
assertThat(result).isNotNull();
@@ -264,8 +264,8 @@ void createCollectionWithDistributeShardsLike(ArangoDatabase db) {
264264

265265
final Integer numberOfShards = 3;
266266

267-
String name1 = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
268-
String name2 = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
267+
String name1 = rndName();
268+
String name2 = rndName();
269269
db.createCollection(name1, new CollectionCreateOptions().numberOfShards(numberOfShards));
270270
db.createCollection(name2, new CollectionCreateOptions().distributeShardsLike(name1));
271271

@@ -274,7 +274,7 @@ void createCollectionWithDistributeShardsLike(ArangoDatabase db) {
274274
}
275275

276276
private void createCollectionWithKeyType(ArangoDatabase db, KeyType keyType) {
277-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
277+
String name = rndName();
278278
db.createCollection(name, new CollectionCreateOptions().keyOptions(
279279
false,
280280
keyType,
@@ -315,7 +315,7 @@ void createCollectionWithKeyTypeUuid(ArangoDatabase db) {
315315
@MethodSource("dbs")
316316
void createCollectionWithJsonSchema(ArangoDatabase db) {
317317
assumeTrue(isAtLeastVersion(3, 7));
318-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
318+
String name = rndName();
319319
String rule = ("{ " +
320320
" \"properties\": {" +
321321
" \"number\": {" +
@@ -363,7 +363,7 @@ void createCollectionWithJsonSchema(ArangoDatabase db) {
363363
@MethodSource("dbs")
364364
void createCollectionWithComputedFields(ArangoDatabase db) {
365365
assumeTrue(isAtLeastVersion(3, 10));
366-
String cName = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
366+
String cName = rndName();
367367
ComputedValue cv = new ComputedValue()
368368
.name("foo")
369369
.expression("RETURN 11")
@@ -398,7 +398,7 @@ void createCollectionWithComputedFields(ArangoDatabase db) {
398398
@ParameterizedTest(name = "{index}")
399399
@MethodSource("dbs")
400400
void deleteCollection(ArangoDatabase db) {
401-
String name = "collection-" + TestUtils.generateRandomName(supportsExtendedNames());
401+
String name = rndName();
402402
db.createCollection(name, null);
403403
db.collection(name).drop();
404404
Throwable thrown = catchThrowable(() -> db.collection(name).getInfo());
@@ -1222,9 +1222,9 @@ void createGraphSatellite(ArangoDatabase db) {
12221222
void createGraphReplicationFaktor(ArangoDatabase db) {
12231223
assumeTrue(isCluster());
12241224
String name = "graph-" + rnd();
1225-
final String edgeCollection = "edge-" + TestUtils.generateRandomName(supportsExtendedNames());
1226-
final String fromCollection = "from-" + TestUtils.generateRandomName(supportsExtendedNames());
1227-
final String toCollection = "to-" + TestUtils.generateRandomName(supportsExtendedNames());
1225+
final String edgeCollection = rndName();
1226+
final String fromCollection = rndName();
1227+
final String toCollection = rndName();
12281228
final Collection<EdgeDefinition> edgeDefinitions =
12291229
Collections.singletonList(new EdgeDefinition().collection(edgeCollection).from(fromCollection).to(toCollection));
12301230
final GraphEntity result = db.createGraph(name, edgeDefinitions, new GraphCreateOptions().replicationFactor(2));
@@ -1240,9 +1240,9 @@ void createGraphReplicationFaktor(ArangoDatabase db) {
12401240
void createGraphNumberOfShards(ArangoDatabase db) {
12411241
assumeTrue(isCluster());
12421242
String name = "graph-" + rnd();
1243-
final String edgeCollection = "edge-" + TestUtils.generateRandomName(supportsExtendedNames());
1244-
final String fromCollection = "from-" + TestUtils.generateRandomName(supportsExtendedNames());
1245-
final String toCollection = "to-" + TestUtils.generateRandomName(supportsExtendedNames());
1243+
final String edgeCollection = rndName();
1244+
final String fromCollection = rndName();
1245+
final String toCollection = rndName();
12461246
final Collection<EdgeDefinition> edgeDefinitions =
12471247
Collections.singletonList(new EdgeDefinition().collection(edgeCollection).from(fromCollection).to(toCollection));
12481248
final GraphEntity result = db

driver/src/test/java/com/arangodb/ArangoDocumentUtilTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ private void checkDocumentKey(final String key) throws ArangoDBException {
6060

6161
@Test
6262
void validateDocumentIdValid() {
63-
checkDocumentId(TestUtils.generateRandomName(true) + "/1test");
64-
checkDocumentId(TestUtils.generateRandomName(true) + "/test1");
65-
checkDocumentId(TestUtils.generateRandomName(true) + "/test-1");
66-
checkDocumentId(TestUtils.generateRandomName(true) + "/test_1");
67-
checkDocumentId(TestUtils.generateRandomName(true) + "/_test");
63+
checkDocumentId(TestUtils.generateRandomName(true, 100) + "/1test");
64+
checkDocumentId(TestUtils.generateRandomName(true, 100) + "/test1");
65+
checkDocumentId(TestUtils.generateRandomName(true, 100) + "/test-1");
66+
checkDocumentId(TestUtils.generateRandomName(true, 100) + "/test_1");
67+
checkDocumentId(TestUtils.generateRandomName(true, 100) + "/_test");
6868
}
6969

7070
@Test

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
class ArangoEdgeCollectionTest extends BaseJunit5 {
4545

4646
private static final String GRAPH_NAME = "EdgeCollectionTest_graph";
47-
private static final String VERTEX_COLLECTION_NAME = "EdgeCollectionTest_vertex_collection-" + TestUtils.generateRandomName(supportsExtendedNames());
48-
private static final String EDGE_COLLECTION_NAME = "EdgeCollectionTest_edge_collection-" + TestUtils.generateRandomName(supportsExtendedNames());
47+
private static final String VERTEX_COLLECTION_NAME = rndName();
48+
private static final String EDGE_COLLECTION_NAME = rndName();
4949

5050
private static Stream<Arguments> args() {
5151
return dbsStream()

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ class ArangoGraphTest extends BaseJunit5 {
5050

5151
private static final String GRAPH_NAME = "ArangoGraphTest_graph";
5252

53-
private static final String VERTEX_COL_1 = "ArangoGraphTest_vertex_collection_1-"+ TestUtils.generateRandomName(supportsExtendedNames());
54-
private static final String VERTEX_COL_2 = "ArangoGraphTest_vertex_collection_2-"+ TestUtils.generateRandomName(supportsExtendedNames());
55-
private static final String VERTEX_COL_3 = "ArangoGraphTest_vertex_collection_3-"+ TestUtils.generateRandomName(supportsExtendedNames());
56-
private static final String VERTEX_COL_4 = "ArangoGraphTest_vertex_collection_4-"+ TestUtils.generateRandomName(supportsExtendedNames());
57-
private static final String VERTEX_COL_5 = "ArangoGraphTest_vertex_collection_5-"+ TestUtils.generateRandomName(supportsExtendedNames());
58-
59-
private static final String EDGE_COL_1 = "ArangoGraphTest_edge_collection_1-"+TestUtils.generateRandomName(supportsExtendedNames());
60-
private static final String EDGE_COL_2 = "ArangoGraphTest_edge_collection_2-"+TestUtils.generateRandomName(supportsExtendedNames());
61-
private static final String EDGE_COL_3 = "ArangoGraphTest_edge_collection_3-"+TestUtils.generateRandomName(supportsExtendedNames());
53+
private static final String VERTEX_COL_1 = rndName();
54+
private static final String VERTEX_COL_2 = rndName();
55+
private static final String VERTEX_COL_3 = rndName();
56+
private static final String VERTEX_COL_4 = rndName();
57+
private static final String VERTEX_COL_5 = rndName();
58+
59+
private static final String EDGE_COL_1 = rndName();
60+
private static final String EDGE_COL_2 = rndName();
61+
private static final String EDGE_COL_3 = rndName();
6262

6363
private static final Integer REPLICATION_FACTOR = 2;
6464
private static final Integer NUMBER_OF_SHARDS = 2;

0 commit comments

Comments
 (0)