summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-19 09:36:01 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-12-19 09:36:01 +0000
commit613c2a8aa1d14347ae3bdaf9efe92633b5077fa9 (patch)
tree2206821e80860df9d9f9171d946264a98f0fe782 /container-search/src/test/java
parented9bf1ee31f28295fc920984e0e0cbf492d49e65 (diff)
Avoid deprecation warnings
Diffstat (limited to 'container-search/src/test/java')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java19
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/LiteralBoostSearcherTestCase.java22
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/querytransform/test/NormalizingSearcherTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java11
-rw-r--r--container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java6
10 files changed, 46 insertions, 66 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
index 6970093fc9d..5b6a4b68930 100644
--- a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.cluster;
+import com.google.common.collect.ImmutableList;
import com.yahoo.cloud.config.ClusterInfoConfig;
import com.yahoo.component.ComponentId;
import com.yahoo.component.provider.ComponentRegistry;
@@ -28,6 +29,7 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -69,15 +71,14 @@ public class ClusterSearcherTestCase {
clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
clusters.put("cluster2", Arrays.asList("type4", "type5"));
clusters.put("type1", Arrays.asList("type6"));
- Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
- searchDefs.put("type1", new SearchDefinition("type1"));
- searchDefs.put("type2", new SearchDefinition("type2"));
- searchDefs.put("type3", new SearchDefinition("type3"));
- searchDefs.put("type4", new SearchDefinition("type4"));
- searchDefs.put("type5", new SearchDefinition("type5"));
- searchDefs.put("type6", new SearchDefinition("type6"));
- SearchDefinition union = new SearchDefinition("union");
- return new IndexFacts(new IndexModel(clusters, searchDefs, union));
+ Collection<SearchDefinition> searchDefs = ImmutableList.of(
+ new SearchDefinition("type1"),
+ new SearchDefinition("type2"),
+ new SearchDefinition("type3"),
+ new SearchDefinition("type4"),
+ new SearchDefinition("type5"),
+ new SearchDefinition("type6"));
+ return new IndexFacts(new IndexModel(clusters, searchDefs));
}
private Set<String> resolve(ClusterSearcher searcher, String query) {
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 9850c80754f..12e756a07ee 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 2017 Yahoo Holdings. 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.Test;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static org.junit.Assert.assertEquals;
@@ -87,15 +85,13 @@ public class LiteralBoostSearcherTestCase {
Map<String, List<String>> clusters = new LinkedHashMap<>();
clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
clusters.put("cluster2", Arrays.asList("type4", "type5"));
- Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
- searchDefs.put("type1", createSearchDefinitionWithFields("type1", true));
- searchDefs.put("type2", createSearchDefinitionWithFields("type2", false));
- searchDefs.put("type3", new SearchDefinition("type3"));
- searchDefs.put("type3", new SearchDefinition("type3"));
- searchDefs.put("type4", new SearchDefinition("type4"));
- searchDefs.put("type5", new SearchDefinition("type5"));
- SearchDefinition union = new SearchDefinition("union");
- return new IndexFacts(new IndexModel(clusters, searchDefs, union));
+ Collection<SearchDefinition> searchDefs = ImmutableList.of(
+ createSearchDefinitionWithFields("type1", true),
+ createSearchDefinitionWithFields("type2", false),
+ new SearchDefinition("type3"),
+ new SearchDefinition("type4"),
+ new SearchDefinition("type5"));
+ return new IndexFacts(new IndexModel(clusters, searchDefs));
}
private SearchDefinition createSearchDefinitionWithFields(String name, boolean literalBoost) {
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 77f7f057eea..bf1ab6fc397 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.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import com.google.common.collect.ImmutableList;
import com.yahoo.language.Linguistics;
import com.yahoo.language.simple.SimpleLinguistics;
import com.yahoo.prelude.Index;
@@ -24,6 +25,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -129,15 +131,13 @@ public class NormalizingSearcherTestCase {
Map<String, List<String>> clusters = new LinkedHashMap<>();
clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
clusters.put("cluster2", Arrays.asList("type4", "type5"));
- Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
- searchDefs.put("type1", createSearchDefinitionWithFields("type1", true));
- searchDefs.put("type2", createSearchDefinitionWithFields("type2", false));
- searchDefs.put("type3", new SearchDefinition("type3"));
- searchDefs.put("type3", new SearchDefinition("type3"));
- searchDefs.put("type4", new SearchDefinition("type4"));
- searchDefs.put("type5", new SearchDefinition("type5"));
- SearchDefinition union = new SearchDefinition("union");
- return new IndexFacts(new IndexModel(clusters, searchDefs, union));
+ Collection<SearchDefinition> searchDefs = ImmutableList.of(
+ createSearchDefinitionWithFields("type1", true),
+ createSearchDefinitionWithFields("type2", false),
+ new SearchDefinition("type3"),
+ new SearchDefinition("type4"),
+ new SearchDefinition("type5"));
+ return new IndexFacts(new IndexModel(clusters, searchDefs));
}
private SearchDefinition createSearchDefinitionWithFields(String name, boolean normalize) {
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 24af91cb5c0..909d641225d 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
@@ -2,9 +2,10 @@
package com.yahoo.prelude.searcher.test;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
+import com.google.common.collect.ImmutableList;
import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.Chain;
import com.yahoo.container.QrSearchersConfig;
@@ -23,6 +24,7 @@ import com.yahoo.prelude.searcher.JuniperSearcher;
import com.yahoo.search.searchchain.Execution;
import org.junit.Test;
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -83,11 +85,8 @@ public class JuniperSearcherTestCase {
private Execution createExecution(Chain<Searcher> chain) {
Map<String, List<String>> clusters = new LinkedHashMap<>();
- Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
- searchDefs.put("one", createSearchDefinitionOne());
- searchDefs.put("two", createSearchDefinitionTwo());
- SearchDefinition union = new SearchDefinition("union");
- IndexModel indexModel = new IndexModel(clusters, searchDefs, union);
+ Collection<SearchDefinition> searchDefs = ImmutableList.of(createSearchDefinitionOne(), createSearchDefinitionTwo());
+ IndexModel indexModel = new IndexModel(clusters, searchDefs);
return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel)));
}
@@ -110,8 +109,7 @@ public class JuniperSearcherTestCase {
}
private SearchDefinition createSearchDefinitionTwo() {
- SearchDefinition two = new SearchDefinition("two");
- return two;
+ return new SearchDefinition("two");
}
@Test
@@ -140,7 +138,7 @@ public class JuniperSearcherTestCase {
@Test
public void testBoldingEquals() {
- assertFalse(new Query("?query=12").equals(new Query("?query=12&bolding=false")));
+ assertNotEquals(new Query("?query=12"), new Query("?query=12&bolding=false"));
}
@Test
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
index 197f1d65172..1b9ca1cd29b 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/ValidatePredicateSearcherTestCase.java
@@ -51,15 +51,11 @@ public class ValidatePredicateSearcherTestCase {
Query query = new Query();
query.getModel().getQueryTree().setRoot(queryTree.getRoot());
- TreeMap<String, List<String>> masterClusters = new TreeMap<>();
- masterClusters.put("cluster", Arrays.asList("document"));
SearchDefinition searchDefinition = new SearchDefinition("document");
Index index = new Index("predicate_field");
index.addCommand(command);
searchDefinition.addIndex(index);
- Map<String, SearchDefinition> searchDefinitionMap = new HashMap<>();
- searchDefinitionMap.put("document", searchDefinition);
- IndexFacts indexFacts = new IndexFacts(new IndexModel(masterClusters, searchDefinitionMap, searchDefinition));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(searchDefinition));
Execution.Context context = new Execution.Context(null, indexFacts, null, new RendererRegistry(MoreExecutors.directExecutor()), new SimpleLinguistics());
return new Execution(searcher, context).search(query);
}
diff --git a/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java b/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java
index ab07baf438a..43f42685021 100644
--- a/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/federation/sourceref/test/SourceRefResolverTestCase.java
@@ -20,10 +20,11 @@ import java.util.Set;
import java.util.TreeMap;
import static com.yahoo.search.federation.sourceref.test.SearchChainResolverTestCase.emptySourceToProviderMap;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.hasItems;
/**
@@ -45,9 +46,9 @@ public class SourceRefResolverTestCase {
private static SourceRefResolver createSourceRefResolver() {
SearchChainResolver.Builder builder = new SearchChainResolver.Builder();
builder.addSearchChain(ComponentId.fromString(cluster1), new FederationOptions().setUseByDefault(true),
- Collections.<String>emptyList());
+ Collections.emptyList());
builder.addSearchChain(ComponentId.fromString(cluster2), new FederationOptions().setUseByDefault(true),
- Collections.<String>emptyList());
+ Collections.emptyList());
return new SourceRefResolver(builder.build());
}
@@ -57,7 +58,7 @@ public class SourceRefResolverTestCase {
masterClusters.put(cluster1, Arrays.asList("document1", "document2"));
masterClusters.put(cluster2, Arrays.asList("document1"));
masterClusters.put(cluster3, Arrays.asList("document3"));
- indexFacts = new IndexFacts(new IndexModel(masterClusters, null, null));
+ indexFacts = new IndexFacts(new IndexModel(masterClusters, Collections.emptyList()));
}
@Test
@@ -69,7 +70,7 @@ public class SourceRefResolverTestCase {
public void lookup_search_chain() throws Exception {
Set<SearchChainInvocationSpec> searchChains = resolve(cluster1);
assertThat(searchChains.size(), is(1));
- assertThat(searchChainIds(searchChains), hasItems(cluster1));
+ assertThat(searchChainIds(searchChains), hasItem(cluster1));
}
@Test
diff --git a/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java
index b1abdacf88f..9ec717e5584 100644
--- a/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/grouping/request/RawBufferTestCase.java
@@ -43,7 +43,7 @@ public class RawBufferTestCase {
@Test
public void requireThatToStringWorks() {
assertToString(Arrays.asList("a".getBytes()[0], "b".getBytes()[0]), "{97,98}");
- assertToString(Arrays.asList(new Byte((byte)2), new Byte((byte)6)), "{2,6}");
+ assertToString(Arrays.asList((byte)2, (byte)6), "{2,6}");
}
public void assertToString(List<Byte> data, String expected) {
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
index a83a0e84bbf..c4d49c11f5e 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
@@ -1369,11 +1369,7 @@ public class JsonRendererTestCase {
}
private Execution createExecution(Chain<Searcher> chain) {
- Map<String, List<String>> clusters = new LinkedHashMap<>();
- Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
- searchDefs.put("one", createSearchDefinitionOne());
- SearchDefinition union = new SearchDefinition("union");
- IndexModel indexModel = new IndexModel(clusters, searchDefs, union);
+ IndexModel indexModel = new IndexModel(createSearchDefinitionOne());
return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel)));
}
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
index 184a8c1aa43..6396981f12d 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/XMLRendererTestCase.java
@@ -206,11 +206,7 @@ public class XMLRendererTestCase {
}
private Execution createExecution(Chain<Searcher> chain) {
- Map<String, List<String>> clusters = new LinkedHashMap<>();
- Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
- searchDefs.put("one", createSearchDefinitionOne());
- SearchDefinition union = new SearchDefinition("union");
- IndexModel indexModel = new IndexModel(clusters, searchDefs, union);
+ IndexModel indexModel = new IndexModel(createSearchDefinitionOne());
return new Execution(chain, Execution.Context.createContextStub(new IndexFacts(indexModel)));
}
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
index 871d9285071..0cbf3a6f92c 100644
--- a/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/searchers/ValidateNearestNeighborTestCase.java
@@ -209,12 +209,8 @@ public class ValidateNearestNeighborTestCase {
Query query = new Query();
query.getModel().getQueryTree().setRoot(queryTree.getRoot());
query.getRanking().getProperties().put("qvector", qTensor);
- TreeMap<String, List<String>> masterClusters = new TreeMap<>();
- masterClusters.put("cluster", Arrays.asList("document"));
SearchDefinition searchDefinition = new SearchDefinition("document");
- Map<String, SearchDefinition> searchDefinitionMap = new HashMap<>();
- searchDefinitionMap.put("document", searchDefinition);
- IndexFacts indexFacts = new IndexFacts(new IndexModel(masterClusters, searchDefinitionMap, searchDefinition));
+ IndexFacts indexFacts = new IndexFacts(new IndexModel(searchDefinition));
Execution.Context context = new Execution.Context(null, indexFacts, null, new RendererRegistry(MoreExecutors.directExecutor()), new SimpleLinguistics());
return new Execution(searcher, context).search(query);
}