1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.search.test;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileXMLReader;
import com.yahoo.vespa.model.container.search.QueryProfiles;
import java.io.IOException;
import static helpers.CompareConfigTestHelper.assertSerializedConfigFileEquals;
/**
* @author bratseth
*/
public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
private final String root = "src/test/java/com/yahoo/vespa/model/container/search/test/";
public void testConfigCreation() throws IOException {
QueryProfileRegistry registry = new QueryProfileXMLReader().read(root + "queryprofilevariants");
QueryProfiles profiles = new QueryProfiles(registry);
assertSerializedConfigFileEquals(root + "query-profile-variants-configuration.cfg", profiles.getConfig().toString());
}
public void testConfigCreation2() throws IOException {
QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/vespa/model/container/search/test/queryprofilevariants2");
QueryProfiles profiles = new QueryProfiles(registry);
assertSerializedConfigFileEquals(root + "query-profile-variants2-configuration.cfg", profiles.getConfig().toString());
}
public void testConfigCreationNewsBESimple() throws IOException {
QueryProfileRegistry registry = new QueryProfileXMLReader().read(root + "newsbesimple");
QueryProfiles profiles = new QueryProfiles(registry);
assertSerializedConfigFileEquals(root + "newsbe-query-profiles-simple.cfg", profiles.getConfig().toString());
}
public void testConfigCreationNewsFESimple() throws IOException {
QueryProfileRegistry registry = new QueryProfileXMLReader().read(root + "newsfesimple");
QueryProfiles profiles = new QueryProfiles(registry);
assertSerializedConfigFileEquals(root + "newsfe-query-profiles-simple.cfg", profiles.getConfig().toString());
}
public void testVariantsOfExplicitCompound() throws IOException {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a1.b", registry);
QueryProfile profile = new QueryProfile("test");
profile.setDimensions(new String[] {"x"});
profile.set("a", a1, registry);
profile.set("a.b", "a.b.x1", new String[] {"x1"}, registry);
profile.set("a.b", "a.b.x2", new String[] {"x2"}, registry);
registry.register(a1);
registry.register(profile);
QueryProfiles profiles = new QueryProfiles(registry);
assertSerializedConfigFileEquals(root + "variants-of-explicit-compound.cfg", profiles.getConfig().toString());
}
public void testVariantsOfExplicitCompoundWithVariantReference() throws IOException {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a1.b", registry);
QueryProfile a2 = new QueryProfile("a2");
a2.set("b", "a2.b", registry);
QueryProfile profile = new QueryProfile("test");
profile.setDimensions(new String[] {"x"});
profile.set("a", a1, registry);
profile.set("a", a2, new String[] {"x1"}, registry);
profile.set("a.b", "a.b.x1", new String[] {"x1"}, registry);
profile.set("a.b", "a.b.x2", new String[] {"x2"}, registry);
registry.register(a1);
registry.register(a2);
registry.register(profile);
QueryProfiles profiles = new QueryProfiles(registry);
assertSerializedConfigFileEquals(root + "variants-of-explicit-compound-with-reference.cfg", profiles.getConfig().toString());
}
/** For comparison with the above */
public void testExplicitReferenceOverride() throws IOException {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a1.b", registry);
QueryProfile profile = new QueryProfile("test");
profile.set("a", a1, registry);
profile.set("a.b", "a.b", registry);
assertEquals("a.b", profile.get("a.b"));
registry.register(a1);
registry.register(profile);
QueryProfiles profiles = new QueryProfiles(registry);
assertSerializedConfigFileEquals(root + "explicit-reference-override.cfg", profiles.getConfig().toString());
}
}
|