aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/processing
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/processing')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSearchFieldsTestCase.java3
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java16
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java7
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java5
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java16
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java9
6 files changed, 37 insertions, 19 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSearchFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSearchFieldsTestCase.java
index 3ffa89b612b..d743f60201e 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSearchFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSearchFieldsTestCase.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.searchdefinition.processing;
+import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.SearchDefinitionTestCase;
@@ -98,7 +99,7 @@ public class ImplicitSearchFieldsTestCase extends SearchDefinitionTestCase {
sb.importFile("src/test/examples/nextgen/simple.sd");
sb.build();
assertNotNull(sb.getSearch());
- new DerivedConfiguration(sb.getSearch(), sb.getRankProfileRegistry());
+ new DerivedConfiguration(sb.getSearch(), sb.getRankProfileRegistry(), new QueryProfileRegistry());
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java
index 86094458b34..800697b3430 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java
@@ -3,6 +3,7 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.test.MockApplicationPackage;
+import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.RankProfile;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.searchdefinition.Search;
@@ -22,20 +23,22 @@ import static org.junit.Assert.assertEquals;
class RankProfileSearchFixture {
private RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
+ private final QueryProfileRegistry queryProfileRegistry;
private Search search;
RankProfileSearchFixture(String rankProfiles) throws ParseException {
- this(MockApplicationPackage.createEmpty(), rankProfiles);
+ this(MockApplicationPackage.createEmpty(), new QueryProfileRegistry(), rankProfiles);
}
- RankProfileSearchFixture(ApplicationPackage applicationpackage, String rankProfiles) throws ParseException {
- this(applicationpackage, rankProfiles, null, null);
+ RankProfileSearchFixture(ApplicationPackage applicationpackage, QueryProfileRegistry queryProfileRegistry,
+ String rankProfiles) throws ParseException {
+ this(applicationpackage, queryProfileRegistry, rankProfiles, null, null);
}
- RankProfileSearchFixture(ApplicationPackage applicationpackage,
+ RankProfileSearchFixture(ApplicationPackage applicationpackage, QueryProfileRegistry queryProfileRegistry,
String rankProfiles, String constant, String field)
throws ParseException {
- SearchBuilder builder = new SearchBuilder(applicationpackage, rankProfileRegistry);
+ SearchBuilder builder = new SearchBuilder(applicationpackage, rankProfileRegistry, new QueryProfileRegistry());
String sdContent = "search test {\n" +
" " + (constant != null ? constant : "") + "\n" +
" document test {\n" +
@@ -47,6 +50,7 @@ class RankProfileSearchFixture {
builder.importString(sdContent);
builder.build();
search = builder.getSearch();
+ this.queryProfileRegistry = queryProfileRegistry;
}
public void assertFirstPhaseExpression(String expExpression, String rankProfile) {
@@ -68,7 +72,7 @@ class RankProfileSearchFixture {
}
public RankProfile rankProfile(String rankProfile) {
- return rankProfileRegistry.getRankProfile(search, rankProfile).compile();
+ return rankProfileRegistry.getRankProfile(search, rankProfile).compile(queryProfileRegistry);
}
public Search search() { return search; }
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java
index bdfad96ef87..df2bcca63dd 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java
@@ -2,6 +2,7 @@
package com.yahoo.searchdefinition.processing;
import com.yahoo.config.model.application.provider.BaseDeployLogger;
+import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.RankProfile.RankProperty;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.searchdefinition.Search;
@@ -16,10 +17,14 @@ import java.util.List;
import static org.junit.Assert.fail;
public class RankPropertyVariablesTestCase extends SearchDefinitionTestCase {
+
@Test
public void testRankPropVariables() throws IOException, ParseException {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- Search search = SearchBuilder.buildFromFile("src/test/examples/rankpropvars.sd", new BaseDeployLogger(), rankProfileRegistry);
+ Search search = SearchBuilder.buildFromFile("src/test/examples/rankpropvars.sd",
+ new BaseDeployLogger(),
+ rankProfileRegistry,
+ new QueryProfileRegistry());
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar1", "foo");
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar_2", "bar");
assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvarOne23", "baz");
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java
index e6db6abdc95..73c622cba7f 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java
@@ -8,6 +8,7 @@ import com.yahoo.io.GrowableByteBuffer;
import com.yahoo.io.IOUtils;
import com.yahoo.io.reader.NamedReader;
import com.yahoo.path.Path;
+import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.RankingConstant;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.tensor.Tensor;
@@ -148,6 +149,7 @@ public class RankingExpressionWithTensorFlowTestCase {
try {
RankProfileSearchFixture search = new RankProfileSearchFixture(
new StoringApplicationPackage(applicationDir),
+ new QueryProfileRegistry(),
" rank-profile my_profile {\n" +
" first-phase {\n" +
" expression: tensorflow('mnist_softmax/saved')" +
@@ -290,6 +292,7 @@ public class RankingExpressionWithTensorFlowTestCase {
try {
return new RankProfileSearchFixture(
application,
+ application.getQueryProfiles(),
" rank-profile my_profile {\n" +
" macro Placeholder() {\n" +
" expression: " + placeholderExpression +
@@ -319,7 +322,7 @@ public class RankingExpressionWithTensorFlowTestCase {
StoringApplicationPackage(Path applicationPackageWritableRoot, String queryProfile, String queryProfileType) {
super(null, null, Collections.emptyList(), null,
- null, null, false);
+ null, null, false, queryProfile, queryProfileType);
this.root = new File(applicationPackageWritableRoot.toString());
this.queryProfile = queryProfile;
this.queryProfileType = queryProfileType;
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java
index cdb77f5d0e1..18c3e43ae7e 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java
@@ -2,6 +2,7 @@
package com.yahoo.searchdefinition.processing;
import com.yahoo.collections.Pair;
+import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.*;
import com.yahoo.searchdefinition.derived.DerivedConfiguration;
import com.yahoo.searchdefinition.derived.AttributeFields;
@@ -16,13 +17,14 @@ import java.util.Map;
import static org.junit.Assert.assertEquals;
-// TODO: WHO?
public class RankingExpressionsTestCase extends SearchDefinitionTestCase {
@Test
public void testMacros() throws IOException, ParseException {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- Search search = SearchBuilder.createFromDirectory("src/test/examples/rankingexpressionfunction", rankProfileRegistry).getSearch();
+ Search search = SearchBuilder.createFromDirectory("src/test/examples/rankingexpressionfunction",
+ rankProfileRegistry,
+ new QueryProfileRegistry()).getSearch();
final RankProfile macrosRankProfile = rankProfileRegistry.getRankProfile(search, "macros");
macrosRankProfile.parseExpressions();
final Map<String, RankProfile.Macro> macros = macrosRankProfile.getMacros();
@@ -35,7 +37,9 @@ public class RankingExpressionsTestCase extends SearchDefinitionTestCase {
assertEquals("78 + closeness(distance)", macros.get("artistmatch").getTextualExpression().trim());
assertEquals(0, macros.get("artistmatch").getFormalParams().size());
- List<Pair<String, String>> rankProperties = new RawRankProfile(macrosRankProfile, new AttributeFields(search)).configProperties();
+ List<Pair<String, String>> rankProperties = new RawRankProfile(macrosRankProfile,
+ new QueryProfileRegistry(),
+ new AttributeFields(search)).configProperties();
assertEquals(6, rankProperties.size());
assertEquals("rankingExpression(titlematch$).rankingScript", rankProperties.get(0).getFirst());
@@ -57,8 +61,10 @@ public class RankingExpressionsTestCase extends SearchDefinitionTestCase {
@Test(expected = IllegalArgumentException.class)
public void testThatIncludingFileInSubdirFails() throws IOException, ParseException {
RankProfileRegistry registry = new RankProfileRegistry();
- Search search = SearchBuilder.createFromDirectory("src/test/examples/rankingexpressioninfile", registry).getSearch();
- new DerivedConfiguration(search, registry); // rank profile parsing happens during deriving
+ Search search = SearchBuilder.createFromDirectory("src/test/examples/rankingexpressioninfile",
+ registry,
+ new QueryProfileRegistry()).getSearch();
+ new DerivedConfiguration(search, registry, new QueryProfileRegistry()); // rank profile parsing happens during deriving
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java
index 28e1f310078..c18cfcfe1aa 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java
@@ -100,7 +100,6 @@ public class TensorTransformTestCase extends SearchDefinitionTestCase {
String rankProperty = rankPropertyExpression.getFirst();
if (rankProperty.equals("rankingExpression(firstphase).rankingScript")) {
String rankExpression = censorBindingHash(rankPropertyExpression.getSecond().replace(" ",""));
- System.out.println("expression is --> " + rankExpression);
return rankExpression.equals(transformedExpression);
}
}
@@ -170,10 +169,10 @@ public class TensorTransformTestCase extends SearchDefinitionTestCase {
"}\n");
builder.build(new BaseDeployLogger(), setupQueryProfileTypes());
Search s = builder.getSearch();
- RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile();
- List<Pair<String, String>> testRankProperties = new RawRankProfile(test, new AttributeFields(s)).configProperties();
- for (Object o : testRankProperties)
- System.out.println(o);
+ RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(new QueryProfileRegistry());
+ List<Pair<String, String>> testRankProperties = new RawRankProfile(test,
+ new QueryProfileRegistry(),
+ new AttributeFields(s)).configProperties();
return testRankProperties;
}