use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class OverrideTestCase method testUntypedNestedUnoverridable.
/**
* Check that non-overridables are protected also in nested untyped references
*/
public void testUntypedNestedUnoverridable() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile topMap = new QueryProfile("topMap");
registry.register(topMap);
QueryProfile subMap = new QueryProfile("topSubMap");
topMap.set("subMap", subMap, registry);
registry.register(subMap);
QueryProfile test = new QueryProfile("test");
test.setType(type);
subMap.set("test", test, registry);
registry.register(test);
QueryProfile myUser = new QueryProfile("user");
myUser.setType(user);
myUser.set("myUserString", "finalValue", registry);
test.set("myUserQueryProfile", myUser, registry);
registry.register(myUser);
registry.freeze();
Query query = new Query(HttpRequest.createTestRequest("?subMap.test.myUserQueryProfile.myUserString=newValue", Method.GET), registry.compile().getComponent("topMap"));
assertEquals(0, query.errors().size());
assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
query.properties().set("subMap.test.myUserQueryProfile.myUserString", "newValue");
assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class OverrideTestCase method testInheritedNonOverridableInType.
/**
* Tests overridability in an inherited field
*/
public void testInheritedNonOverridableInType() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
test.set("myString", "finalString", (QueryProfileRegistry) null);
registry.register(test);
QueryProfile profile = new QueryProfile("profile");
profile.addInherited(test);
registry.register(profile);
registry.freeze();
Query query = new Query(HttpRequest.createTestRequest("?myString=newString", Method.GET), registry.compile().getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals("finalString", query.properties().get("myString"));
query.properties().set("myString", "newString");
assertEquals("finalString", query.properties().get("myString"));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class OverrideTestCase method testUnoverridableQueryProfile.
/**
* Check that a query profile cannot be overridden
*/
public void testUnoverridableQueryProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
registry.register(test);
QueryProfile myUser = new QueryProfile("user");
myUser.setType(user);
myUser.set("myUserInteger", 1, registry);
myUser.set("myUserString", "userValue", registry);
test.set("myUserQueryProfile", myUser, registry);
registry.register(myUser);
QueryProfile otherUser = new QueryProfile("otherUser");
otherUser.setType(user);
otherUser.set("myUserInteger", 2, registry);
registry.register(otherUser);
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?myUserQueryprofile=otherUser", Method.GET), cRegistry.getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(1, query.properties().get("myUserQueryProfile.myUserInteger"));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class OverrideTestCase method testInheritedNonOverridableInProfile.
/**
* Tests overridability in an inherited field
*/
public void testInheritedNonOverridableInProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
test.set("myInteger", 1, registry);
test.setOverridable("myInteger", false, null);
registry.register(test);
QueryProfile profile = new QueryProfile("profile");
profile.addInherited(test);
registry.register(profile);
registry.freeze();
Query query = new Query(HttpRequest.createTestRequest("?myInteger=32", Method.GET), registry.compile().getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(1, query.properties().get("myInteger"));
query.properties().set("myInteger", 32);
assertEquals(1, query.properties().get("myInteger"));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileTypeInheritanceTestCase method testInheritanceStrict.
public void testInheritanceStrict() {
typeStrict.inherited().add(userStrict);
typeStrict.freeze();
userStrict.freeze();
QueryProfile test = new QueryProfile("test");
test.setType(typeStrict);
test.set("myUserInteger", "37", (QueryProfileRegistry) null);
try {
test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
fail("Should have failed");
} catch (IllegalArgumentException e) {
assertEquals("'myUnknownInteger' is not declared in query profile type 'testtypeStrict', and the type is strict", e.getCause().getMessage());
}
assertEquals(37, test.get("myUserInteger"));
assertNull(test.get("myUnknownInteger"));
}
Aggregations