summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/test/java/com')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java5
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java3
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java26
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java11
7 files changed, 28 insertions, 53 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
index e9b1cbabc79..73975ecaa96 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.fastsearch.test;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.chain.Chain;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.container.handler.VipStatus;
@@ -143,7 +142,7 @@ public class FastSearcherTestCase {
@Test
void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
- MockDispatcher dispatcher = MockDispatcher.create(ImmutableList.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
+ MockDispatcher dispatcher = MockDispatcher.create(List.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
FastSearcher fastSearcher = new FastSearcher("container.0",
dispatcher,
@@ -185,7 +184,7 @@ public class FastSearcherTestCase {
searchClusterB.name(clusterName);
b.searchcluster(searchClusterB);
VipStatus vipStatus = new VipStatus(b.build());
- List<Node> nodes_1 = ImmutableList.of(new Node(0, "host0", 0));
+ List<Node> nodes_1 = List.of(new Node(0, "host0", 0));
RpcResourcePool rpcPool_1 = new RpcResourcePool(MockDispatcher.toDispatchConfig(), MockDispatcher.toNodesConfig(nodes_1));
MockDispatcher dispatch_1 = MockDispatcher.create(nodes_1, rpcPool_1, vipStatus);
dispatch_1.clusterMonitor.shutdown();
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
index 16e27303fa8..5f9d0a53f06 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.querytransform.test;
-import com.google.common.collect.ImmutableList;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
import com.yahoo.prelude.IndexModel;
@@ -12,7 +11,10 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.test.QueryTestCase;
import org.junit.jupiter.api.Test;
-import java.util.*;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -83,9 +85,9 @@ public class LiteralBoostSearcherTestCase {
private IndexFacts createIndexFacts() {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
- clusters.put("cluster2", Arrays.asList("type4", "type5"));
- Collection<SearchDefinition> searchDefs = ImmutableList.of(
+ clusters.put("cluster1", List.of("type1", "type2", "type3"));
+ clusters.put("cluster2", List.of("type4", "type5"));
+ Collection<SearchDefinition> searchDefs = List.of(
createSearchDefinitionWithFields("type1", true),
createSearchDefinitionWithFields("type2", false),
new SearchDefinition("type3"),
diff --git a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java
index 239f4500297..9eba23e3ab6 100644
--- a/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java
@@ -4,7 +4,6 @@ package com.yahoo.prelude.querytransform.test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.google.common.collect.ImmutableList;
import com.yahoo.language.Linguistics;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.Index;
@@ -23,8 +22,8 @@ import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
@@ -73,12 +72,7 @@ public class NormalizingSearcherTestCase {
}
private String enc(String s) {
- try {
- return URLEncoder.encode(s, "utf-8");
- }
- catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
+ return URLEncoder.encode(s, StandardCharsets.UTF_8);
}
@Test
@@ -129,9 +123,9 @@ public class NormalizingSearcherTestCase {
private IndexFacts createIndexFacts() {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
- clusters.put("cluster2", Arrays.asList("type4", "type5"));
- Collection<SearchDefinition> searchDefs = ImmutableList.of(
+ clusters.put("cluster1", List.of("type1", "type2", "type3"));
+ clusters.put("cluster2", List.of("type4", "type5"));
+ Collection<SearchDefinition> searchDefs = List.of(
createSearchDefinitionWithFields("type1", true),
createSearchDefinitionWithFields("type2", false),
new SearchDefinition("type3"),
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
index d374bfdeb7b..e064f8f2ba0 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
@@ -3,7 +3,6 @@ package com.yahoo.prelude.searcher.test;
import static org.junit.jupiter.api.Assertions.*;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.Chain;
import com.yahoo.container.QrSearchersConfig;
@@ -84,7 +83,7 @@ public class JuniperSearcherTestCase {
private Execution createExecution(Chain<Searcher> chain) {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- Collection<SearchDefinition> searchDefs = ImmutableList.of(createSearchDefinitionOne(), createSearchDefinitionTwo());
+ Collection<SearchDefinition> searchDefs = List.of(createSearchDefinitionOne(), createSearchDefinitionTwo());
IndexModel indexModel = new IndexModel(clusters, searchDefs);
return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel)));
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
index 4b24ba3671e..e6c5a18c9da 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.test;
-import com.google.common.collect.ImmutableList;
import com.yahoo.config.subscription.ConfigGetter;
import com.yahoo.language.process.StemMode;
import com.yahoo.prelude.Index;
@@ -13,11 +12,7 @@ import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.search.searchchain.Execution;
import org.junit.jupiter.api.Test;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,7 +23,6 @@ import static org.junit.jupiter.api.Assertions.*;
*
* @author Steinar Knutsen
*/
-@SuppressWarnings({"rawtypes", "unchecked"})
public class IndexFactsTestCase {
private static final String INDEXFACTS_TESTING = "file:src/test/java/com/yahoo/prelude/test/indexfactstesting.cfg";
@@ -45,14 +39,8 @@ public class IndexFactsTestCase {
}
private Map<String, List<String>> createClusters() {
- List<String> clusterOne = new ArrayList<>();
- List<String> clusterTwo = new ArrayList<>();
- clusterOne.addAll(Arrays.asList("one", "two"));
- clusterTwo.addAll(Arrays.asList("one", "three"));
- Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("clusterOne", clusterOne);
- clusters.put("clusterTwo", clusterTwo);
- return clusters;
+ return Map.of("clusterOne", List.of("one", "two"),
+ "clusterTwo", List.of("one", "three"));
}
@Test
@@ -86,7 +74,7 @@ public class IndexFactsTestCase {
sd2.addIndex(a);
assertEquals(sd2.getDefaultPosition(), "a");
- IndexFacts indexFacts = createIndexFacts(ImmutableList.of(sd, sd2));
+ IndexFacts indexFacts = createIndexFacts(List.of(sd, sd2));
assertEquals(indexFacts.getDefaultPosition(null), "a");
assertEquals(indexFacts.getDefaultPosition("sd"), "c");
}
@@ -142,8 +130,6 @@ public class IndexFactsTestCase {
assertExactIsWorking("test");
assertExactIsWorking("artist_name_ft_norm1");
- List search = new ArrayList();
- search.add("three");
Query query = new Query();
query.getModel().getSources().add("three");
IndexFacts.Session threeSession = createIndexFacts().newSession(query);
@@ -194,7 +180,7 @@ public class IndexFactsTestCase {
query.getModel().getSources().add("one");
query.getModel().getRestrict().add("two");
- IndexFacts.Session indexFacts = createIndexFacts().newSession(Collections.singleton("clusterOne"), Collections.emptyList());
+ IndexFacts.Session indexFacts = createIndexFacts().newSession(List.of("clusterOne"), List.of());
assertTrue(indexFacts.isIndex("a"));
assertFalse(indexFacts.isIndex("b"));
assertTrue(indexFacts.isIndex("d"));
@@ -282,7 +268,7 @@ public class IndexFactsTestCase {
b.indexinfo(b3);
IndexInfoConfig config = new IndexInfoConfig(b);
- IndexFacts indexFacts = new IndexFacts(new IndexModel(config, Collections.emptyMap()));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(config, Map.of()));
Query query1 = new Query("?query=url:https://foo.bar");
Query query2 = new Query("?query=url:https://foo.bar&restrict=hasUri");
assertEquals(0, query1.getModel().getRestrict().size());
@@ -308,7 +294,7 @@ public class IndexFactsTestCase {
// Alias to field1 conflics with field1 in the "union" search definition.
// Should not produce an exception (but a log message):
- new IndexFacts(new IndexModel(Collections.emptyMap(), ImmutableList.of(first, second)));
+ new IndexFacts(new IndexModel(Map.of(), List.of(first, second)));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
index cb0d4ab923f..ea29e0a15ff 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/DuplicateSourceTestCase.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.federation;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.Chain;
import com.yahoo.prelude.IndexFacts;
@@ -14,7 +13,6 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChainRegistry;
import org.junit.jupiter.api.Test;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,10 +36,10 @@ public class DuplicateSourceTestCase {
SearchChainRegistry searchChains = new SearchChainRegistry();
searchChains.register(new Chain<>("chain1", mockBackendSearcher));
Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("chain1", ImmutableList.of("doc1", "doc2"));
- IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, Collections.emptyList()));
+ clusters.put("chain1", List.of("doc1", "doc2"));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, List.of()));
SearchChainResolver resolver = new SearchChainResolver.Builder()
- .addSearchChain(new ComponentId("chain1"), ImmutableList.of("doc1", "doc2"))
+ .addSearchChain(new ComponentId("chain1"), List.of("doc1", "doc2"))
.build();
FederationSearcher searcher = new FederationSearcher(new ComponentId("test"), resolver);
diff --git a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
index 8dccf7d0f38..49449153d1f 100644
--- a/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/querytransform/test/NGramSearcherTestCase.java
@@ -1,13 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.querytransform.test;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.google.common.collect.ImmutableList;
import com.yahoo.component.chain.Chain;
import com.yahoo.language.Language;
import com.yahoo.language.simple.SimpleLinguistics;
@@ -92,11 +89,11 @@ public class NGramSearcherTestCase {
song.addIndex(songDefault);
Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("musicOnly", Collections.singletonList(music.getName()));
- clusters.put("songOnly", Collections.singletonList(song.getName()));
- clusters.put("musicAndSong", Arrays.asList(music.getName(), song.getName()));
+ clusters.put("musicOnly", List.of(music.getName()));
+ clusters.put("songOnly", List.of(song.getName()));
+ clusters.put("musicAndSong", List.of(music.getName(), song.getName()));
- IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, ImmutableList.of(music, song)));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, List.of(music, song)));
return new Execution(createSearcher(), Execution.Context.createContextStub(indexFacts));
}