From 2a64c712743594812dbf96ec5ff8d3b7482c4748 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Thu, 7 Jul 2022 12:19:09 +0200 Subject: Deprecate ConfigGetter --- .../searchers/ValidateFuzzySearcherTestCase.java | 34 +++++++--------------- .../searchers/ValidateNearestNeighborTestCase.java | 11 ++----- .../test/ValidateMatchPhaseSearcherTestCase.java | 4 +-- 3 files changed, 16 insertions(+), 33 deletions(-) (limited to 'container-search/src/test/java/com/yahoo/search/searchers') diff --git a/container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.java index 587b40dfd03..577963ef2b3 100644 --- a/container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchers/ValidateFuzzySearcherTestCase.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.searchers; -import com.yahoo.config.subscription.ConfigGetter; import com.yahoo.prelude.IndexFacts; import com.yahoo.prelude.IndexModel; import com.yahoo.prelude.SearchDefinition; @@ -13,10 +12,9 @@ import com.yahoo.search.query.parser.ParserEnvironment; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.searchchain.Execution; import com.yahoo.search.yql.YqlParser; -import com.yahoo.vespa.config.search.AttributesConfig.Attribute; import com.yahoo.vespa.config.search.AttributesConfig; +import com.yahoo.vespa.config.search.AttributesConfig.Attribute; import org.junit.Test; - import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -33,35 +31,25 @@ public class ValidateFuzzySearcherTestCase { List attributes; public ValidateFuzzySearcherTestCase() { - int i = 0; attributes = new ArrayList<>(); - StringBuilder attributeConfig = new StringBuilder(); + AttributesConfig.Builder configBuilder = new AttributesConfig.Builder(); + List attributesList = new ArrayList<>(); for (Attribute.Datatype.Enum attr: Attribute.Datatype.Enum.values()) { for (Attribute.Collectiontype.Enum ctype: Attribute.Collectiontype.Enum.values()) { + AttributesConfig.Attribute.Builder attributesBuilder = new AttributesConfig.Attribute.Builder(); String attributeName = attr.name().toLowerCase() + "_" + ctype.name().toLowerCase(); + attributesBuilder.name(attributeName); + attributesBuilder.datatype(attr); + attributesBuilder.collectiontype(ctype); + attributesList.add(attributesBuilder); - attributeConfig.append("attribute[" + i + "].name "); - attributeConfig.append(attributeName); - attributeConfig.append("\n"); - - attributeConfig.append("attribute[" + i + "].datatype "); - attributeConfig.append(attr.name()); - attributeConfig.append("\n"); - - attributeConfig.append("attribute[" + i + "].collectiontype "); - attributeConfig.append(ctype.name()); - attributeConfig.append("\n"); - - i += 1; attributes.add(attributeName); } } + configBuilder.attribute(attributesList); + AttributesConfig config = configBuilder.build(); - searcher = new ValidateFuzzySearcher(ConfigGetter.getConfig( - AttributesConfig.class, - "raw: " + - "attribute[" + attributes.size() + "]\n" + - attributeConfig)); + searcher = new ValidateFuzzySearcher(config); } private String makeQuery(String attribute, String query, int maxEditDistance, int prefixLength) { 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 9a760bfb0cb..c2f4ee31aa8 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 @@ -2,28 +2,22 @@ package com.yahoo.search.searchers; import com.yahoo.config.subscription.ConfigGetter; -import com.yahoo.config.subscription.FileSource; -import com.yahoo.config.subscription.RawSource; import com.yahoo.prelude.IndexFacts; import com.yahoo.prelude.IndexModel; import com.yahoo.prelude.SearchDefinition; import com.yahoo.search.Query; +import com.yahoo.search.Result; +import com.yahoo.search.query.QueryTree; import com.yahoo.search.query.parser.Parsable; import com.yahoo.search.query.parser.ParserEnvironment; -import com.yahoo.search.query.QueryTree; -import com.yahoo.search.Result; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.searchchain.Execution; import com.yahoo.search.yql.YqlParser; import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; import com.yahoo.vespa.config.search.AttributesConfig; - -import com.yahoo.vespa.config.search.RankProfilesConfig; import org.junit.Test; -import java.io.File; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -34,6 +28,7 @@ public class ValidateNearestNeighborTestCase { ValidateNearestNeighborSearcher searcher; + @SuppressWarnings("deprecation") public ValidateNearestNeighborTestCase() { searcher = new ValidateNearestNeighborSearcher( ConfigGetter.getConfig(AttributesConfig.class, diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java index 01e360858c1..1b3689a94b0 100644 --- a/container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchers/test/ValidateMatchPhaseSearcherTestCase.java @@ -3,7 +3,6 @@ package com.yahoo.search.searchers.test; import com.yahoo.component.chain.Chain; import com.yahoo.config.subscription.ConfigGetter; -import com.yahoo.config.subscription.RawSource; import com.yahoo.search.Searcher; import com.yahoo.search.searchchain.Execution; import com.yahoo.search.searchers.ValidateMatchPhaseSearcher; @@ -15,7 +14,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * @author baldersheim @@ -24,6 +23,7 @@ public class ValidateMatchPhaseSearcherTestCase { private final ValidateMatchPhaseSearcher searcher; + @SuppressWarnings("deprecation") public ValidateMatchPhaseSearcherTestCase() { searcher = new ValidateMatchPhaseSearcher( ConfigGetter.getConfig(AttributesConfig.class, -- cgit v1.2.3