Skip to content

Commit c73f788

Browse files
committed
view names
1 parent eae98d1 commit c73f788

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package com.arangodb;
2222

2323
import com.arangodb.internal.util.DocumentUtil;
24+
import com.arangodb.util.TestUtils;
2425
import org.junit.jupiter.api.Test;
2526

2627
import static org.assertj.core.api.Assertions.assertThat;
@@ -59,11 +60,11 @@ private void checkDocumentKey(final String key) throws ArangoDBException {
5960

6061
@Test
6162
void validateDocumentIdValid() {
62-
checkDocumentId("1test/1test");
63-
checkDocumentId("test1/test1");
64-
checkDocumentId("test-1/test-1");
65-
checkDocumentId("test_1/test_1");
66-
checkDocumentId("_test/_test");
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");
6768
}
6869

6970
@Test

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

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.arangodb.entity.arangosearch.analyzer.*;
2828
import com.arangodb.model.InvertedIndexOptions;
2929
import com.arangodb.model.arangosearch.*;
30+
import com.arangodb.util.TestUtils;
3031
import org.junit.jupiter.api.BeforeAll;
3132
import org.junit.jupiter.params.ParameterizedTest;
3233
import org.junit.jupiter.params.provider.MethodSource;
@@ -55,7 +56,7 @@ static void init() {
5556
@MethodSource("dbs")
5657
void exists(ArangoDatabase db) {
5758
assumeTrue(isAtLeastVersion(3, 4));
58-
String viewName = "view-" + rnd();
59+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
5960
db.createArangoSearch(viewName, new ArangoSearchCreateOptions());
6061
assertThat(db.arangoSearch(viewName).exists()).isTrue();
6162
}
@@ -64,7 +65,7 @@ void exists(ArangoDatabase db) {
6465
@MethodSource("dbs")
6566
void createAndExistsSearchAlias(ArangoDatabase db) {
6667
assumeTrue(isAtLeastVersion(3, 10));
67-
String viewName = "view-" + rnd();
68+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
6869
db.createSearchAlias(viewName, new SearchAliasCreateOptions());
6970
assertThat(db.arangoSearch(viewName).exists()).isTrue();
7071
}
@@ -73,7 +74,7 @@ void createAndExistsSearchAlias(ArangoDatabase db) {
7374
@MethodSource("dbs")
7475
void getInfo(ArangoDatabase db) {
7576
assumeTrue(isAtLeastVersion(3, 4));
76-
String viewName = "view-" + rnd();
77+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
7778
db.createArangoSearch(viewName, new ArangoSearchCreateOptions());
7879
final ViewEntity info = db.arangoSearch(viewName).getInfo();
7980
assertThat(info).isNotNull();
@@ -86,7 +87,7 @@ void getInfo(ArangoDatabase db) {
8687
@MethodSource("dbs")
8788
void drop(ArangoDatabase db) {
8889
assumeTrue(isAtLeastVersion(3, 4));
89-
String viewName = "view-" + rnd();
90+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
9091
db.createArangoSearch(viewName, new ArangoSearchCreateOptions());
9192
final ArangoView view = db.arangoSearch(viewName);
9293
view.drop();
@@ -98,7 +99,7 @@ void drop(ArangoDatabase db) {
9899
void rename(ArangoDatabase db) {
99100
assumeTrue(isSingleServer());
100101
assumeTrue(isAtLeastVersion(3, 4));
101-
String viewName = "view-" + rnd();
102+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
102103
final String name = viewName + "_new";
103104
db.createArangoSearch(name, new ArangoSearchCreateOptions());
104105
db.arangoSearch(name).rename(viewName);
@@ -110,7 +111,7 @@ void rename(ArangoDatabase db) {
110111
@MethodSource("dbs")
111112
void createArangoSearchView(ArangoDatabase db) {
112113
assumeTrue(isAtLeastVersion(3, 4));
113-
String viewName = "view-" + rnd();
114+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
114115
final ViewEntity info = db.arangoSearch(viewName).create();
115116
assertThat(info).isNotNull();
116117
assertThat(info.getId()).isNotNull();
@@ -123,7 +124,7 @@ void createArangoSearchView(ArangoDatabase db) {
123124
@MethodSource("dbs")
124125
void createSearchAliasView(ArangoDatabase db) {
125126
assumeTrue(isAtLeastVersion(3, 10));
126-
String viewName = "view-" + rnd();
127+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
127128
final ViewEntity info = db.searchAlias(viewName).create();
128129
assertThat(info).isNotNull();
129130
assertThat(info.getId()).isNotNull();
@@ -136,7 +137,7 @@ void createSearchAliasView(ArangoDatabase db) {
136137
@MethodSource("dbs")
137138
void createArangoSearchViewWithOptions(ArangoDatabase db) {
138139
assumeTrue(isAtLeastVersion(3, 4));
139-
String viewName = "view-" + rnd();
140+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
140141
final ArangoSearchCreateOptions options = new ArangoSearchCreateOptions();
141142
final ViewEntity info = db.arangoSearch(viewName).create(options);
142143
assertThat(info).isNotNull();
@@ -150,7 +151,7 @@ void createArangoSearchViewWithOptions(ArangoDatabase db) {
150151
@MethodSource("dbs")
151152
void createArangoSearchViewWithPrimarySort(ArangoDatabase db) {
152153
assumeTrue(isAtLeastVersion(3, 5));
153-
String viewName = "view-" + rnd();
154+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
154155
final ArangoSearchCreateOptions options = new ArangoSearchCreateOptions();
155156

156157
final PrimarySort primarySort = PrimarySort.on("myFieldName");
@@ -186,7 +187,7 @@ void createArangoSearchViewWithPrimarySort(ArangoDatabase db) {
186187
@MethodSource("dbs")
187188
void createArangoSearchViewWithCommitIntervalMsec(ArangoDatabase db) {
188189
assumeTrue(isAtLeastVersion(3, 5));
189-
String viewName = "view-" + rnd();
190+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
190191
final ArangoSearchCreateOptions options = new ArangoSearchCreateOptions();
191192
options.commitIntervalMsec(666666L);
192193

@@ -207,7 +208,7 @@ void createArangoSearchViewWithCommitIntervalMsec(ArangoDatabase db) {
207208
@MethodSource("dbs")
208209
void createSearchAliasViewWithOptions(ArangoDatabase db) {
209210
assumeTrue(isAtLeastVersion(3, 10));
210-
String viewName = "view-" + rnd();
211+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
211212
final SearchAliasCreateOptions options = new SearchAliasCreateOptions();
212213
final ViewEntity info = db.searchAlias(viewName).create(options);
213214
assertThat(info).isNotNull();
@@ -222,17 +223,17 @@ void createSearchAliasViewWithOptions(ArangoDatabase db) {
222223
void createSearchAliasViewWithIndexesAndGetProperties(ArangoDatabase db) {
223224
assumeTrue(isAtLeastVersion(3, 10));
224225
ArangoCollection col = db.collection(COLL_1);
225-
String idxName1 = "idx-" + rnd();
226+
String idxName1 = "idx-" + TestUtils.generateRandomName(supportsExtendedNames());
226227
col.ensureInvertedIndex(new InvertedIndexOptions()
227228
.name(idxName1)
228229
.fields(new InvertedIndexField().name("a" + rnd())));
229230

230-
String idxName2 = "idx-" + rnd();
231+
String idxName2 = "idx-" + TestUtils.generateRandomName(supportsExtendedNames());
231232
col.ensureInvertedIndex(new InvertedIndexOptions()
232233
.name(idxName2)
233234
.fields(new InvertedIndexField().name("a" + rnd())));
234235

235-
String viewName = "view-" + rnd();
236+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
236237
final SearchAliasCreateOptions options = new SearchAliasCreateOptions()
237238
.indexes(
238239
new SearchAliasIndex(COLL_1, idxName1, SearchAliasIndex.OperationType.add),
@@ -260,7 +261,7 @@ void createSearchAliasViewWithIndexesAndGetProperties(ArangoDatabase db) {
260261
@MethodSource("dbs")
261262
void getArangoSearchViewProperties(ArangoDatabase db) {
262263
assumeTrue(isAtLeastVersion(3, 4));
263-
String viewName = "view-" + rnd();
264+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
264265
final ArangoSearch view = db.arangoSearch(viewName);
265266
view.create(new ArangoSearchCreateOptions());
266267
final ArangoSearchPropertiesEntity properties = view.getProperties();
@@ -280,7 +281,7 @@ void getArangoSearchViewProperties(ArangoDatabase db) {
280281
@MethodSource("dbs")
281282
void updateArangoSearchViewProperties(ArangoDatabase db) {
282283
assumeTrue(isAtLeastVersion(3, 4));
283-
String viewName = "view-" + rnd();
284+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
284285
final ArangoSearch view = db.arangoSearch(viewName);
285286
view.create(new ArangoSearchCreateOptions());
286287
final ArangoSearchPropertiesOptions options = new ArangoSearchPropertiesOptions();
@@ -314,17 +315,17 @@ void updateArangoSearchViewProperties(ArangoDatabase db) {
314315
void updateSearchAliasViewWithIndexesAndGetProperties(ArangoDatabase db) {
315316
assumeTrue(isAtLeastVersion(3, 10));
316317
ArangoCollection col = db.collection(COLL_1);
317-
String idxName = "idx-" + rnd();
318+
String idxName = "idx-" + TestUtils.generateRandomName(supportsExtendedNames());
318319
col.ensureInvertedIndex(new InvertedIndexOptions()
319320
.name(idxName)
320321
.fields(new InvertedIndexField().name("a" + rnd())));
321322
ArangoCollection col2 = db.collection(COLL_2);
322-
String idxName2 = "idx-" + rnd();
323+
String idxName2 = "idx-" + TestUtils.generateRandomName(supportsExtendedNames());
323324
col2.ensureInvertedIndex(new InvertedIndexOptions()
324325
.name(idxName2)
325326
.fields(new InvertedIndexField().name("a" + rnd())));
326327

327-
String viewName = "view-" + rnd();
328+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
328329
final SearchAliasCreateOptions options = new SearchAliasCreateOptions()
329330
.indexes(new SearchAliasIndex(COLL_1, idxName));
330331
final ViewEntity info = db.searchAlias(viewName).create(options);
@@ -353,7 +354,7 @@ void updateSearchAliasViewWithIndexesAndGetProperties(ArangoDatabase db) {
353354
@MethodSource("dbs")
354355
void replaceArangoSearchViewProperties(ArangoDatabase db) {
355356
assumeTrue(isAtLeastVersion(3, 4));
356-
String viewName = "view-" + rnd();
357+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
357358
final ArangoSearch view = db.arangoSearch(viewName);
358359
view.create(new ArangoSearchCreateOptions());
359360
final ArangoSearchPropertiesOptions options = new ArangoSearchPropertiesOptions();
@@ -373,17 +374,17 @@ void replaceArangoSearchViewProperties(ArangoDatabase db) {
373374
void replaceSearchAliasViewWithIndexesAndGetProperties(ArangoDatabase db) {
374375
assumeTrue(isAtLeastVersion(3, 10));
375376
ArangoCollection col = db.collection(COLL_1);
376-
String idxName = "idx-" + rnd();
377+
String idxName = "idx-" + TestUtils.generateRandomName(supportsExtendedNames());
377378
col.ensureInvertedIndex(new InvertedIndexOptions()
378379
.name(idxName)
379380
.fields(new InvertedIndexField().name("a" + rnd())));
380381
ArangoCollection col2 = db.collection(COLL_2);
381-
String idxName2 = "idx-" + rnd();
382+
String idxName2 = "idx-" + TestUtils.generateRandomName(supportsExtendedNames());
382383
col2.ensureInvertedIndex(new InvertedIndexOptions()
383384
.name(idxName2)
384385
.fields(new InvertedIndexField().name("a" + rnd())));
385386

386-
String viewName = "view-" + rnd();
387+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
387388
final SearchAliasCreateOptions options = new SearchAliasCreateOptions()
388389
.indexes(new SearchAliasIndex(COLL_1, idxName));
389390
final ViewEntity info = db.searchAlias(viewName).create(options);
@@ -646,7 +647,7 @@ void enhancedTextAnalyzerTyped(ArangoDatabase db) {
646647
@MethodSource("dbs")
647648
void arangoSearchOptions(ArangoDatabase db) {
648649
assumeTrue(isAtLeastVersion(3, 4));
649-
String viewName = "view-" + rnd();
650+
String viewName = "view-" + TestUtils.generateRandomName(supportsExtendedNames());
650651
FieldLink field = FieldLink.on("f1").inBackground(true);
651652
if (isEnterprise()) {
652653
field.nested(FieldLink.on("f2"));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.arangodb.entity.arangosearch.analyzer.DelimiterAnalyzerProperties;
77
import com.arangodb.model.InvertedIndexOptions;
88
import com.arangodb.model.PersistentIndexOptions;
9+
import com.arangodb.util.TestUtils;
910
import org.junit.jupiter.api.BeforeAll;
1011
import org.junit.jupiter.params.ParameterizedTest;
1112
import org.junit.jupiter.params.provider.Arguments;
@@ -78,7 +79,7 @@ private InvertedIndexOptions createOptions(String analyzerName) {
7879
}
7980

8081
return new InvertedIndexOptions()
81-
.name("invertedIndex-" + UUID.randomUUID())
82+
.name("invertedIndex-" + TestUtils.generateRandomName(supportsExtendedNames()))
8283
.inBackground(true)
8384
.parallelism(5)
8485
.primarySort(new InvertedIndexPrimarySort()

0 commit comments

Comments
 (0)