use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class MandatoryTestCase method testMandatoryNestedInMaps.
/**
* Same as above except the whole thing is nested in maps
*/
@Test
public void testMandatoryNestedInMaps() {
Fixture1 fixture = new Fixture1();
QueryProfile topMap = new QueryProfile("topMap");
fixture.registry.register(topMap);
QueryProfile subMap = new QueryProfile("topSubMap");
topMap.set("subMap", subMap, fixture.registry);
fixture.registry.register(subMap);
QueryProfile test = new QueryProfile("test");
test.setType(fixture.type);
subMap.set("test", test, fixture.registry);
fixture.registry.register(test);
QueryProfile myUser = new QueryProfile("user");
myUser.setType(fixture.user);
myUser.set("myUserInteger", 1, fixture.registry);
test.set("myUserQueryProfile", myUser, fixture.registry);
fixture.registry.register(myUser);
CompiledQueryProfileRegistry cRegistry = fixture.registry.compile();
// Underspecified request 1
assertError("Incomplete query: Parameter 'subMap.test.myString' is mandatory in query profile 'topMap' but is not set", new Query(HttpRequest.createTestRequest("", Method.GET), cRegistry.getComponent("topMap")));
// Underspecified request 2
assertError("Incomplete query: Parameter 'subMap.test.myUserQueryProfile.myUserString' is mandatory in query profile 'topMap' but is not set", new Query(HttpRequest.createTestRequest("?subMap.test.myString=aString", Method.GET), cRegistry.getComponent("topMap")));
// Fully specified request
assertError(null, new Query(HttpRequest.createTestRequest("?subMap.test.myString=aString&subMap.test.myUserQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("topMap")));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileSubstitutionTestCase method testUnclosedSubstitution1.
public void testUnclosedSubstitution1() {
try {
QueryProfile p = new QueryProfile("test");
p.set("message1", "%{greeting} %{entity}%{exclamation", (QueryProfileRegistry) null);
fail("Should have produced an exception");
} catch (IllegalArgumentException e) {
assertEquals("Could not set 'message1' to '%{greeting} %{entity}%{exclamation': Unterminated value substitution '%{exclamation'", Exceptions.toMessageString(e));
}
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileSubstitutionTestCase method testUnclosedSubstitution2.
public void testUnclosedSubstitution2() {
try {
QueryProfile p = new QueryProfile("test");
p.set("message1", "%{greeting} %{entity%{exclamation}", (QueryProfileRegistry) null);
fail("Should have produced an exception");
} catch (IllegalArgumentException e) {
assertEquals("Could not set 'message1' to '%{greeting} %{entity%{exclamation}': Unterminated value substitution '%{entity%{exclamation}'", Exceptions.toMessageString(e));
}
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsCloneTestCase method test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning.
/**
* Test for Ticket 4882480.
*/
@Test
public void test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning() {
Map<String, String> dimensionBinding = createDimensionBinding("location", "norway");
QueryProfile profile = new QueryProfile("profile");
profile.setDimensions(keys(dimensionBinding));
DimensionValues dimensionValues = DimensionValues.createFrom(values(dimensionBinding));
profile.set("interior.leaf", "leafValue", dimensionValues, null);
profile.set("interior", "interiorValue", dimensionValues, null);
CompiledQueryProfile clone = profile.compile(null).clone();
assertEquals(profile.get("interior", dimensionBinding, null), clone.get("interior", dimensionBinding));
assertEquals(profile.get("interior.leaf", dimensionBinding, null), clone.get("interior.leaf", dimensionBinding));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class NativePropertiesTestCase method testNativeInStrict.
public void testNativeInStrict() {
QueryProfileType strictType = new QueryProfileType("strict");
strictType.setStrict(true);
QueryProfile strict = new QueryProfile("profile");
strict.setType(strictType);
try {
new Query(HttpRequest.createTestRequest("?hits=10&tracelevel=5", Method.GET), strict.compile(null));
fail("Above statement should throw");
} catch (QueryException e) {
// As expected.
}
try {
new Query(HttpRequest.createTestRequest("?notnative=5", Method.GET), strict.compile(null));
fail("Above statement should throw");
} catch (QueryException e) {
// As expected.
assertThat(Exceptions.toMessageString(e), containsString("Could not set 'notnative' to '5':" + " 'notnative' is not declared in query profile type 'strict', and the type is strict"));
}
}
Aggregations