18
18
*/
19
19
20
20
/*
21
- * Copyright (c) 2018, 2021 , Oracle and/or its affiliates. All rights reserved.
21
+ * Copyright (c) 2018, 2022 , Oracle and/or its affiliates. All rights reserved.
22
22
*/
23
23
package org .opengrok .suggest ;
24
24
60
60
import static org .hamcrest .MatcherAssert .assertThat ;
61
61
import static org .hamcrest .collection .IsIterableContainingInAnyOrder .containsInAnyOrder ;
62
62
import static org .hamcrest .collection .IsIterableContainingInOrder .contains ;
63
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
63
64
import static org .junit .jupiter .api .Assertions .assertFalse ;
65
+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
64
66
import static org .junit .jupiter .api .Assertions .assertThrows ;
65
67
import static org .junit .jupiter .api .Assertions .assertTrue ;
66
68
67
- public class SuggesterTest {
69
+ class SuggesterTest {
68
70
69
71
private final MeterRegistry registry = new SimpleMeterRegistry ();
70
72
@@ -101,13 +103,13 @@ private Suggester.NamedIndexReader getNamedIndexReader() throws IOException {
101
103
}
102
104
103
105
@ Test
104
- public void testNullSuggesterDir () {
106
+ void testNullSuggesterDir () {
105
107
assertThrows (IllegalArgumentException .class ,
106
108
() -> new Suggester (null , 10 , Duration .ofMinutes (5 ), false , true , null , Integer .MAX_VALUE , 1 , registry ));
107
109
}
108
110
109
111
@ Test
110
- public void testNullDuration () {
112
+ void testNullDuration () {
111
113
assertThrows (IllegalArgumentException .class , () -> {
112
114
Path tempFile = Files .createTempFile ("opengrok" , "test" );
113
115
try {
@@ -119,7 +121,7 @@ public void testNullDuration() {
119
121
}
120
122
121
123
@ Test
122
- public void testNegativeDuration () {
124
+ void testNegativeDuration () {
123
125
assertThrows (IllegalArgumentException .class , () -> {
124
126
Path tempFile = Files .createTempFile ("opengrok" , "test" );
125
127
try {
@@ -172,7 +174,7 @@ private static int getSuggesterProjectDataSize(final Suggester suggester) throws
172
174
}
173
175
174
176
@ Test
175
- public void testSimpleSuggestions () throws IOException {
177
+ void testSimpleSuggestions () throws IOException {
176
178
SuggesterTestData t = initSuggester ();
177
179
178
180
Suggester .NamedIndexReader ir = t .getNamedIndexReader ();
@@ -187,7 +189,7 @@ public void testSimpleSuggestions() throws IOException {
187
189
}
188
190
189
191
@ Test
190
- public void testRefresh () throws IOException {
192
+ void testRefresh () throws IOException {
191
193
SuggesterTestData t = initSuggester ();
192
194
193
195
addText (t .getIndexDirectory (), "a1 a2" );
@@ -206,7 +208,7 @@ public void testRefresh() throws IOException {
206
208
}
207
209
208
210
@ Test
209
- public void testIndexChangedWhileOffline () throws IOException {
211
+ void testIndexChangedWhileOffline () throws IOException {
210
212
SuggesterTestData t = initSuggester ();
211
213
212
214
t .s .close ();
@@ -233,7 +235,7 @@ public void testIndexChangedWhileOffline() throws IOException {
233
235
}
234
236
235
237
@ Test
236
- public void testRemove () throws IOException {
238
+ void testRemove () throws IOException {
237
239
SuggesterTestData t = initSuggester ();
238
240
239
241
t .s .remove (Collections .singleton ("test" ));
@@ -245,7 +247,7 @@ public void testRemove() throws IOException {
245
247
}
246
248
247
249
@ Test
248
- public void testComplexQuerySearch () throws IOException {
250
+ void testComplexQuerySearch () throws IOException {
249
251
SuggesterTestData t = initSuggester ();
250
252
251
253
List <LookupResultItem > res = t .s .search (Collections .singletonList (t .getNamedIndexReader ()),
@@ -259,7 +261,7 @@ public void testComplexQuerySearch() throws IOException {
259
261
260
262
@ Test
261
263
@ SuppressWarnings ("unchecked" ) // for contains()
262
- public void testOnSearch () throws IOException {
264
+ void testOnSearch () throws IOException {
263
265
SuggesterTestData t = initSuggester ();
264
266
265
267
Query q = new BooleanQuery .Builder ()
@@ -278,7 +280,7 @@ public void testOnSearch() throws IOException {
278
280
}
279
281
280
282
@ Test
281
- public void testGetSearchCountsForUnknown () throws IOException {
283
+ void testGetSearchCountsForUnknown () throws IOException {
282
284
SuggesterTestData t = initSuggester ();
283
285
284
286
assertTrue (t .s .getSearchCounts ("unknown" , "unknown" , 0 , 10 ).isEmpty ());
@@ -288,7 +290,7 @@ public void testGetSearchCountsForUnknown() throws IOException {
288
290
289
291
@ Test
290
292
@ SuppressWarnings ("unchecked" ) // for contains()
291
- public void testIncreaseSearchCount () throws IOException {
293
+ void testIncreaseSearchCount () throws IOException {
292
294
SuggesterTestData t = initSuggester ();
293
295
294
296
t .s .increaseSearchCount ("test" , new Term ("test" , "term2" ), 100 , true );
@@ -300,4 +302,24 @@ public void testIncreaseSearchCount() throws IOException {
300
302
t .close ();
301
303
}
302
304
305
+ @ Test
306
+ void testNamedIndexDirEquals () {
307
+ Suggester .NamedIndexDir namedIndexDir1 = new Suggester .NamedIndexDir ("foo" , Path .of ("/foo" ));
308
+ Suggester .NamedIndexDir namedIndexDir2 = new Suggester .NamedIndexDir ("foo" , Path .of ("/foo" ));
309
+ assertEquals (namedIndexDir1 , namedIndexDir2 );
310
+ }
311
+
312
+ @ Test
313
+ void testNamedIndexDirNotEqualsName () {
314
+ Suggester .NamedIndexDir namedIndexDir1 = new Suggester .NamedIndexDir ("foo" , Path .of ("/foo" ));
315
+ Suggester .NamedIndexDir namedIndexDir2 = new Suggester .NamedIndexDir ("bar" , Path .of ("/foo" ));
316
+ assertNotEquals (namedIndexDir1 , namedIndexDir2 );
317
+ }
318
+
319
+ @ Test
320
+ void testNamedIndexDirNotEqualsPath () {
321
+ Suggester .NamedIndexDir namedIndexDir1 = new Suggester .NamedIndexDir ("foo" , Path .of ("/foo" ));
322
+ Suggester .NamedIndexDir namedIndexDir2 = new Suggester .NamedIndexDir ("foo" , Path .of ("/bar" ));
323
+ assertNotEquals (namedIndexDir1 , namedIndexDir2 );
324
+ }
303
325
}
0 commit comments