diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-09-30 12:58:59 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-09-30 12:58:59 +0200 |
commit | 44f2ecfdaacd12062087fd91161a25cc302e6c6f (patch) | |
tree | 71bbe41d5cb5035ed2cd950b4886b1c90ee60c69 /container-search/src/test | |
parent | aa7061626f330bfb573f4afdbab8bc9ddd5ec927 (diff) |
Substitute properties in trace output
Diffstat (limited to 'container-search/src/test')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java index 46dbac859a2..18329a817a5 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java @@ -9,6 +9,7 @@ import com.yahoo.search.query.profile.BackedOverridableQueryProfile; import com.yahoo.search.query.profile.QueryProfile; import com.yahoo.search.query.profile.QueryProfileProperties; import com.yahoo.search.query.profile.compiled.CompiledQueryProfile; +import com.yahoo.yolean.trace.TraceNode; import org.junit.Test; import java.util.Arrays; @@ -18,6 +19,7 @@ import java.util.Map; import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author bratseth @@ -68,6 +70,21 @@ public class QueryProfileVariantsTestCase { } @Test + public void testVariantSubstitution() { + QueryProfile profile = new QueryProfile("test"); + profile.setDimensions(new String[] { "langReg", "region", "site" }); + profile.set("property", "%{site}", null); + profile.set("property", "fp", new String[] { null, null, "frontpage"}, null); + profile.set("streams", "ntk_stream_fresh", new String[] { "en-GB", "GB" }, null); + CompiledQueryProfile cProfile = profile.compile(null); + + Query query = new Query("?langReg=en-GB®ion=GB&site=frontpage&tracelevel=4", cProfile); + assertEquals("frontpage", query.properties().get("property")); + assertEquals("ntk_stream_fresh", query.properties().get("streams")); + assertTrue(traceContains("property=frontpage", query)); + } + + @Test public void testInheritedVariants() { QueryProfile parent = new QueryProfile("parent"); parent.setDimensions(new String[] { "parentDim" }); @@ -1147,4 +1164,12 @@ public class QueryProfileVariantsTestCase { return context; } + // NB: NOT RECURSIVE + private boolean traceContains(String string, Query query) { + for (TraceNode node : query.getContext(true).getTrace().traceNode().children()) + if (node.payload().toString().contains(string)) + return true; + return false; + } + } |