use of com.yahoo.search.query.Properties in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testQueryProfileReferencesWithSubstitution.
public void testQueryProfileReferencesWithSubstitution() {
QueryProfile main = new QueryProfile("main");
main.setDimensions(new String[] { "x1" });
QueryProfile referencedMain = new QueryProfile("referencedMain");
// In both
referencedMain.set("r1", "%{prefix}mainReferenced-r1", (QueryProfileRegistry) null);
// Only in this
referencedMain.set("r2", "%{prefix}mainReferenced-r2", (QueryProfileRegistry) null);
QueryProfile referencedVariant = new QueryProfile("referencedVariant");
// In both
referencedVariant.set("r1", "%{prefix}variantReferenced-r1", (QueryProfileRegistry) null);
// Only in this
referencedVariant.set("r3", "%{prefix}variantReferenced-r3", (QueryProfileRegistry) null);
main.set("a", referencedMain, (QueryProfileRegistry) null);
main.set("a", referencedVariant, new String[] { "x1" }, null);
main.set("prefix", "mainPrefix:", (QueryProfileRegistry) null);
main.set("prefix", "variantPrefix:", new String[] { "x1" }, null);
Properties properties = new QueryProfileProperties(main.compile(null));
// No context
Map<String, Object> listed = properties.listProperties();
assertEquals(3, listed.size());
assertEquals("mainPrefix:mainReferenced-r1", listed.get("a.r1"));
assertEquals("mainPrefix:mainReferenced-r2", listed.get("a.r2"));
// Context x=x1
listed = properties.listProperties(toMap(main, new String[] { "x1" }));
assertEquals(4, listed.size());
assertEquals("variantPrefix:variantReferenced-r1", listed.get("a.r1"));
assertEquals("variantPrefix:mainReferenced-r2", listed.get("a.r2"));
assertEquals("variantPrefix:variantReferenced-r3", listed.get("a.r3"));
}
use of com.yahoo.search.query.Properties in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testListVariantPropertiesCompounds1Simplified.
public void testListVariantPropertiesCompounds1Simplified() {
QueryProfile main = new QueryProfile("main");
main.setDimensions(new String[] { "x", "y" });
main.set("a.p1", "main-a-x1", new String[] { "x1" }, null);
QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
inheritedVariant1.set("a.p1", "inheritedVariant1-a", (QueryProfileRegistry) null);
main.addInherited(inheritedVariant1, new String[] { "x1" });
Properties properties = new QueryProfileProperties(main.compile(null));
// Context x=x1
Map<String, Object> listed = properties.listProperties(toMap(main, new String[] { "x1" }));
assertEquals("main-a-x1", listed.get("a.p1"));
}
use of com.yahoo.search.query.Properties in project vespa by vespa-engine.
the class XmlReadingTestCase method testSystemtest.
/**
* Tests a subset of the configuration in the system test of this
*/
@Test
public void testSystemtest() {
String queryString = "?query=test";
QueryProfileXMLReader reader = new QueryProfileXMLReader();
CompiledQueryProfileRegistry registry = reader.read("src/test/java/com/yahoo/search/query/profile/config/test/systemtest/").compile();
HttpRequest request = HttpRequest.createTestRequest(queryString, Method.GET);
CompiledQueryProfile profile = registry.findQueryProfile("default");
Query query = new Query(request, profile);
Properties p = query.properties();
assertEquals("test", query.getModel().getQueryString());
assertEquals("test", p.get("query"));
assertEquals("test", p.get("QueRY"));
assertEquals("test", p.get("model.queryString"));
assertEquals("bar", p.get("foo"));
assertEquals(5, p.get("hits"));
assertEquals("tit", p.get("subst"));
assertEquals("le", p.get("subst.end"));
assertEquals("title", p.get("model.defaultIndex"));
Map<String, Object> ps = p.listProperties();
assertEquals(6, ps.size());
assertEquals("bar", ps.get("foo"));
assertEquals("5", ps.get("hits"));
assertEquals("tit", ps.get("subst"));
assertEquals("le", ps.get("subst.end"));
assertEquals("title", ps.get("model.defaultIndex"));
assertEquals("test", ps.get("model.queryString"));
}
Aggregations