use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class OverrideTestCase method testSimpleUnoverridable.
/**
* Check that a simple non-overridable string cannot be overridden
*/
public void testSimpleUnoverridable() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
test.set("myString", "finalString", (QueryProfileRegistry) null);
registry.register(test);
registry.freeze();
// Assert request assignment does not work
Query query = new Query(HttpRequest.createTestRequest("?myString=newValue", Method.GET), registry.compile().getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals("finalString", query.properties().get("myString"));
// Assert direct assignment does not work
query.properties().set("myString", "newValue");
assertEquals("finalString", query.properties().get("myString"));
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class XmlReadingTestCase method testKlee.
@Test
public void testKlee() {
QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/klee");
QueryProfile pv = registry.getComponent("twitter_dd-us:0.2.4");
assertEquals("0.2.4", pv.getId().getVersion().toString());
assertEquals("[query profile 'production']", pv.inherited().toString());
QueryProfile p = registry.getComponent("twitter_dd-us:0.0.0");
// that is 0.0.0
assertEquals("", p.getId().getVersion().toString());
assertEquals("[query profile 'twitter_dd']", p.inherited().toString());
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class QueryFromProfileTestCase method testQueryFromProfile1.
public void testQueryFromProfile1() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile topLevel = new QueryProfile("topLevel");
topLevel.setType(registry.getTypeRegistry().getComponent("native"));
registry.register(topLevel);
QueryProfile queryBest = new QueryProfile("querybest");
queryBest.setType(registry.getTypeRegistry().getComponent("model"));
queryBest.set("queryString", "best", registry);
registry.register(queryBest);
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?model=querybest", Method.GET), cRegistry.getComponent("topLevel"));
assertEquals("best", query.properties().get("model.queryString"));
assertEquals("best", query.getModel().getQueryTree().toString());
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class MandatoryTestCase method testMandatoryUserProfileSetInRequest.
/**
* Here, no user query profile is referenced in the query profile, but one is chosen in the request
*/
@Test
public void testMandatoryUserProfileSetInRequest() {
Fixture1 fixture = new Fixture1();
QueryProfile test = new QueryProfile("test");
test.setType(fixture.type);
QueryProfile myUser = new QueryProfile("user");
myUser.setType(fixture.user);
myUser.set("myUserInteger", 1, null);
QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(test);
registry.register(myUser);
CompiledQueryProfileRegistry cRegistry = registry.compile();
// Underspecified request 1
assertError("Incomplete query: Parameter 'myUserQueryProfile' is mandatory in query profile 'test' of type 'testtype' but is not set", new Query(HttpRequest.createTestRequest("?myString=aString", Method.GET), cRegistry.getComponent("test")));
// Underspecified request 1
assertError("Incomplete query: Parameter 'myUserQueryProfile.myUserString' is mandatory in query profile 'test' of type 'testtype' but is not set", new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile=user", Method.GET), cRegistry.getComponent("test")));
// Fully specified request
assertError(null, new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile=user&myUserQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("test")));
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class MultiProfileTestCase method testValid.
public void testValid() {
QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/multiprofile");
QueryProfile multiprofile1 = registry.getComponent("multiprofile1");
assertNotNull(multiprofile1);
assertGet("general-a", "a", new String[] { null, null, null }, multiprofile1);
assertGet("us-nokia-test1-a", "a", new String[] { "us", "nok ia", "test1" }, multiprofile1);
assertGet("us-nokia-b", "b", new String[] { "us", "nok ia", "test1" }, multiprofile1);
assertGet("us-a", "a", new String[] { "us", null, null }, multiprofile1);
assertGet("us-b", "b", new String[] { "us", null, null }, multiprofile1);
assertGet("us-nokia-a", "a", new String[] { "us", "nok ia", null }, multiprofile1);
assertGet("us-test1-a", "a", new String[] { "us", null, "test1" }, multiprofile1);
assertGet("us-test1-b", "b", new String[] { "us", null, "test1" }, multiprofile1);
assertGet("us-a", "a", new String[] { "us", "unspecified", "unspecified" }, multiprofile1);
assertGet("us-nokia-a", "a", new String[] { "us", "nok ia", "unspecified" }, multiprofile1);
assertGet("us-test1-a", "a", new String[] { "us", "unspecified", "test1" }, multiprofile1);
assertGet("us-nokia-b", "b", new String[] { "us", "nok ia", "test1" }, multiprofile1);
// ...inherited
assertGet("parent1-value", "parent1", new String[] { "us", "nok ia", "-" }, multiprofile1);
assertGet("parent2-value", "parent2", new String[] { "us", "nok ia", "-" }, multiprofile1);
assertGet(null, "parent1", new String[] { "us", "-", "-" }, multiprofile1);
assertGet(null, "parent2", new String[] { "us", "-", "-" }, multiprofile1);
}
Aggregations