use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileSubstitutionTestCase method testVariants.
public void testVariants() {
QueryProfile p = new QueryProfile("test");
p.set("message", "Hello %{world}!", (QueryProfileRegistry) null);
p.set("world", "world", (QueryProfileRegistry) null);
p.setDimensions(new String[] { "x" });
p.set("message", "Halo %{world}!", new String[] { "x1" }, null);
p.set("world", "Europe", new String[] { "x2" }, null);
CompiledQueryProfile cp = p.compile(null);
assertEquals("Hello world!", cp.get("message", QueryProfileVariantsTestCase.toMap("x=x?")));
assertEquals("Halo world!", cp.get("message", QueryProfileVariantsTestCase.toMap("x=x1")));
assertEquals("Hello Europe!", cp.get("message", QueryProfileVariantsTestCase.toMap("x=x2")));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileTypeTestCase method testTypedOfPrimitivesAssignmentStrict.
public void testTypedOfPrimitivesAssignmentStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(typeStrict);
profile.set("myString", "anyValue", registry);
// Illegal because this is strict
assertNotPermitted(profile, "nontypedString", "anyValueToo");
assertWrongType(profile, "integer", "myInteger", "notInteger");
assertWrongType(profile, "integer", "myInteger", "1.5");
profile.set("myInteger", 3, registry);
assertWrongType(profile, "long", "myLong", "notLong");
assertWrongType(profile, "long", "myLong", "1.5");
profile.set("myLong", 4000000000000l, registry);
assertWrongType(profile, "float", "myFloat", "notFloat");
profile.set("myFloat", 3.14f, registry);
assertWrongType(profile, "double", "myDouble", "notDouble");
profile.set("myDouble", 2.18, registry);
profile.set("myQueryProfile.anyString", "value1", registry);
profile.set("myQueryProfile.anyDouble", 8.76, registry);
profile.set("myUserQueryProfile.myUserString", "value2", registry);
// Illegal because this is strict
assertNotPermitted(profile, "myUserQueryProfile.anyString", "value3");
assertWrongType(profile, "integer", "myUserQueryProfile.myUserInteger", "notInteger");
profile.set("myUserQueryProfile.myUserInteger", 1337, registry);
// Illegal because this is strict
assertNotPermitted(profile, "myUserQueryProfile.anyDouble", 9.13);
CompiledQueryProfile cprofile = profile.compile(null);
assertEquals("anyValue", cprofile.get("myString"));
assertNull(cprofile.get("nontypedString"));
assertEquals(3, cprofile.get("myInteger"));
assertEquals(4000000000000l, cprofile.get("myLong"));
assertEquals(3.14f, cprofile.get("myFloat"));
assertEquals(2.18, cprofile.get("myDouble"));
assertEquals("value1", cprofile.get("myQueryProfile.anyString"));
assertEquals(8.76, cprofile.get("myQueryProfile.anyDouble"));
assertEquals("value2", cprofile.get("myUserQueryProfile.myUserString"));
assertNull(cprofile.get("myUserQueryProfile.anyString"));
assertEquals(1337, cprofile.get("myUserQueryProfile.myUserInteger"));
assertNull(cprofile.get("myUserQueryProfile.anyDouble"));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileTypeTestCase method testTypedAssignmentOfQueryProfilesStrict.
/**
* Tests assigning a subprofile directly
*/
public void testTypedAssignmentOfQueryProfilesStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(typeStrict);
QueryProfile map1 = new QueryProfile("myMap1");
map1.set("key1", "value1", registry);
QueryProfile map2 = new QueryProfile("myMap2");
map2.set("key2", "value2", registry);
QueryProfile myUser = new QueryProfile("myUser");
myUser.setType(userStrict);
myUser.set("myUserString", "userValue1", registry);
myUser.set("myUserInteger", 442, registry);
assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
profile.set("myQueryProfile", map1, registry);
assertNotPermitted(profile, "someMap", map2);
assertWrongType(profile, "reference to a query profile of type 'userStrict'", "myUserQueryProfile", map1);
profile.set("myUserQueryProfile", myUser, registry);
CompiledQueryProfile cprofile = profile.compile(null);
assertEquals("value1", cprofile.get("myQueryProfile.key1"));
assertNull(cprofile.get("someMap.key2"));
assertEquals("userValue1", cprofile.get("myUserQueryProfile.myUserString"));
assertEquals(442, cprofile.get("myUserQueryProfile.myUserInteger"));
}
Aggregations