summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-04-17 08:58:59 +0200
committerGitHub <noreply@github.com>2018-04-17 08:58:59 +0200
commit14177967ff7ef44926c206ef21a666f822597511 (patch)
tree5d4c2824934d1929ab5cfd4cc118dfd34ab8d5f4
parenta2d5b8283794c8872376c754ef0a1a9fc0a978de (diff)
parenta507737fac2a684c2801959b2339bf267fee1524 (diff)
Merge pull request #5589 from vespa-engine/bratseth/more-remove-old-junit
Remove use of old junit
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java213
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java272
3 files changed, 281 insertions, 210 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java b/container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java
index f66acb2bdc0..f900b4c9d8a 100644
--- a/container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/test/NullSetMemberTestCase.java
@@ -5,10 +5,14 @@ import org.junit.Test;
import java.util.HashSet;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
/**
* Tests null members in HashSet
*/
-public class NullSetMemberTestCase extends junit.framework.TestCase {
+public class NullSetMemberTestCase {
@Test
public void testNullMember() {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java
index 4604678198d..f3133855729 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java
@@ -9,24 +9,32 @@ import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileProperties;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
+import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* Tests untyped query profiles
*
* @author bratseth
*/
-public class QueryProfileTestCase extends junit.framework.TestCase {
+public class QueryProfileTestCase {
+ @Test
public void testBasics() {
- QueryProfile profile=new QueryProfile("test");
- profile.set("a","a-value", (QueryProfileRegistry)null);
- profile.set("b.c","b.c-value", (QueryProfileRegistry)null);
- profile.set("d.e.f","d.e.f-value", (QueryProfileRegistry)null);
+ QueryProfile profile = new QueryProfile("test");
+ profile.set("a","a-value", null);
+ profile.set("b.c","b.c-value", null);
+ profile.set("d.e.f","d.e.f-value", null);
CompiledQueryProfile cprofile = profile.compile(null);
@@ -42,10 +50,11 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
}
/** Tests cloning, with wrappers used in production in place */
+ @Test
public void testCloning() {
QueryProfile classProfile=new QueryProfile("test");
- classProfile.set("a","aValue", (QueryProfileRegistry)null);
- classProfile.set("b",3, (QueryProfileRegistry)null);
+ classProfile.set("a","aValue", null);
+ classProfile.set("b",3, null);
Properties properties = new QueryProfileProperties(classProfile.compile(null));
@@ -57,11 +66,12 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("aValue",propertiesClone.get("a"));
}
+ @Test
public void testFreezing() {
QueryProfile profile=new QueryProfile("test");
- profile.set("a","a-value", (QueryProfileRegistry)null);
- profile.set("b.c","b.c-value", (QueryProfileRegistry)null);
- profile.set("d.e.f","d.e.f-value", (QueryProfileRegistry)null);
+ profile.set("a","a-value", null);
+ profile.set("b.c","b.c-value", null);
+ profile.set("d.e.f","d.e.f-value", null);
assertFalse(profile.isFrozen());
assertEquals("a-value",profile.get("a"));
@@ -73,7 +83,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertTrue(((QueryProfile)profile.lookup("d.e",null)).isFrozen());
try {
- profile.set("a","value", (QueryProfileRegistry)null);
+ profile.set("a","value", null);
fail("Expected exception");
}
catch (IllegalStateException e) {
@@ -89,6 +99,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
}
+ @Test
public void testGetSubObjects() {
QueryProfile barn=new QueryProfile("barn");
QueryProfile mor=new QueryProfile("mor");
@@ -101,11 +112,11 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
far.addInherited(farfar);
barn.addInherited(mor);
barn.addInherited(far);
- mormor.set("a.mormor","a.mormor", (QueryProfileRegistry)null);
- barn.set("a.barn","a.barn", (QueryProfileRegistry)null);
- mor.set("b.mor", "b.mor", (QueryProfileRegistry)null);
- far.set("b.far", "b.far", (QueryProfileRegistry)null);
- far.set("a.far","a.far", (QueryProfileRegistry)null);
+ mormor.set("a.mormor","a.mormor", null);
+ barn.set("a.barn","a.barn", null);
+ mor.set("b.mor", "b.mor", null);
+ far.set("b.far", "b.far", null);
+ far.set("a.far","a.far", null);
CompiledQueryProfile cbarn = barn.compile(null);
assertSameObjects(cbarn, "a", Arrays.asList("mormor","far","barn"));
@@ -114,6 +125,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("b.far", cbarn.get("b.far"));
}
+ @Test
public void testInheritance() {
QueryProfile barn=new QueryProfile("barn");
QueryProfile mor=new QueryProfile("mor");
@@ -127,24 +139,24 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- morfar.set("a","morfar-a", (QueryProfileRegistry)null);
- mormor.set("a","mormor-a", (QueryProfileRegistry)null);
- farfar.set("a","farfar-a", (QueryProfileRegistry)null);
- mor.set("a","mor-a", (QueryProfileRegistry)null);
- far.set("a","far-a", (QueryProfileRegistry)null);
- barn.set("a","barn-a", (QueryProfileRegistry)null);
+ morfar.set("a","morfar-a", null);
+ mormor.set("a","mormor-a", null);
+ farfar.set("a","farfar-a", null);
+ mor.set("a","mor-a", null);
+ far.set("a","far-a", null);
+ barn.set("a","barn-a", null);
- mormor.set("b","mormor-b", (QueryProfileRegistry)null);
- far.set("b","far-b", (QueryProfileRegistry)null);
+ mormor.set("b","mormor-b", null);
+ far.set("b","far-b", null);
- mor.set("c","mor-c", (QueryProfileRegistry)null);
- far.set("c","far-c", (QueryProfileRegistry)null);
+ mor.set("c","mor-c", null);
+ far.set("c","far-c", null);
- mor.set("d.a","mor-d.a", (QueryProfileRegistry)null);
- barn.set("d.b","barn-d.b", (QueryProfileRegistry)null);
+ mor.set("d.a","mor-d.a", null);
+ barn.set("d.b","barn-d.b", null);
QueryProfile annetBarn=new QueryProfile("annetBarn");
- annetBarn.set("venn",barn, (QueryProfileRegistry)null);
+ annetBarn.set("venn",barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -161,6 +173,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("mor-d.a", cbarn.get("d.a"));
}
+ @Test
public void testInheritance2Level() {
QueryProfile barn=new QueryProfile("barn");
QueryProfile mor=new QueryProfile("mor");
@@ -174,24 +187,24 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- morfar.set("a.x","morfar-a", (QueryProfileRegistry)null);
- mormor.set("a.x","mormor-a", (QueryProfileRegistry)null);
- farfar.set("a.x","farfar-a", (QueryProfileRegistry)null);
- mor.set("a.x","mor-a", (QueryProfileRegistry)null);
- far.set("a.x","far-a", (QueryProfileRegistry)null);
- barn.set("a.x","barn-a", (QueryProfileRegistry)null);
+ morfar.set("a.x","morfar-a", null);
+ mormor.set("a.x","mormor-a", null);
+ farfar.set("a.x","farfar-a", null);
+ mor.set("a.x","mor-a", null);
+ far.set("a.x","far-a", null);
+ barn.set("a.x","barn-a", null);
- mormor.set("b.x","mormor-b", (QueryProfileRegistry)null);
- far.set("b.x","far-b", (QueryProfileRegistry)null);
+ mormor.set("b.x","mormor-b", null);
+ far.set("b.x","far-b", null);
- mor.set("c.x","mor-c", (QueryProfileRegistry)null);
- far.set("c.x","far-c", (QueryProfileRegistry)null);
+ mor.set("c.x","mor-c", null);
+ far.set("c.x","far-c", null);
- mor.set("d.a.x","mor-d.a", (QueryProfileRegistry)null);
- barn.set("d.b.x","barn-d.b", (QueryProfileRegistry)null);
+ mor.set("d.a.x","mor-d.a", null);
+ barn.set("d.b.x","barn-d.b", null);
QueryProfile annetBarn=new QueryProfile("annetBarn");
- annetBarn.set("venn",barn, (QueryProfileRegistry)null);
+ annetBarn.set("venn",barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -208,6 +221,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("mor-d.a", cbarn.get("d.a.x"));
}
+ @Test
public void testInheritance3Level() {
QueryProfile barn=new QueryProfile("barn");
QueryProfile mor=new QueryProfile("mor");
@@ -221,24 +235,24 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- morfar.set("y.a.x","morfar-a", (QueryProfileRegistry)null);
- mormor.set("y.a.x","mormor-a", (QueryProfileRegistry)null);
- farfar.set("y.a.x","farfar-a", (QueryProfileRegistry)null);
- mor.set("y.a.x","mor-a", (QueryProfileRegistry)null);
- far.set("y.a.x","far-a", (QueryProfileRegistry)null);
- barn.set("y.a.x","barn-a", (QueryProfileRegistry)null);
+ morfar.set("y.a.x","morfar-a", null);
+ mormor.set("y.a.x","mormor-a", null);
+ farfar.set("y.a.x","farfar-a", null);
+ mor.set("y.a.x","mor-a", null);
+ far.set("y.a.x","far-a", null);
+ barn.set("y.a.x","barn-a", null);
- mormor.set("y.b.x","mormor-b", (QueryProfileRegistry)null);
- far.set("y.b.x","far-b", (QueryProfileRegistry)null);
+ mormor.set("y.b.x","mormor-b", null);
+ far.set("y.b.x","far-b", null);
- mor.set("y.c.x","mor-c", (QueryProfileRegistry)null);
- far.set("y.c.x","far-c", (QueryProfileRegistry)null);
+ mor.set("y.c.x","mor-c", null);
+ far.set("y.c.x","far-c", null);
- mor.set("y.d.a.x","mor-d.a", (QueryProfileRegistry)null);
- barn.set("y.d.b.x","barn-d.b", (QueryProfileRegistry)null);
+ mor.set("y.d.a.x","mor-d.a", null);
+ barn.set("y.d.b.x","barn-d.b", null);
QueryProfile annetBarn=new QueryProfile("annetBarn");
- annetBarn.set("venn",barn, (QueryProfileRegistry)null);
+ annetBarn.set("venn",barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -255,6 +269,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("mor-d.a", cbarn.get("y.d.a.x"));
}
+ @Test
public void testListProperties() {
QueryProfile barn=new QueryProfile("barn");
QueryProfile mor=new QueryProfile("mor");
@@ -268,18 +283,18 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- morfar.set("a","morfar-a", (QueryProfileRegistry)null);
- morfar.set("model.b","morfar-model.b", (QueryProfileRegistry)null);
- mormor.set("a","mormor-a", (QueryProfileRegistry)null);
- mormor.set("model.b","mormor-model.b", (QueryProfileRegistry)null);
- farfar.set("a","farfar-a", (QueryProfileRegistry)null);
- mor.set("a","mor-a", (QueryProfileRegistry)null);
- far.set("a","far-a", (QueryProfileRegistry)null);
- barn.set("a","barn-a", (QueryProfileRegistry)null);
- mormor.set("b","mormor-b", (QueryProfileRegistry)null);
- far.set("b","far-b", (QueryProfileRegistry)null);
- mor.set("c","mor-c", (QueryProfileRegistry)null);
- far.set("c","far-c", (QueryProfileRegistry)null);
+ morfar.set("a","morfar-a", null);
+ morfar.set("model.b","morfar-model.b", null);
+ mormor.set("a","mormor-a", null);
+ mormor.set("model.b","mormor-model.b", null);
+ farfar.set("a","farfar-a", null);
+ mor.set("a","mor-a", null);
+ far.set("a","far-a", null);
+ barn.set("a","barn-a", null);
+ mormor.set("b","mormor-b", null);
+ far.set("b","far-b", null);
+ mor.set("c","mor-c", null);
+ far.set("c","far-c", null);
CompiledQueryProfile cbarn = barn.compile(null);
@@ -308,9 +323,10 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
}
/** Tests that dots are followed when setting overridability */
+ @Test
public void testInstanceOverridable() {
QueryProfile profile=new QueryProfile("root/unoverridableIndex");
- profile.set("model.defaultIndex","default", (QueryProfileRegistry)null);
+ profile.set("model.defaultIndex","default", null);
profile.setOverridable("model.defaultIndex",false,null);
assertFalse(profile.isDeclaredOverridable("model.defaultIndex",null).booleanValue());
@@ -326,10 +342,11 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
}
/** Tests that dots are followed when setting overridability...also with variants */
+ @Test
public void testInstanceOverridableWithVariants() {
QueryProfile profile=new QueryProfile("root/unoverridableIndex");
profile.setDimensions(new String[] {"x"});
- profile.set("model.defaultIndex","default", (QueryProfileRegistry)null);
+ profile.set("model.defaultIndex","default", null);
profile.setOverridable("model.defaultIndex",false,null);
assertFalse(profile.isDeclaredOverridable("model.defaultIndex",null));
@@ -344,10 +361,11 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("de",query.getModel().getLanguage().languageCode());
}
+ @Test
public void testSimpleInstanceOverridableWithVariants1() {
QueryProfile profile=new QueryProfile("test");
profile.setDimensions(new String[] {"x"});
- profile.set("a","original", (QueryProfileRegistry)null);
+ profile.set("a","original", null);
profile.setOverridable("a",false,null);
assertFalse(profile.isDeclaredOverridable("a",null));
@@ -356,6 +374,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("original",query.properties().get("a"));
}
+ @Test
public void testSimpleInstanceOverridableWithVariants2() {
QueryProfile profile=new QueryProfile("test");
profile.setDimensions(new String[] {"x"});
@@ -369,39 +388,43 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
}
/** Tests having both an explicit reference and an override */
+ @Test
public void testExplicitReferenceOverride() {
QueryProfile a1=new QueryProfile("a1");
- a1.set("b","a1.b", (QueryProfileRegistry)null);
+ a1.set("b","a1.b", null);
QueryProfile profile=new QueryProfile("test");
- profile.set("a",a1, (QueryProfileRegistry)null);
- profile.set("a.b","a.b", (QueryProfileRegistry)null);
+ profile.set("a",a1, null);
+ profile.set("a.b","a.b", null);
assertEquals("a.b",profile.compile(null).get("a.b"));
}
+ @Test
public void testSettingNonLeaf1() {
QueryProfile p=new QueryProfile("test");
- p.set("a","a-value", (QueryProfileRegistry)null);
- p.set("a.b","a.b-value", (QueryProfileRegistry)null);
+ p.set("a","a-value", null);
+ p.set("a.b","a.b-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertEquals("a-value", cp.get("a"));
assertEquals("a.b-value", cp.get("a.b"));
}
+ @Test
public void testSettingNonLeaf2() {
QueryProfile p=new QueryProfile("test");
- p.set("a.b","a.b-value", (QueryProfileRegistry)null);
- p.set("a","a-value", (QueryProfileRegistry)null);
+ p.set("a.b","a.b-value", null);
+ p.set("a","a-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertEquals("a-value", cp.get("a"));
assertEquals("a.b-value", cp.get("a.b"));
}
+ @Test
public void testSettingNonLeaf3a() {
QueryProfile p=new QueryProfile("test");
p.setDimensions(new String[] {"x"});
- p.set("a.b","a.b-value", (QueryProfileRegistry)null);
+ p.set("a.b","a.b-value", null);
p.set("a","a-value",new String[] {"x1"}, null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
@@ -412,11 +435,12 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("a.b-value", cp.get("a.b", new String[] {"x1"}));
}
+ @Test
public void testSettingNonLeaf3b() {
QueryProfile p=new QueryProfile("test");
p.setDimensions(new String[] {"x"});
p.set("a","a-value",new String[] {"x1"}, null);
- p.set("a.b","a.b-value", (QueryProfileRegistry)null);
+ p.set("a.b","a.b-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
@@ -426,11 +450,12 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("a.b-value", cp.get("a.b",new String[] {"x1"}));
}
+ @Test
public void testSettingNonLeaf4a() {
QueryProfile p=new QueryProfile("test");
p.setDimensions(new String[] {"x"});
p.set("a.b","a.b-value",new String[] {"x1"}, null);
- p.set("a","a-value", (QueryProfileRegistry)null);
+ p.set("a","a-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
@@ -454,6 +479,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
}
+ @Test
public void testSettingNonLeaf5() {
QueryProfile p=new QueryProfile("test");
p.setDimensions(new String[] {"x"});
@@ -468,20 +494,22 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
}
+ @Test
public void testListingWithNonLeafs() {
QueryProfile p=new QueryProfile("test");
- p.set("a","a-value", (QueryProfileRegistry)null);
- p.set("a.b","a.b-value", (QueryProfileRegistry)null);
+ p.set("a","a-value", null);
+ p.set("a.b","a.b-value", null);
Map<String,Object> values = p.compile(null).listValues("a");
assertEquals(1,values.size());
assertEquals("a.b-value",values.get("b"));
}
+ @Test
public void testRankTypeNames() {
QueryProfile p=new QueryProfile("test");
- p.set("a.$b","foo", (QueryProfileRegistry)null);
- p.set("a.query(b)","bar", (QueryProfileRegistry)null);
- p.set("a.b.default-index","fuu", (QueryProfileRegistry)null);
+ p.set("a.$b","foo", null);
+ p.set("a.query(b)","bar", null);
+ p.set("a.b.default-index","fuu", null);
CompiledQueryProfile cp = p.compile(null);
assertEquals("foo", cp.get("a.$b"));
@@ -499,9 +527,10 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("fuu", p2.get("b.default-index"));
}
+ @Test
public void testQueryProfileInlineValueReassignment() {
QueryProfile p=new QueryProfile("test");
- p.set("source.rel.params.query","%{model.queryString}", (QueryProfileRegistry)null);
+ p.set("source.rel.params.query","%{model.queryString}", null);
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?query=foo", Method.GET), p.compile(null));
assertEquals("foo",q.properties().get("source.rel.params.query"));
@@ -511,9 +540,10 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("foo",q.properties().listProperties().get("source.rel.params.query")); // Is still foo because model variables are not supported with the list function
}
+ @Test
public void testQueryProfileInlineValueReassignmentSimpleName() {
QueryProfile p=new QueryProfile("test");
- p.set("key","%{model.queryString}", (QueryProfileRegistry)null);
+ p.set("key","%{model.queryString}", null);
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?query=foo", Method.GET), p.compile(null));
assertEquals("foo",q.properties().get("key"));
@@ -523,9 +553,10 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("foo",q.properties().listProperties().get("key")); // Is still bar because model variables are not supported with the list function
}
+ @Test
public void testQueryProfileInlineValueReassignmentSimpleNameGenericProperty() {
QueryProfile p=new QueryProfile("test");
- p.set("key","%{value}", (QueryProfileRegistry)null);
+ p.set("key","%{value}", null);
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?query=test&value=foo", Method.GET), p.compile(null));
assertEquals("foo",q.properties().get("key"));
@@ -535,6 +566,7 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("bar",q.properties().listProperties().get("key"));
}
+ @Test
public void testQueryProfileModelValueListing() {
QueryProfile p=new QueryProfile("test");
p.freeze();
@@ -546,11 +578,12 @@ public class QueryProfileTestCase extends junit.framework.TestCase {
assertEquals("bar",q.properties().listProperties().get("model.queryString")); // Is still bar because model variables are not supported with the list function
}
+ @Test
public void testEmptyBoolean() {
QueryProfile p=new QueryProfile("test");
p.setDimensions(new String[] {"x","y"});
- p.set("clustering.something","bar", (QueryProfileRegistry)null);
- p.set("clustering.something","bar",new String[] {"x1","y1"}, null);
+ p.set("clustering.something","bar", null);
+ p.set("clustering.something","bar", new String[] {"x1","y1"}, null);
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?x=x1&y=y1&query=bar&clustering.timeline.kano=tur&" +
"clustering.enable=true&clustering.timeline.bucketspec=-" +
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
index 9e920799bbc..9a7a57d5e10 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
@@ -10,20 +10,24 @@ import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileProperties;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
+import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static org.junit.Assert.assertEquals;
+
/**
* @author bratseth
*/
-public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
+public class QueryProfileVariantsTestCase {
+ @Test
public void testSimple() {
QueryProfile profile=new QueryProfile("a");
- profile.set("a","a.deflt", (QueryProfileRegistry)null);
+ profile.set("a","a.deflt", null);
profile.setDimensions(new String[] {"x","y","z"});
profile.set("a","a.1.*.*",new String[] {"x1",null,null}, null);
profile.set("a","a.1.*.1",new String[] {"x1",null,"z1"}, null);
@@ -63,10 +67,11 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertGet("a.2.*.*","a",new String[] {"x2","y?","z?"}, profile, cprofile);
}
+ @Test
public void testVariantsOfInlineCompound() {
QueryProfile profile=new QueryProfile("test");
profile.setDimensions(new String[] {"x"});
- profile.set("a.b","a.b", (QueryProfileRegistry)null);
+ profile.set("a.b","a.b", null);
profile.set("a.b","a.b.x1",new String[] {"x1"}, null);
profile.set("a.b","a.b.x2",new String[] {"x2"}, null);
@@ -77,13 +82,14 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("a.b.x2",cprofile.get("a.b", toMap("x=x2")));
}
+ @Test
public void testVariantsOfExplicitCompound() {
QueryProfile a1=new QueryProfile("a1");
- a1.set("b","a.b", (QueryProfileRegistry)null);
+ a1.set("b","a.b", null);
QueryProfile profile=new QueryProfile("test");
profile.setDimensions(new String[] {"x"});
- profile.set("a",a1, (QueryProfileRegistry)null);
+ profile.set("a",a1, null);
profile.set("a.b","a.b.x1",new String[] {"x1"}, null);
profile.set("a.b","a.b.x2",new String[] {"x2"}, null);
@@ -94,6 +100,7 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("a.b.x2",cprofile.get("a.b", toMap("x=x2")));
}
+ @Test
public void testCompound() {
// Configuration phase
@@ -101,22 +108,22 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
profile.setDimensions(new String[] {"x","y"});
QueryProfile a1=new QueryProfile("a1");
- a1.set("b","a1.b.default", (QueryProfileRegistry)null);
- a1.set("c","a1.c.default", (QueryProfileRegistry)null);
- a1.set("d","a1.d.default", (QueryProfileRegistry)null);
- a1.set("e","a1.e.default", (QueryProfileRegistry)null);
+ a1.set("b","a1.b.default", null);
+ a1.set("c","a1.c.default", null);
+ a1.set("d","a1.d.default", null);
+ a1.set("e","a1.e.default", null);
QueryProfile a2=new QueryProfile("a2");
- a2.set("b","a2.b.default", (QueryProfileRegistry)null);
- a2.set("c","a2.c.default", (QueryProfileRegistry)null);
- a2.set("d","a2.d.default", (QueryProfileRegistry)null);
- a2.set("e","a2.e.default", (QueryProfileRegistry)null);
+ a2.set("b","a2.b.default", null);
+ a2.set("c","a2.c.default", null);
+ a2.set("d","a2.d.default", null);
+ a2.set("e","a2.e.default", null);
- profile.set("a",a1, (QueryProfileRegistry)null); // Must set profile references before overrides
- profile.set("a.b","a.b.default-override", (QueryProfileRegistry)null);
- profile.set("a.c","a.c.default-override", (QueryProfileRegistry)null);
- profile.set("a.d","a.d.default-override", (QueryProfileRegistry)null);
- profile.set("a.g","a.g.default-override", (QueryProfileRegistry)null);
+ profile.set("a",a1, null); // Must set profile references before overrides
+ profile.set("a.b","a.b.default-override", null);
+ profile.set("a.c","a.c.default-override", null);
+ profile.set("a.d","a.d.default-override", null);
+ profile.set("a.g","a.g.default-override", null);
String[] d1=new String[] { "x1","y1" };
profile.set("a",a1,d1, null);
@@ -181,6 +188,7 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("a.g.d3.runtime-override", d3RuntimeProfile.get("a.g", toMap("x=x2", "y=y1")));
}
+ @Test
public void testVariantNotInBase() {
QueryProfile test=new QueryProfile("test");
test.setDimensions(new String[] {"x"});
@@ -192,6 +200,7 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals(null,ctest.get("InX1Only"));
}
+ @Test
public void testVariantNotInBaseSpaceVariantValue() {
QueryProfile test=new QueryProfile("test");
test.setDimensions(new String[] {"x"});
@@ -204,12 +213,13 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals(null,ctest.get("InX1Only"));
}
+ @Test
public void testDimensionsInSuperType() {
QueryProfile parent=new QueryProfile("parent");
parent.setDimensions(new String[] {"x","y"});
QueryProfile child=new QueryProfile("child");
child.addInherited(parent);
- child.set("a","a.default", (QueryProfileRegistry)null);
+ child.set("a","a.default", null);
child.set("a","a.x1.y1",new String[] {"x1","y1"}, null);
child.set("a","a.x1.y2",new String[] {"x1","y2"}, null);
@@ -220,12 +230,13 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("a.x1.y2",cchild.get("a", toMap("x=x1","y=y2")));
}
+ @Test
public void testDimensionsInSuperTypeRuntime() {
QueryProfile parent=new QueryProfile("parent");
parent.setDimensions(new String[] {"x","y"});
QueryProfile child=new QueryProfile("child");
child.addInherited(parent);
- child.set("a","a.default", (QueryProfileRegistry)null);
+ child.set("a","a.default", null);
child.set("a", "a.x1.y1", new String[]{"x1", "y1"}, null);
child.set("a", "a.x1.y2", new String[]{"x1", "y2"}, null);
Properties overridable=new QueryProfileProperties(child.compile(null));
@@ -235,19 +246,20 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("a.x1.y2", overridable.get("a", toMap("x=x1", "y=y2")));
}
+ @Test
public void testVariantsAreResolvedBeforeInheritance() {
QueryProfile parent=new QueryProfile("parent");
parent.setDimensions(new String[] {"x","y"});
- parent.set("a","p.a.default", (QueryProfileRegistry)null);
+ parent.set("a","p.a.default", null);
parent.set("a","p.a.x1.y1",new String[] {"x1","y1"}, null);
parent.set("a","p.a.x1.y2",new String[] {"x1","y2"}, null);
- parent.set("b","p.b.default", (QueryProfileRegistry)null);
+ parent.set("b","p.b.default", null);
parent.set("b","p.b.x1.y1",new String[] {"x1","y1"}, null);
parent.set("b","p.b.x1.y2",new String[] {"x1","y2"}, null);
QueryProfile child=new QueryProfile("child");
child.setDimensions(new String[] {"x","y"});
child.addInherited(parent);
- child.set("a","c.a.default", (QueryProfileRegistry)null);
+ child.set("a","c.a.default", null);
child.set("a","c.a.x1.y1",new String[] {"x1","y1"}, null);
CompiledQueryProfile cchild = child.compile(null);
@@ -259,6 +271,7 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("p.b.x1.y2",cchild.get("b", toMap("x=x1", "y=y2")));
}
+ @Test
public void testVariantsAreResolvedBeforeInheritanceSimplified() {
QueryProfile parent=new QueryProfile("parent");
parent.setDimensions(new String[] {"x","y"});
@@ -267,26 +280,27 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
QueryProfile child=new QueryProfile("child");
child.setDimensions(new String[] {"x","y"});
child.addInherited(parent);
- child.set("a","c.a.default", (QueryProfileRegistry)null);
+ child.set("a","c.a.default", null);
assertEquals("c.a.default",child.compile(null).get("a", toMap("x=x1", "y=y2")));
}
+ @Test
public void testVariantInheritance() {
QueryProfile test=new QueryProfile("test");
test.setDimensions(new String[] {"x","y"});
QueryProfile defaultParent=new QueryProfile("defaultParent");
- defaultParent.set("a","a-default", (QueryProfileRegistry)null);
+ defaultParent.set("a","a-default", null);
QueryProfile x1Parent=new QueryProfile("x1Parent");
- x1Parent.set("a","a-x1", (QueryProfileRegistry)null);
- x1Parent.set("d","d-x1", (QueryProfileRegistry)null);
- x1Parent.set("e","e-x1", (QueryProfileRegistry)null);
+ x1Parent.set("a","a-x1", null);
+ x1Parent.set("d","d-x1", null);
+ x1Parent.set("e","e-x1", null);
QueryProfile x1y1Parent=new QueryProfile("x1y1Parent");
- x1y1Parent.set("a","a-x1y1", (QueryProfileRegistry)null);
+ x1y1Parent.set("a","a-x1y1", null);
QueryProfile x1y2Parent=new QueryProfile("x1y2Parent");
- x1y2Parent.set("a","a-x1y2", (QueryProfileRegistry)null);
- x1y2Parent.set("b","b-x1y2", (QueryProfileRegistry)null);
- x1y2Parent.set("c","c-x1y2", (QueryProfileRegistry)null);
+ x1y2Parent.set("a","a-x1y2", null);
+ x1y2Parent.set("b","b-x1y2", null);
+ x1y2Parent.set("c","c-x1y2", null);
test.addInherited(defaultParent);
test.addInherited(x1Parent,new String[] {"x1"});
test.addInherited(x1y1Parent,new String[] {"x1","y1"});
@@ -323,11 +337,12 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("e-x1y2",ctest.get("e", toMap("x=x1", "y=y2")));
}
+ @Test
public void testVariantInheritanceSimplified() {
QueryProfile test=new QueryProfile("test");
test.setDimensions(new String[] {"x","y"});
QueryProfile x1y2Parent=new QueryProfile("x1y2Parent");
- x1y2Parent.set("c","c-x1y2", (QueryProfileRegistry)null);
+ x1y2Parent.set("c","c-x1y2", null);
test.addInherited(x1y2Parent,new String[] {"x1","y2"});
test.set("c","c-x1",new String[] {"x1"}, null);
@@ -339,13 +354,14 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("c-x1y2",ctest.get("c", toMap("x=x1", "y=y2")));
}
+ @Test
public void testVariantInheritanceWithCompoundReferences() {
QueryProfile test=new QueryProfile("test");
test.setDimensions(new String[] {"x"});
- test.set("a.b","default-a.b", (QueryProfileRegistry)null);
+ test.set("a.b","default-a.b", null);
QueryProfile ac=new QueryProfile("ac");
- ac.set("a.c","referenced-a.c", (QueryProfileRegistry)null);
+ ac.set("a.c","referenced-a.c", null);
test.addInherited(ac,new String[] {"x1"});
test.set("a.b","x1-a.b",new String[] {"x1"}, null);
@@ -355,13 +371,14 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("Inherited variance reference overriding works","x1-a.b",ctest.get("a.b", toMap("x=x1")));
}
+ @Test
public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel() {
QueryProfile test=new QueryProfile("test");
test.setDimensions(new String[] {"x"});
- test.set("o.a.b","default-a.b", (QueryProfileRegistry)null);
+ test.set("o.a.b","default-a.b", null);
QueryProfile ac=new QueryProfile("ac");
- ac.set("o.a.c","referenced-a.c", (QueryProfileRegistry)null);
+ ac.set("o.a.c","referenced-a.c", null);
test.addInherited(ac,new String[] {"x1"});
test.set("o.a.b","x1-a.b",new String[] {"x1"}, null);
@@ -371,18 +388,19 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("Inherited variance reference overriding works","x1-a.b",ctest.get("o.a.b", toMap("x=x1")));
}
+ @Test
public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel() {
QueryProfile test=new QueryProfile("test");
test.setDimensions(new String[] {"x"});
QueryProfile ac=new QueryProfile("ac");
- ac.set("a.c","referenced-a.c", (QueryProfileRegistry)null);
+ ac.set("a.c","referenced-a.c", null);
test.addInherited(ac,new String[] {"x1"});
test.set("a.b","x1-a.b",new String[] {"x1"}, null);
QueryProfile top=new QueryProfile("top");
- top.set("o.a.b","default-a.b", (QueryProfileRegistry)null);
- top.set("o",test, (QueryProfileRegistry)null);
+ top.set("o.a.b","default-a.b", null);
+ top.set("o",test, null);
CompiledQueryProfile ctop = top.compile(null);
assertEquals("Basic functionality","default-a.b",ctop.get("o.a.b"));
@@ -390,12 +408,13 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("Inherited variance reference does not override value set in referent","default-a.b",ctop.get("o.a.b", toMap("x=x1"))); // Note: Changed from x1-a.b in 4.2.3
}
+ @Test
public void testVariantInheritanceOverridesBaseInheritance1() {
QueryProfile test=new QueryProfile("test");
QueryProfile baseInherited=new QueryProfile("baseInherited");
- baseInherited.set("a.b","baseInherited-a.b", (QueryProfileRegistry)null);
+ baseInherited.set("a.b","baseInherited-a.b", null);
QueryProfile variantInherited=new QueryProfile("variantInherited");
- variantInherited.set("a.b","variantInherited-a.b", (QueryProfileRegistry)null);
+ variantInherited.set("a.b","variantInherited-a.b", null);
test.setDimensions(new String[] {"x"});
test.addInherited(baseInherited);
test.addInherited(variantInherited,new String[] {"x1"});
@@ -405,12 +424,13 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("variantInherited-a.b",ctest.get("a.b",toMap("x=x1")));
}
+ @Test
public void testVariantInheritanceOverridesBaseInheritance2() {
QueryProfile test=new QueryProfile("test");
QueryProfile baseInherited=new QueryProfile("baseInherited");
- baseInherited.set("a.b","baseInherited-a.b", (QueryProfileRegistry)null);
+ baseInherited.set("a.b","baseInherited-a.b", null);
QueryProfile variantInherited=new QueryProfile("variantInherited");
- variantInherited.set("a.b","variantInherited-a.b", (QueryProfileRegistry)null);
+ variantInherited.set("a.b","variantInherited-a.b", null);
test.setDimensions(new String[] {"x"});
test.addInherited(baseInherited);
test.addInherited(variantInherited,new String[] {"x1"});
@@ -422,22 +442,23 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("variant-a.c",ctest.get("a.c", toMap("x=x1")));
}
+ @Test
public void testVariantInheritanceOverridesBaseInheritanceComplex() {
QueryProfile defaultQP=new QueryProfile("default");
- defaultQP.set("model.defaultIndex","title", (QueryProfileRegistry)null);
+ defaultQP.set("model.defaultIndex","title", null);
QueryProfile root=new QueryProfile("root");
root.addInherited(defaultQP);
- root.set("model.defaultIndex","default", (QueryProfileRegistry)null);
+ root.set("model.defaultIndex","default", null);
QueryProfile querybest=new QueryProfile("querybest");
- querybest.set("defaultIndex","title", (QueryProfileRegistry)null);
- querybest.set("queryString","best", (QueryProfileRegistry)null);
+ querybest.set("defaultIndex","title", null);
+ querybest.set("queryString","best", null);
QueryProfile multi=new QueryProfile("multi");
multi.setDimensions(new String[] {"x"});
multi.addInherited(defaultQP);
- multi.set("model",querybest, (QueryProfileRegistry)null);
+ multi.set("model",querybest, null);
multi.addInherited(root,new String[] {"x1"});
multi.set("model.queryString","love",new String[] {"x1"}, null);
@@ -452,26 +473,28 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("love",runtime.get("model.queryString", toMap("x=x1")));
}
+ @Test
public void testVariantInheritanceOverridesBaseInheritanceComplexSimplified() {
QueryProfile root=new QueryProfile("root");
- root.set("model.defaultIndex","default", (QueryProfileRegistry)null);
+ root.set("model.defaultIndex","default", null);
QueryProfile multi=new QueryProfile("multi");
multi.setDimensions(new String[] {"x"});
- multi.set("model.defaultIndex","title", (QueryProfileRegistry)null);
+ multi.set("model.defaultIndex","title", null);
multi.addInherited(root,new String[] {"x1"});
assertEquals("default",multi.compile(null).get("model.defaultIndex", toMap("x=x1")));
}
+ @Test
public void testVariantInheritanceOverridesBaseInheritanceMixed() {
QueryProfile root=new QueryProfile("root");
- root.set("model.defaultIndex","default", (QueryProfileRegistry)null);
+ root.set("model.defaultIndex","default", null);
QueryProfile multi=new QueryProfile("multi");
multi.setDimensions(new String[] {"x"});
- multi.set("model.defaultIndex","title", (QueryProfileRegistry)null);
- multi.set("model.queryString","modelQuery", (QueryProfileRegistry)null);
+ multi.set("model.defaultIndex","title", null);
+ multi.set("model.queryString","modelQuery", null);
multi.addInherited(root,new String[] {"x1"});
multi.set("model.queryString","modelVariantQuery",new String[] {"x1"}, null);
@@ -480,23 +503,24 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("modelVariantQuery",cmulti.get("model.queryString", toMap("x=x1")));
}
+ @Test
public void testListVariantPropertiesNoCompounds() {
QueryProfile parent1=new QueryProfile("parent1");
- parent1.set("a","parent1-a", (QueryProfileRegistry)null); // Defined everywhere
- parent1.set("b","parent1-b", (QueryProfileRegistry)null); // Defined everywhere, but no variants
- parent1.set("c","parent1-c", (QueryProfileRegistry)null); // Defined in both parents only
+ parent1.set("a","parent1-a", null); // Defined everywhere
+ parent1.set("b","parent1-b", null); // Defined everywhere, but no variants
+ parent1.set("c","parent1-c", null); // Defined in both parents only
QueryProfile parent2=new QueryProfile("parent2");
- parent2.set("a","parent2-a", (QueryProfileRegistry)null);
- parent2.set("b","parent2-b", (QueryProfileRegistry)null);
- parent2.set("c","parent2-c", (QueryProfileRegistry)null);
- parent2.set("d","parent2-d", (QueryProfileRegistry)null); // Defined in second parent only
+ parent2.set("a","parent2-a", null);
+ parent2.set("b","parent2-b", null);
+ parent2.set("c","parent2-c", null);
+ parent2.set("d","parent2-d", null); // Defined in second parent only
QueryProfile main=new QueryProfile("main");
main.setDimensions(new String[] {"x","y"});
main.addInherited(parent1);
main.addInherited(parent2);
- main.set("a","main-a", (QueryProfileRegistry)null);
+ main.set("a","main-a", null);
main.set("a","main-a-x1",new String[] {"x1"}, null);
main.set("e","main-e-x1",new String[] {"x1"}, null); // Defined in two variants only
main.set("f","main-f-x1",new String[] {"x1"}, null); // Defined in one variants only
@@ -504,19 +528,19 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
main.set("a","main-a-x1.y2",new String[] {"x1","y2"}, null);
main.set("e","main-e-x1.y2",new String[] {"x1","y2"}, null);
main.set("g","main-g-x1.y2",new String[] {"x1","y2"}, null); // Defined in one variant only
- main.set("b","main-b", (QueryProfileRegistry)null);
+ main.set("b","main-b", null);
QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- inheritedVariant1.set("a","inheritedVariant1-a", (QueryProfileRegistry)null);
- inheritedVariant1.set("h","inheritedVariant1-h", (QueryProfileRegistry)null); // Only defined in two inherited variants
+ inheritedVariant1.set("a","inheritedVariant1-a", null);
+ inheritedVariant1.set("h","inheritedVariant1-h", null); // Only defined in two inherited variants
QueryProfile inheritedVariant2=new QueryProfile("inheritedVariant2");
- inheritedVariant2.set("a","inheritedVariant2-a", (QueryProfileRegistry)null);
- inheritedVariant2.set("h","inheritedVariant2-h", (QueryProfileRegistry)null); // Only defined in two inherited variants
- inheritedVariant2.set("i","inheritedVariant2-i", (QueryProfileRegistry)null); // Only defined in one inherited variant
+ inheritedVariant2.set("a","inheritedVariant2-a", null);
+ inheritedVariant2.set("h","inheritedVariant2-h", null); // Only defined in two inherited variants
+ inheritedVariant2.set("i","inheritedVariant2-i", null); // Only defined in one inherited variant
QueryProfile inheritedVariant3=new QueryProfile("inheritedVariant3");
- inheritedVariant3.set("j","inheritedVariant3-j", (QueryProfileRegistry)null); // Only defined in one inherited variant, but inherited twice
+ inheritedVariant3.set("j","inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
main.addInherited(inheritedVariant1,new String[] {"x1"});
main.addInherited(inheritedVariant3,new String[] {"x1"});
@@ -595,13 +619,14 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("parent2-d",listed.get("d"));
}
+ @Test
public void testListVariantPropertiesCompounds1Simplified() {
QueryProfile main=new QueryProfile("main");
main.setDimensions(new String[] {"x","y"});
main.set("a.p1","main-a-x1",new String[] {"x1"}, null);
QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- inheritedVariant1.set("a.p1","inheritedVariant1-a", (QueryProfileRegistry)null);
+ inheritedVariant1.set("a.p1","inheritedVariant1-a", null);
main.addInherited(inheritedVariant1,new String[] {"x1"});
Properties properties=new QueryProfileProperties(main.compile(null));
@@ -611,23 +636,24 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("main-a-x1",listed.get("a.p1"));
}
+ @Test
public void testListVariantPropertiesCompounds1() {
QueryProfile parent1=new QueryProfile("parent1");
- parent1.set("a.p1","parent1-a", (QueryProfileRegistry)null); // Defined everywhere
- parent1.set("b.p1","parent1-b", (QueryProfileRegistry)null); // Defined everywhere, but no variants
- parent1.set("c.p1","parent1-c", (QueryProfileRegistry)null); // Defined in both parents only
+ parent1.set("a.p1","parent1-a", null); // Defined everywhere
+ parent1.set("b.p1","parent1-b", null); // Defined everywhere, but no variants
+ parent1.set("c.p1","parent1-c", null); // Defined in both parents only
QueryProfile parent2=new QueryProfile("parent2");
- parent2.set("a.p1","parent2-a", (QueryProfileRegistry)null);
- parent2.set("b.p1","parent2-b", (QueryProfileRegistry)null);
- parent2.set("c.p1","parent2-c", (QueryProfileRegistry)null);
- parent2.set("d.p1","parent2-d", (QueryProfileRegistry)null); // Defined in second parent only
+ parent2.set("a.p1","parent2-a", null);
+ parent2.set("b.p1","parent2-b", null);
+ parent2.set("c.p1","parent2-c", null);
+ parent2.set("d.p1","parent2-d", null); // Defined in second parent only
QueryProfile main=new QueryProfile("main");
main.setDimensions(new String[] {"x","y"});
main.addInherited(parent1);
main.addInherited(parent2);
- main.set("a.p1","main-a", (QueryProfileRegistry)null);
+ main.set("a.p1","main-a", null);
main.set("a.p1","main-a-x1",new String[] {"x1"}, null);
main.set("e.p1","main-e-x1",new String[] {"x1"}, null); // Defined in two variants only
main.set("f.p1","main-f-x1",new String[] {"x1"}, null); // Defined in one variants only
@@ -635,19 +661,19 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
main.set("a.p1","main-a-x1.y2",new String[] {"x1","y2"}, null);
main.set("e.p1","main-e-x1.y2",new String[] {"x1","y2"}, null);
main.set("g.p1","main-g-x1.y2",new String[] {"x1","y2"}, null); // Defined in one variant only
- main.set("b.p1","main-b", (QueryProfileRegistry)null);
+ main.set("b.p1","main-b", null);
QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- inheritedVariant1.set("a.p1","inheritedVariant1-a", (QueryProfileRegistry)null);
- inheritedVariant1.set("h.p1","inheritedVariant1-h", (QueryProfileRegistry)null); // Only defined in two inherited variants
+ inheritedVariant1.set("a.p1","inheritedVariant1-a", null);
+ inheritedVariant1.set("h.p1","inheritedVariant1-h", null); // Only defined in two inherited variants
QueryProfile inheritedVariant2=new QueryProfile("inheritedVariant2");
- inheritedVariant2.set("a.p1","inheritedVariant2-a", (QueryProfileRegistry)null);
- inheritedVariant2.set("h.p1","inheritedVariant2-h", (QueryProfileRegistry)null); // Only defined in two inherited variants
- inheritedVariant2.set("i.p1","inheritedVariant2-i", (QueryProfileRegistry)null); // Only defined in one inherited variant
+ inheritedVariant2.set("a.p1","inheritedVariant2-a", null);
+ inheritedVariant2.set("h.p1","inheritedVariant2-h", null); // Only defined in two inherited variants
+ inheritedVariant2.set("i.p1","inheritedVariant2-i", null); // Only defined in one inherited variant
QueryProfile inheritedVariant3=new QueryProfile("inheritedVariant3");
- inheritedVariant3.set("j.p1","inheritedVariant3-j", (QueryProfileRegistry)null); // Only defined in one inherited variant, but inherited twice
+ inheritedVariant3.set("j.p1","inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
main.addInherited(inheritedVariant1,new String[] {"x1"});
main.addInherited(inheritedVariant3,new String[] {"x1"});
@@ -725,23 +751,24 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("parent2-d",listed.get("d.p1"));
}
+ @Test
public void testListVariantPropertiesCompounds2() {
QueryProfile parent1=new QueryProfile("parent1");
- parent1.set("p1.a","parent1-a", (QueryProfileRegistry)null); // Defined everywhere
- parent1.set("p1.b","parent1-b", (QueryProfileRegistry)null); // Defined everywhere, but no variants
- parent1.set("p1.c","parent1-c", (QueryProfileRegistry)null); // Defined in both parents only
+ parent1.set("p1.a","parent1-a", null); // Defined everywhere
+ parent1.set("p1.b","parent1-b", null); // Defined everywhere, but no variants
+ parent1.set("p1.c","parent1-c", null); // Defined in both parents only
QueryProfile parent2=new QueryProfile("parent2");
- parent2.set("p1.a","parent2-a", (QueryProfileRegistry)null);
- parent2.set("p1.b","parent2-b", (QueryProfileRegistry)null);
- parent2.set("p1.c","parent2-c", (QueryProfileRegistry)null);
- parent2.set("p1.d","parent2-d", (QueryProfileRegistry)null); // Defined in second parent only
+ parent2.set("p1.a","parent2-a", null);
+ parent2.set("p1.b","parent2-b", null);
+ parent2.set("p1.c","parent2-c", null);
+ parent2.set("p1.d","parent2-d", null); // Defined in second parent only
QueryProfile main=new QueryProfile("main");
main.setDimensions(new String[] {"x","y"});
main.addInherited(parent1);
main.addInherited(parent2);
- main.set("p1.a","main-a", (QueryProfileRegistry)null);
+ main.set("p1.a","main-a", null);
main.set("p1.a","main-a-x1",new String[] {"x1"}, null);
main.set("p1.e","main-e-x1",new String[] {"x1"}, null); // Defined in two variants only
main.set("p1.f","main-f-x1",new String[] {"x1"}, null); // Defined in one variants only
@@ -749,19 +776,19 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
main.set("p1.a","main-a-x1.y2",new String[] {"x1","y2"}, null);
main.set("p1.e","main-e-x1.y2",new String[] {"x1","y2"}, null);
main.set("p1.g","main-g-x1.y2",new String[] {"x1","y2"}, null); // Defined in one variant only
- main.set("p1.b","main-b", (QueryProfileRegistry)null);
+ main.set("p1.b","main-b", null);
QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- inheritedVariant1.set("p1.a","inheritedVariant1-a", (QueryProfileRegistry)null);
- inheritedVariant1.set("p1.h","inheritedVariant1-h", (QueryProfileRegistry)null); // Only defined in two inherited variants
+ inheritedVariant1.set("p1.a","inheritedVariant1-a", null);
+ inheritedVariant1.set("p1.h","inheritedVariant1-h", null); // Only defined in two inherited variants
QueryProfile inheritedVariant2=new QueryProfile("inheritedVariant2");
- inheritedVariant2.set("p1.a","inheritedVariant2-a", (QueryProfileRegistry)null);
- inheritedVariant2.set("p1.h","inheritedVariant2-h", (QueryProfileRegistry)null); // Only defined in two inherited variants
- inheritedVariant2.set("p1.i","inheritedVariant2-i", (QueryProfileRegistry)null); // Only defined in one inherited variant
+ inheritedVariant2.set("p1.a","inheritedVariant2-a", null);
+ inheritedVariant2.set("p1.h","inheritedVariant2-h", null); // Only defined in two inherited variants
+ inheritedVariant2.set("p1.i","inheritedVariant2-i", null); // Only defined in one inherited variant
QueryProfile inheritedVariant3=new QueryProfile("inheritedVariant3");
- inheritedVariant3.set("p1.j","inheritedVariant3-j", (QueryProfileRegistry)null); // Only defined in one inherited variant, but inherited twice
+ inheritedVariant3.set("p1.j","inheritedVariant3-j", null); // Only defined in one inherited variant, but inherited twice
main.addInherited(inheritedVariant1,new String[] {"x1"});
main.addInherited(inheritedVariant3,new String[] {"x1"});
@@ -839,17 +866,18 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("parent2-d",listed.get("p1.d"));
}
+ @Test
public void testQueryProfileReferences() {
QueryProfile main=new QueryProfile("main");
main.setDimensions(new String[] {"x1"});
QueryProfile referencedMain=new QueryProfile("referencedMain");
- referencedMain.set("r1","mainReferenced-r1", (QueryProfileRegistry)null); // In both
- referencedMain.set("r2","mainReferenced-r2", (QueryProfileRegistry)null); // Only in this
+ referencedMain.set("r1","mainReferenced-r1", null); // In both
+ referencedMain.set("r2","mainReferenced-r2", null); // Only in this
QueryProfile referencedVariant=new QueryProfile("referencedVariant");
- referencedVariant.set("r1","variantReferenced-r1", (QueryProfileRegistry)null); // In both
- referencedVariant.set("r3","variantReferenced-r3", (QueryProfileRegistry)null); // Only in this
+ referencedVariant.set("r1","variantReferenced-r1", null); // In both
+ referencedVariant.set("r3","variantReferenced-r3", null); // Only in this
- main.set("a",referencedMain, (QueryProfileRegistry)null);
+ main.set("a",referencedMain, null);
main.set("a",referencedVariant,new String[] {"x1"}, null);
Properties properties=new QueryProfileProperties(main.compile(null));
@@ -868,19 +896,20 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("variantReferenced-r3",listed.get("a.r3"));
}
+ @Test
public void testQueryProfileReferencesWithSubstitution() {
QueryProfile main=new QueryProfile("main");
main.setDimensions(new String[] {"x1"});
QueryProfile referencedMain=new QueryProfile("referencedMain");
- referencedMain.set("r1","%{prefix}mainReferenced-r1", (QueryProfileRegistry)null); // In both
- referencedMain.set("r2","%{prefix}mainReferenced-r2", (QueryProfileRegistry)null); // Only in this
+ referencedMain.set("r1","%{prefix}mainReferenced-r1", null); // In both
+ referencedMain.set("r2","%{prefix}mainReferenced-r2", null); // Only in this
QueryProfile referencedVariant=new QueryProfile("referencedVariant");
- referencedVariant.set("r1","%{prefix}variantReferenced-r1", (QueryProfileRegistry)null); // In both
- referencedVariant.set("r3","%{prefix}variantReferenced-r3", (QueryProfileRegistry)null); // Only in this
+ referencedVariant.set("r1","%{prefix}variantReferenced-r1", null); // In both
+ referencedVariant.set("r3","%{prefix}variantReferenced-r3", null); // Only in this
- main.set("a",referencedMain, (QueryProfileRegistry)null);
+ main.set("a",referencedMain, null);
main.set("a",referencedVariant,new String[] {"x1"}, null);
- main.set("prefix","mainPrefix:", (QueryProfileRegistry)null);
+ main.set("prefix","mainPrefix:", null);
main.set("prefix","variantPrefix:",new String[] {"x1"}, null);
Properties properties=new QueryProfileProperties(main.compile(null));
@@ -899,11 +928,12 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("variantPrefix:variantReferenced-r3",listed.get("a.r3"));
}
+ @Test
public void testNewsCase1() {
QueryProfile shortcuts=new QueryProfile("shortcuts");
shortcuts.setDimensions(new String[] {"custid_1","custid_2","custid_3","custid_4","custid_5","custid_6"});
- shortcuts.set("testout","outside", (QueryProfileRegistry)null);
- shortcuts.set("test.out","dotoutside", (QueryProfileRegistry)null);
+ shortcuts.set("testout","outside", null);
+ shortcuts.set("test.out","dotoutside", null);
shortcuts.set("testin","inside",new String[] {"yahoo","ca","sc"}, null);
shortcuts.set("test.in","dotinside",new String[] {"yahoo","ca","sc"}, null);
@@ -920,6 +950,7 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("dotinside",query.properties().get("test.in"));
}
+ @Test
public void testNewsCase2() {
QueryProfile test=new QueryProfile("test");
test.setDimensions("sort,resulttypes,rss,age,intl,testid".split(","));
@@ -945,6 +976,7 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("10",sourceValues.get("count"));
}
+ @Test
public void testRuntimeAssignmentInClone() {
QueryProfile test=new QueryProfile("test");
test.setDimensions(new String[] {"x"});
@@ -977,12 +1009,13 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
assertEquals("51",qMain.properties().get("a.b",x1m));
}
+ @Test
public void testIncompatibleDimensions() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
backendBase.setDimensions(new String[] { "sort", "resulttypes", "rss" });
- backendBase.set("custid", "s", (QueryProfileRegistry)null);
+ backendBase.set("custid", "s", null);
QueryProfile backend = new QueryProfile("backend");
backend.setDimensions(new String[] { "sort", "offset", "resulttypes", "rss", "age", "lang", "fr", "entry" });
@@ -992,19 +1025,20 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
web.setDimensions(new String[] { "entry", "recency" });
web.set("fr", "alerts", new String[] { "alert" }, null);
- alert.set("config.backend.vertical.news", backend, (QueryProfileRegistry)null);
- alert.set("config.backend.multimedia", web, (QueryProfileRegistry)null);
+ alert.set("config.backend.vertical.news", backend, null);
+ alert.set("config.backend.multimedia", web, null);
backend.set("custid", "yahoo/alerts", new String[] { null, null, null, null, null, "en-US", null, "alert"}, null);
CompiledQueryProfile cAlert = alert.compile(null);
assertEquals("yahoo/alerts", cAlert.get("config.backend.vertical.news.custid", toMap("entry=alert", "intl=us", "lang=en-US")));
}
+ @Test
public void testIncompatibleDimensionsSimplified() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
- backendBase.set("custid", "s", (QueryProfileRegistry)null);
+ backendBase.set("custid", "s", null);
QueryProfile backend = new QueryProfile("backend");
backend.setDimensions(new String[] { "sort", "lang", "fr", "entry" });
@@ -1015,8 +1049,8 @@ public class QueryProfileVariantsTestCase extends junit.framework.TestCase {
web.setDimensions(new String[] { "entry", "recency" });
web.set("fr", "alerts", new String[] { "alert" }, null);
- alert.set("vertical", backend, (QueryProfileRegistry)null);
- alert.set("multimedia", web, (QueryProfileRegistry)null);
+ alert.set("vertical", backend, null);
+ alert.set("multimedia", web, null);
CompiledQueryProfile cAlert = alert.compile(null);
assertEquals("yahoo/alerts", cAlert.get("vertical.custid", toMap("entry=alert", "intl=us", "lang=en-US")));