27
27
28
28
import java .util .Collection ;
29
29
30
+ import org .junit .After ;
30
31
import org .junit .Test ;
31
32
import org .junit .runner .RunWith ;
32
33
import org .junit .runners .Parameterized ;
33
34
34
35
import com .arangodb .ArangoDB .Builder ;
36
+ import com .arangodb .entity .ServerRole ;
35
37
import com .arangodb .entity .ViewEntity ;
36
38
import com .arangodb .entity .ViewType ;
37
39
import com .arangodb .entity .arangosearch .ArangoSearchPropertiesEntity ;
38
40
import com .arangodb .entity .arangosearch .CollectionLink ;
39
- import com .arangodb .entity .arangosearch .ConsolidationType ;
40
41
import com .arangodb .entity .arangosearch .ConsolidationPolicy ;
42
+ import com .arangodb .entity .arangosearch .ConsolidationType ;
41
43
import com .arangodb .entity .arangosearch .FieldLink ;
42
44
import com .arangodb .entity .arangosearch .StoreValuesType ;
43
45
import com .arangodb .model .arangosearch .ArangoSearchCreateOptions ;
@@ -54,8 +56,13 @@ public class ArangoSearchTest extends BaseTest {
54
56
55
57
public ArangoSearchTest (final Builder builder ) {
56
58
super (builder );
57
- if (requireVersion (3 , 4 )) {
58
- db .createArangoSearch (VIEW_NAME , new ArangoSearchCreateOptions ());
59
+ }
60
+
61
+ @ After
62
+ public void teardown () {
63
+ try {
64
+ db .view (VIEW_NAME ).drop ();
65
+ } catch (final ArangoDBException e ) {
59
66
}
60
67
}
61
68
@@ -64,6 +71,7 @@ public void exists() {
64
71
if (!requireVersion (3 , 4 )) {
65
72
return ;
66
73
}
74
+ db .createArangoSearch (VIEW_NAME , new ArangoSearchCreateOptions ());
67
75
assertThat (db .arangoSearch (VIEW_NAME ).exists (), is (true ));
68
76
}
69
77
@@ -72,6 +80,7 @@ public void getInfo() {
72
80
if (!requireVersion (3 , 4 )) {
73
81
return ;
74
82
}
83
+ db .createArangoSearch (VIEW_NAME , new ArangoSearchCreateOptions ());
75
84
final ViewEntity info = db .arangoSearch (VIEW_NAME ).getInfo ();
76
85
assertThat (info , is (not (nullValue ())));
77
86
assertThat (info .getId (), is (not (nullValue ())));
@@ -84,67 +93,65 @@ public void drop() {
84
93
if (!requireVersion (3 , 4 )) {
85
94
return ;
86
95
}
87
- final String name = VIEW_NAME + "_droptest" ;
88
- db .createArangoSearch (name , new ArangoSearchCreateOptions ());
89
- final ArangoView view = db .arangoSearch (name );
96
+ db .createArangoSearch (VIEW_NAME , new ArangoSearchCreateOptions ());
97
+ final ArangoView view = db .arangoSearch (VIEW_NAME );
90
98
view .drop ();
91
99
assertThat (view .exists (), is (false ));
92
100
}
93
101
94
102
@ Test
95
103
public void rename () {
104
+ if (arangoDB .getRole () != ServerRole .SINGLE ) {
105
+ return ;
106
+ }
96
107
if (!requireVersion (3 , 4 )) {
97
108
return ;
98
109
}
99
- final String name = VIEW_NAME + "_renametest" ;
100
- final String newName = name + "_new" ;
110
+ final String name = VIEW_NAME + "_new" ;
101
111
db .createArangoSearch (name , new ArangoSearchCreateOptions ());
102
- db .arangoSearch (name ).rename (newName );
112
+ db .arangoSearch (name ).rename (VIEW_NAME );
103
113
assertThat (db .arangoSearch (name ).exists (), is (false ));
104
- assertThat (db .arangoSearch (newName ).exists (), is (true ));
114
+ assertThat (db .arangoSearch (VIEW_NAME ).exists (), is (true ));
105
115
}
106
116
107
117
@ Test
108
118
public void create () {
109
119
if (!requireVersion (3 , 4 )) {
110
120
return ;
111
121
}
112
- final String name = VIEW_NAME + "_createtest" ;
113
- final ViewEntity info = db .arangoSearch (name ).create ();
122
+ final ViewEntity info = db .arangoSearch (VIEW_NAME ).create ();
114
123
assertThat (info , is (not (nullValue ())));
115
124
assertThat (info .getId (), is (not (nullValue ())));
116
- assertThat (info .getName (), is (name ));
125
+ assertThat (info .getName (), is (VIEW_NAME ));
117
126
assertThat (info .getType (), is (ViewType .ARANGO_SEARCH ));
118
- assertThat (db .arangoSearch (name ).exists (), is (true ));
127
+ assertThat (db .arangoSearch (VIEW_NAME ).exists (), is (true ));
119
128
}
120
129
121
130
@ Test
122
131
public void createWithOptions () {
123
132
if (!requireVersion (3 , 4 )) {
124
133
return ;
125
134
}
126
- final String name = VIEW_NAME + "_createtest" ;
127
135
final ArangoSearchCreateOptions options = new ArangoSearchCreateOptions ();
128
- final ViewEntity info = db .arangoSearch (name ).create (options );
136
+ final ViewEntity info = db .arangoSearch (VIEW_NAME ).create (options );
129
137
assertThat (info , is (not (nullValue ())));
130
138
assertThat (info .getId (), is (not (nullValue ())));
131
- assertThat (info .getName (), is (name ));
139
+ assertThat (info .getName (), is (VIEW_NAME ));
132
140
assertThat (info .getType (), is (ViewType .ARANGO_SEARCH ));
133
- assertThat (db .arangoSearch (name ).exists (), is (true ));
141
+ assertThat (db .arangoSearch (VIEW_NAME ).exists (), is (true ));
134
142
}
135
143
136
144
@ Test
137
145
public void getProperties () {
138
146
if (!requireVersion (3 , 4 )) {
139
147
return ;
140
148
}
141
- final String name = VIEW_NAME + "_getpropertiestest" ;
142
- final ArangoSearch view = db .arangoSearch (name );
149
+ final ArangoSearch view = db .arangoSearch (VIEW_NAME );
143
150
view .create (new ArangoSearchCreateOptions ());
144
151
final ArangoSearchPropertiesEntity properties = view .getProperties ();
145
152
assertThat (properties , is (not (nullValue ())));
146
153
assertThat (properties .getId (), is (not (nullValue ())));
147
- assertThat (properties .getName (), is (name ));
154
+ assertThat (properties .getName (), is (VIEW_NAME ));
148
155
assertThat (properties .getType (), is (ViewType .ARANGO_SEARCH ));
149
156
assertThat (properties .getConsolidationIntervalMsec (), is (not (nullValue ())));
150
157
assertThat (properties .getCleanupIntervalStep (), is (not (nullValue ())));
@@ -160,8 +167,7 @@ public void updateProperties() {
160
167
return ;
161
168
}
162
169
db .createCollection ("view_update_prop_test_collection" );
163
- final String name = VIEW_NAME + "_updatepropertiestest" ;
164
- final ArangoSearch view = db .arangoSearch (name );
170
+ final ArangoSearch view = db .arangoSearch (VIEW_NAME );
165
171
view .create (new ArangoSearchCreateOptions ());
166
172
final ArangoSearchPropertiesOptions options = new ArangoSearchPropertiesOptions ();
167
173
options .cleanupIntervalStep (15L );
@@ -195,8 +201,7 @@ public void replaceProperties() {
195
201
return ;
196
202
}
197
203
db .createCollection ("view_replace_prop_test_collection" );
198
- final String name = VIEW_NAME + "_updatepropertiestest" ;
199
- final ArangoSearch view = db .arangoSearch (name );
204
+ final ArangoSearch view = db .arangoSearch (VIEW_NAME );
200
205
view .create (new ArangoSearchCreateOptions ());
201
206
final ArangoSearchPropertiesOptions options = new ArangoSearchPropertiesOptions ();
202
207
options .link (
0 commit comments