diff options
author | Bjørn Christian Seime <bjorn.christian@seime.no> | 2022-12-02 14:52:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 14:52:26 +0100 |
commit | 81b884ac555806ae2f0a75773accfd8fe27ecbe1 (patch) | |
tree | 0f92b9ef73a90854cacc96796562d3f21ff1cff6 /container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java | |
parent | c956ac4cb73b329243072aabe35f0da508c02d0f (diff) |
Revert "Let list handling catch up with Java 17"
Diffstat (limited to 'container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java')
-rw-r--r-- | container-search/src/test/java/com/yahoo/prelude/test/IndexFactsTestCase.java | 26 |
1 files changed, 20 insertions, 6 deletions
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))); } } |