diff options
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java | 52 |
1 files changed, 52 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 03faeaae8a0..89217bb7f0c 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 @@ -23,6 +23,7 @@ import java.util.Map; import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; /** @@ -74,6 +75,57 @@ public class QueryProfileVariantsTestCase { } @Test + public void testReferenceInVariant() { + QueryProfileRegistry registry = new QueryProfileRegistry(); + QueryProfile test = new QueryProfile("test"); + test.setDimensions(new String[] { "d1" }); + registry.register(test); + + QueryProfile references = new QueryProfile("referenced"); + references.setDimensions(new String[] { "d1" }); + registry.register(references); + + QueryProfile other = new QueryProfile("other"); + other.setDimensions(new String[] { "d1" }); + registry.register(other); + + test.set( "a", references, new String[] { "d1v"}, registry); + test.set( "a.b", "test-value", new String[] { "d1v"}, registry); + other.set( "a", references, new String[] { "d1v"}, registry); + other.set("a.b", "other-value", new String[] { "d1v"}, registry); + + assertEquals("test-value", test.get("a.b", new String[] { "d1v"})); + assertEquals("other-value", other.get("a.b", new String[] { "d1v"})); + assertNull(references.get("b", new String[] { "d1v"})); + + var cRegistry = registry.compile(); + assertEquals("test-value", + cRegistry.getComponent("test").get("a.b", Map.of("d1", "d1v"))); + } + + @Test + public void testReference() { + QueryProfileRegistry registry = new QueryProfileRegistry(); + QueryProfile test = new QueryProfile("test"); + registry.register(test); + + QueryProfile references = new QueryProfile("referenced"); + registry.register(references); + + QueryProfile other = new QueryProfile("other"); + registry.register(other); + + test.set( "a", references, registry); + test.set( "a.b", "test-value", registry); + other.set( "a", references, registry); + other.set("a.b", "other-value", registry); + + assertEquals("test-value", test.get("a.b")); + assertEquals("other-value", other.get("a.b")); + assertNull(references.get("b")); + } + + @Test public void testVariantInReferencedAndParentWithOtherMatchingVariant() { QueryProfileRegistry registry = new QueryProfileRegistry(); QueryProfile parent = new QueryProfile("parent"); |