aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorn.christian@seime.no>2022-12-02 14:52:26 +0100
committerGitHub <noreply@github.com>2022-12-02 14:52:26 +0100
commit81b884ac555806ae2f0a75773accfd8fe27ecbe1 (patch)
tree0f92b9ef73a90854cacc96796562d3f21ff1cff6 /container-search/src/test/java/com
parentc956ac4cb73b329243072aabe35f0da508c02d0f (diff)
Revert "Let list handling catch up with Java 17"
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, 53 insertions, 28 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 73975ecaa96..e9b1cbabc79 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,6 +1,7 @@
// 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;
@@ -142,7 +143,7 @@ public class FastSearcherTestCase {
@Test
void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
- MockDispatcher dispatcher = MockDispatcher.create(List.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
+ MockDispatcher dispatcher = MockDispatcher.create(ImmutableList.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
FastSearcher fastSearcher = new FastSearcher("container.0",
dispatcher,
@@ -184,7 +185,7 @@ public class FastSearcherTestCase {
searchClusterB.name(clusterName);
b.searchcluster(searchClusterB);
VipStatus vipStatus = new VipStatus(b.build());
- List<Node> nodes_1 = List.of(new Node(0, "host0", 0));
+ List<Node> nodes_1 = ImmutableList.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 5f9d0a53f06..16e27303fa8 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,6 +1,7 @@
// 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;
@@ -11,10 +12,7 @@ import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.test.QueryTestCase;
import org.junit.jupiter.api.Test;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -85,9 +83,9 @@ public class LiteralBoostSearcherTestCase {
private IndexFacts createIndexFacts() {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- clusters.put("cluster1", List.of("type1", "type2", "type3"));
- clusters.put("cluster2", List.of("type4", "type5"));
- Collection<SearchDefinition> searchDefs = List.of(
+ clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
+ clusters.put("cluster2", Arrays.asList("type4", "type5"));
+ Collection<SearchDefinition> searchDefs = ImmutableList.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 9eba23e3ab6..239f4500297 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,6 +4,7 @@ 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;
@@ -22,8 +23,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;
@@ -72,7 +73,12 @@ public class NormalizingSearcherTestCase {
}
private String enc(String s) {
- return URLEncoder.encode(s, StandardCharsets.UTF_8);
+ try {
+ return URLEncoder.encode(s, "utf-8");
+ }
+ catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
}
@Test
@@ -123,9 +129,9 @@ public class NormalizingSearcherTestCase {
private IndexFacts createIndexFacts() {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- clusters.put("cluster1", List.of("type1", "type2", "type3"));
- clusters.put("cluster2", List.of("type4", "type5"));
- Collection<SearchDefinition> searchDefs = List.of(
+ clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
+ clusters.put("cluster2", Arrays.asList("type4", "type5"));
+ Collection<SearchDefinition> searchDefs = ImmutableList.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 e064f8f2ba0..d374bfdeb7b 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,6 +3,7 @@ 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;
@@ -83,7 +84,7 @@ public class JuniperSearcherTestCase {
private Execution createExecution(Chain<Searcher> chain) {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- Collection<SearchDefinition> searchDefs = List.of(createSearchDefinitionOne(), createSearchDefinitionTwo());
+ Collection<SearchDefinition> searchDefs = ImmutableList.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 e6c5a18c9da..4b24ba3671e 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,6 +1,7 @@
// 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;
@@ -12,7 +13,11 @@ 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;
@@ -23,6 +28,7 @@ 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";
@@ -39,8 +45,14 @@ public class IndexFactsTestCase {
}
private Map<String, List<String>> createClusters() {
- return Map.of("clusterOne", List.of("one", "two"),
- "clusterTwo", List.of("one", "three"));
+ 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;
}
@Test
@@ -74,7 +86,7 @@ public class IndexFactsTestCase {
sd2.addIndex(a);
assertEquals(sd2.getDefaultPosition(), "a");
- IndexFacts indexFacts = createIndexFacts(List.of(sd, sd2));
+ IndexFacts indexFacts = createIndexFacts(ImmutableList.of(sd, sd2));
assertEquals(indexFacts.getDefaultPosition(null), "a");
assertEquals(indexFacts.getDefaultPosition("sd"), "c");
}
@@ -130,6 +142,8 @@ 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);
@@ -180,7 +194,7 @@ public class IndexFactsTestCase {
query.getModel().getSources().add("one");
query.getModel().getRestrict().add("two");
- IndexFacts.Session indexFacts = createIndexFacts().newSession(List.of("clusterOne"), List.of());
+ IndexFacts.Session indexFacts = createIndexFacts().newSession(Collections.singleton("clusterOne"), Collections.emptyList());
assertTrue(indexFacts.isIndex("a"));
assertFalse(indexFacts.isIndex("b"));
assertTrue(indexFacts.isIndex("d"));
@@ -268,7 +282,7 @@ public class IndexFactsTestCase {
b.indexinfo(b3);
IndexInfoConfig config = new IndexInfoConfig(b);
- IndexFacts indexFacts = new IndexFacts(new IndexModel(config, Map.of()));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(config, Collections.emptyMap()));
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());
@@ -294,7 +308,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(Map.of(), List.of(first, second)));
+ new IndexFacts(new IndexModel(Collections.emptyMap(), ImmutableList.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 ea29e0a15ff..cb0d4ab923f 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,6 +1,7 @@
// 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;
@@ -13,6 +14,7 @@ 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;
@@ -36,10 +38,10 @@ public class DuplicateSourceTestCase {
SearchChainRegistry searchChains = new SearchChainRegistry();
searchChains.register(new Chain<>("chain1", mockBackendSearcher));
Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("chain1", List.of("doc1", "doc2"));
- IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, List.of()));
+ clusters.put("chain1", ImmutableList.of("doc1", "doc2"));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, Collections.emptyList()));
SearchChainResolver resolver = new SearchChainResolver.Builder()
- .addSearchChain(new ComponentId("chain1"), List.of("doc1", "doc2"))
+ .addSearchChain(new ComponentId("chain1"), ImmutableList.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 49449153d1f..8dccf7d0f38 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,10 +1,13 @@
// 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;
@@ -89,11 +92,11 @@ public class NGramSearcherTestCase {
song.addIndex(songDefault);
Map<String, List<String>> clusters = new HashMap<>();
- clusters.put("musicOnly", List.of(music.getName()));
- clusters.put("songOnly", List.of(song.getName()));
- clusters.put("musicAndSong", List.of(music.getName(), song.getName()));
+ clusters.put("musicOnly", Collections.singletonList(music.getName()));
+ clusters.put("songOnly", Collections.singletonList(song.getName()));
+ clusters.put("musicAndSong", Arrays.asList(music.getName(), song.getName()));
- IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, List.of(music, song)));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(clusters, ImmutableList.of(music, song)));
return new Execution(createSearcher(), Execution.Context.createContextStub(indexFacts));
}