1818 */
1919
2020/*
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.
2222 */
2323package org .opengrok .suggest ;
2424
6060import static org .hamcrest .MatcherAssert .assertThat ;
6161import static org .hamcrest .collection .IsIterableContainingInAnyOrder .containsInAnyOrder ;
6262import static org .hamcrest .collection .IsIterableContainingInOrder .contains ;
63+ import static org .junit .jupiter .api .Assertions .assertEquals ;
6364import static org .junit .jupiter .api .Assertions .assertFalse ;
65+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
6466import static org .junit .jupiter .api .Assertions .assertThrows ;
6567import static org .junit .jupiter .api .Assertions .assertTrue ;
6668
67- public class SuggesterTest {
69+ class SuggesterTest {
6870
6971 private final MeterRegistry registry = new SimpleMeterRegistry ();
7072
@@ -101,13 +103,13 @@ private Suggester.NamedIndexReader getNamedIndexReader() throws IOException {
101103 }
102104
103105 @ Test
104- public void testNullSuggesterDir () {
106+ void testNullSuggesterDir () {
105107 assertThrows (IllegalArgumentException .class ,
106108 () -> new Suggester (null , 10 , Duration .ofMinutes (5 ), false , true , null , Integer .MAX_VALUE , 1 , registry ));
107109 }
108110
109111 @ Test
110- public void testNullDuration () {
112+ void testNullDuration () {
111113 assertThrows (IllegalArgumentException .class , () -> {
112114 Path tempFile = Files .createTempFile ("opengrok" , "test" );
113115 try {
@@ -119,7 +121,7 @@ public void testNullDuration() {
119121 }
120122
121123 @ Test
122- public void testNegativeDuration () {
124+ void testNegativeDuration () {
123125 assertThrows (IllegalArgumentException .class , () -> {
124126 Path tempFile = Files .createTempFile ("opengrok" , "test" );
125127 try {
@@ -172,7 +174,7 @@ private static int getSuggesterProjectDataSize(final Suggester suggester) throws
172174 }
173175
174176 @ Test
175- public void testSimpleSuggestions () throws IOException {
177+ void testSimpleSuggestions () throws IOException {
176178 SuggesterTestData t = initSuggester ();
177179
178180 Suggester .NamedIndexReader ir = t .getNamedIndexReader ();
@@ -187,7 +189,7 @@ public void testSimpleSuggestions() throws IOException {
187189 }
188190
189191 @ Test
190- public void testRefresh () throws IOException {
192+ void testRefresh () throws IOException {
191193 SuggesterTestData t = initSuggester ();
192194
193195 addText (t .getIndexDirectory (), "a1 a2" );
@@ -206,7 +208,7 @@ public void testRefresh() throws IOException {
206208 }
207209
208210 @ Test
209- public void testIndexChangedWhileOffline () throws IOException {
211+ void testIndexChangedWhileOffline () throws IOException {
210212 SuggesterTestData t = initSuggester ();
211213
212214 t .s .close ();
@@ -233,7 +235,7 @@ public void testIndexChangedWhileOffline() throws IOException {
233235 }
234236
235237 @ Test
236- public void testRemove () throws IOException {
238+ void testRemove () throws IOException {
237239 SuggesterTestData t = initSuggester ();
238240
239241 t .s .remove (Collections .singleton ("test" ));
@@ -245,7 +247,7 @@ public void testRemove() throws IOException {
245247 }
246248
247249 @ Test
248- public void testComplexQuerySearch () throws IOException {
250+ void testComplexQuerySearch () throws IOException {
249251 SuggesterTestData t = initSuggester ();
250252
251253 List <LookupResultItem > res = t .s .search (Collections .singletonList (t .getNamedIndexReader ()),
@@ -259,7 +261,7 @@ public void testComplexQuerySearch() throws IOException {
259261
260262 @ Test
261263 @ SuppressWarnings ("unchecked" ) // for contains()
262- public void testOnSearch () throws IOException {
264+ void testOnSearch () throws IOException {
263265 SuggesterTestData t = initSuggester ();
264266
265267 Query q = new BooleanQuery .Builder ()
@@ -278,7 +280,7 @@ public void testOnSearch() throws IOException {
278280 }
279281
280282 @ Test
281- public void testGetSearchCountsForUnknown () throws IOException {
283+ void testGetSearchCountsForUnknown () throws IOException {
282284 SuggesterTestData t = initSuggester ();
283285
284286 assertTrue (t .s .getSearchCounts ("unknown" , "unknown" , 0 , 10 ).isEmpty ());
@@ -288,7 +290,7 @@ public void testGetSearchCountsForUnknown() throws IOException {
288290
289291 @ Test
290292 @ SuppressWarnings ("unchecked" ) // for contains()
291- public void testIncreaseSearchCount () throws IOException {
293+ void testIncreaseSearchCount () throws IOException {
292294 SuggesterTestData t = initSuggester ();
293295
294296 t .s .increaseSearchCount ("test" , new Term ("test" , "term2" ), 100 , true );
@@ -300,4 +302,24 @@ public void testIncreaseSearchCount() throws IOException {
300302 t .close ();
301303 }
302304
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+ }
303325}
0 commit comments