aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/query
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@yahooinc.com>2022-07-28 12:54:37 +0200
committerBjørn Christian Seime <bjorncs@yahooinc.com>2022-07-28 14:51:34 +0200
commit34ec3d76225844cfed51e407b2f41cd3e311bf47 (patch)
tree8e8dccbd556c4fce1fba37cdf379538d61fe4922 /container-search/src/test/java/com/yahoo/search/query
parent30b533c56ff0286aa3831889f46ba7c19e393ec0 (diff)
Convert container-search to junit5
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/query')
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java13
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java72
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java49
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java19
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java17
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java40
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java42
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java48
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java46
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java69
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java54
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java230
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java240
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java34
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java95
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java376
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java1476
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java16
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java46
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java86
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java144
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java41
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java174
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java17
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java26
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java31
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java9
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java134
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java100
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java138
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java72
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java7
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java98
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java58
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java20
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java12
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java26
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java66
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java30
49 files changed, 2195 insertions, 2218 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
index 9eb44eb0dc4..e3a1eb18a33 100644
--- a/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/MatchingTestCase.java
@@ -2,10 +2,9 @@
package com.yahoo.search.query;
import com.yahoo.search.Query;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
@@ -13,7 +12,7 @@ import static org.junit.Assert.assertEquals;
public class MatchingTestCase {
@Test
- public void testDefaultsInQuery() {
+ void testDefaultsInQuery() {
Query query = new Query("?query=test");
assertNull(query.getRanking().getMatching().getTermwiseLimit());
assertNull(query.getRanking().getMatching().getNumThreadsPerSearch());
@@ -24,7 +23,7 @@ public class MatchingTestCase {
}
@Test
- public void testQueryOverrides() {
+ void testQueryOverrides() {
Query query = new Query("?query=test" +
"&ranking.matching.termwiseLimit=0.7" +
"&ranking.matching.numThreadsPerSearch=17" +
@@ -49,7 +48,7 @@ public class MatchingTestCase {
}
@Test
- public void testBackwardsCompatibleQueryOverrides() {
+ void testBackwardsCompatibleQueryOverrides() {
// The lowercase aliases are supported to provide backwards compatibility of the properties that was wrongly named in the first place.
Query query = new Query("?query=test" +
"&ranking.matching.termwiselimit=0.7" +
@@ -73,7 +72,7 @@ public class MatchingTestCase {
}
@Test
- public void testLimits() {
+ void testLimits() {
verifyException("termwiselimit", "-0.1");
verifyException("termwiselimit", "1.1");
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java b/container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java
index 6c73937f4fa..4badb16f20c 100644
--- a/container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java
+++ b/container-search/src/test/java/com/yahoo/search/query/QueryTreeTest.java
@@ -4,9 +4,9 @@ package com.yahoo.search.query;
import com.yahoo.prelude.query.NotItem;
import com.yahoo.prelude.query.NullItem;
import com.yahoo.prelude.query.WordItem;
-import org.junit.Assert;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -14,53 +14,53 @@ import static org.junit.Assert.assertEquals;
public class QueryTreeTest {
@Test
- public void testAddQueryItemWithRoot() {
- Assert.assertEquals("AND a b",
- new QueryTree(new WordItem("a")).and(new WordItem("b")).toString());
+ void testAddQueryItemWithRoot() {
+ assertEquals("AND a b",
+ new QueryTree(new WordItem("a")).and(new WordItem("b")).toString());
NotItem not = new NotItem();
not.addNegativeItem(new WordItem("b"));
assertEquals("+a -b",
- new QueryTree(new WordItem("a")).and(not).toString());
- }
+ new QueryTree(new WordItem("a")).and(not).toString());
+ }
- @Test
- public void addNotToNot() {
- NotItem not1 = new NotItem();
- not1.addPositiveItem(new WordItem("p1"));
- not1.addNegativeItem(new WordItem("n1.1"));
- not1.addNegativeItem(new WordItem("n1.2"));
+ @Test
+ void addNotToNot() {
+ NotItem not1 = new NotItem();
+ not1.addPositiveItem(new WordItem("p1"));
+ not1.addNegativeItem(new WordItem("n1.1"));
+ not1.addNegativeItem(new WordItem("n1.2"));
- NotItem not2 = new NotItem();
- not2.addPositiveItem(new WordItem("p2"));
- not2.addNegativeItem(new WordItem("n2.1"));
- not2.addNegativeItem(new WordItem("n2.2"));
+ NotItem not2 = new NotItem();
+ not2.addPositiveItem(new WordItem("p2"));
+ not2.addNegativeItem(new WordItem("n2.1"));
+ not2.addNegativeItem(new WordItem("n2.2"));
- QueryTree tree = new QueryTree(not1);
- tree.and(not2);
+ QueryTree tree = new QueryTree(not1);
+ tree.and(not2);
- assertEquals("+(AND p1 p2) -n1.1 -n1.2 -n2.1 -n2.2", tree.toString());
- }
+ assertEquals("+(AND p1 p2) -n1.1 -n1.2 -n2.1 -n2.2", tree.toString());
+ }
- @Test
- public void getCorrectTreeSize() {
+ @Test
+ void getCorrectTreeSize() {
QueryTree nullTree = new QueryTree(new NullItem());
assertEquals(0, nullTree.treeSize());
- NotItem not1 = new NotItem();
- not1.addPositiveItem(new WordItem("p1"));
- not1.addNegativeItem(new WordItem("n1.1"));
- not1.addNegativeItem(new WordItem("n1.2"));
+ NotItem not1 = new NotItem();
+ not1.addPositiveItem(new WordItem("p1"));
+ not1.addNegativeItem(new WordItem("n1.1"));
+ not1.addNegativeItem(new WordItem("n1.2"));
- NotItem not2 = new NotItem();
- not2.addPositiveItem(new WordItem("p2"));
- not2.addNegativeItem(new WordItem("n2.1"));
- not2.addNegativeItem(new WordItem("n2.2"));
+ NotItem not2 = new NotItem();
+ not2.addPositiveItem(new WordItem("p2"));
+ not2.addNegativeItem(new WordItem("n2.1"));
+ not2.addNegativeItem(new WordItem("n2.2"));
- QueryTree tree = new QueryTree(not1);
- tree.and(not2);
+ QueryTree tree = new QueryTree(not1);
+ tree.and(not2);
- assertEquals(8, tree.treeSize());
- }
+ assertEquals(8, tree.treeSize());
+ }
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java b/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
index e30e8bf119a..da1d09fec1e 100644
--- a/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
+++ b/container-search/src/test/java/com/yahoo/search/query/RankProfileInputTest.java
@@ -14,7 +14,7 @@ import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.yolean.Exceptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@@ -23,9 +23,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests queries towards rank profiles using input declarations.
@@ -35,7 +33,7 @@ import static org.junit.Assert.fail;
public class RankProfileInputTest {
@Test
- public void testTensorRankFeatureInRequest() {
+ void testTensorRankFeatureInRequest() {
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
{
@@ -55,13 +53,12 @@ public class RankProfileInputTest {
{ // Resolution is limited to the correct sources
Query query = createTensor1Query(tensorString, "bOnly", "sources=a");
assertEquals(0, query.errors().size());
- assertEquals("Not converted to tensor",
- tensorString, query.properties().get("ranking.features.query(myTensor1)"));
+ assertEquals(tensorString, query.properties().get("ranking.features.query(myTensor1)"), "Not converted to tensor");
}
}
@Test
- public void testTensorRankFeatureInRequestInconsistentInput() {
+ void testTensorRankFeatureInRequestInconsistentInput() {
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
try {
createTensor1Query(tensorString, "inconsistent", "");
@@ -69,14 +66,14 @@ public class RankProfileInputTest {
}
catch (IllegalArgumentException e) {
assertEquals("Conflicting input type declarations for 'query(myTensor1)': " +
- "Declared as tensor(a{},b{}) in rank profile 'inconsistent' in schema 'a', " +
- "and as tensor(x[10]) in rank profile 'inconsistent' in schema 'b'",
- Exceptions.toMessageString(e));
+ "Declared as tensor(a{},b{}) in rank profile 'inconsistent' in schema 'a', " +
+ "and as tensor(x[10]) in rank profile 'inconsistent' in schema 'b'",
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testTensorRankFeatureWithSourceResolution() {
+ void testTensorRankFeatureWithSourceResolution() {
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
{
@@ -99,14 +96,14 @@ public class RankProfileInputTest {
}
@Test
- public void testTensorRankFeatureSetProgrammatically() {
+ void testTensorRankFeatureSetProgrammatically() {
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query.Builder()
.setSchemaInfo(createSchemaInfo())
.setQueryProfile(createQueryProfile()) // Use the instantiation path with query profiles
.setRequest(HttpRequest.createTestRequest("?" +
- "&ranking=commonProfile",
- com.yahoo.jdisc.http.HttpRequest.Method.GET))
+ "&ranking=commonProfile",
+ com.yahoo.jdisc.http.HttpRequest.Method.GET))
.build();
query.properties().set("ranking.features.query(myTensor1)", Tensor.from(tensorString));
@@ -114,24 +111,24 @@ public class RankProfileInputTest {
}
@Test
- public void testTensorRankFeatureSetProgrammaticallyWithWrongType() {
+ void testTensorRankFeatureSetProgrammaticallyWithWrongType() {
Query query = new Query.Builder()
.setSchemaInfo(createSchemaInfo())
.setQueryProfile(createQueryProfile()) // Use the instantiation path with query profiles
.setRequest(HttpRequest.createTestRequest("?" +
- "&ranking=commonProfile",
- com.yahoo.jdisc.http.HttpRequest.Method.GET))
+ "&ranking=commonProfile",
+ com.yahoo.jdisc.http.HttpRequest.Method.GET))
.build();
String tensorString = "tensor(x[3]):[0.1, 0.2, 0.3]";
try {
- query.getRanking().getFeatures().put("query(myTensor1)",Tensor.from(tensorString));
+ query.getRanking().getFeatures().put("query(myTensor1)", Tensor.from(tensorString));
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'ranking.features.query(myTensor1)' to 'tensor(x[3]):[0.1, 0.2, 0.3]': " +
- "This input is declared in rank profile 'commonProfile' as tensor(a{},b{})",
- Exceptions.toMessageString(e));
+ "This input is declared in rank profile 'commonProfile' as tensor(a{},b{})",
+ Exceptions.toMessageString(e));
}
try {
query.properties().set("ranking.features.query(myTensor1)", Tensor.from(tensorString));
@@ -139,13 +136,13 @@ public class RankProfileInputTest {
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'ranking.features.query(myTensor1)' to 'tensor(x[3]):[0.1, 0.2, 0.3]': " +
- "Require a tensor of type tensor(a{},b{})",
- Exceptions.toMessageString(e));
+ "Require a tensor of type tensor(a{},b{})",
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testUnembeddedTensorRankFeatureInRequest() {
+ void testUnembeddedTensorRankFeatureInRequest() {
String text = "text to embed into a tensor";
Tensor embedding1 = Tensor.from("tensor<float>(x[5]):[3,7,4,0,0]]");
Tensor embedding2 = Tensor.from("tensor<float>(x[5]):[1,2,3,4,0]]");
@@ -159,7 +156,7 @@ public class RankProfileInputTest {
assertEmbedQuery("embed(emb1, '" + text + "')", embedding1, embedders);
assertEmbedQuery("embed(emb1, \"" + text + "\")", embedding1, embedders);
assertEmbedQueryFails("embed(emb2, \"" + text + "\")", embedding1, embedders,
- "Can't find embedder 'emb2'. Valid embedders are emb1");
+ "Can't find embedder 'emb2'. Valid embedders are emb1");
embedders = Map.of(
"emb1", new MockEmbedder(text, Language.UNKNOWN, embedding1),
@@ -168,7 +165,7 @@ public class RankProfileInputTest {
assertEmbedQuery("embed(emb1, '" + text + "')", embedding1, embedders);
assertEmbedQuery("embed(emb2, '" + text + "')", embedding2, embedders);
assertEmbedQueryFails("embed(emb3, \"" + text + "\")", embedding1, embedders,
- "Can't find embedder 'emb3'. Valid embedders are emb1,emb2");
+ "Can't find embedder 'emb3'. Valid embedders are emb1,emb2");
// And with specified language
embedders = Map.of(
diff --git a/container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java b/container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java
index f8874040cb2..2decb3fb26a 100644
--- a/container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/SoftTimeoutTestCase.java
@@ -2,8 +2,9 @@
package com.yahoo.search.query;
import com.yahoo.search.Query;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
@@ -11,7 +12,7 @@ import static org.junit.Assert.*;
public class SoftTimeoutTestCase {
@Test
- public void testDefaultsInQuery() {
+ void testDefaultsInQuery() {
Query query = new Query("?query=test");
assertTrue(query.getRanking().getSoftTimeout().getEnable());
assertNull(query.getRanking().getSoftTimeout().getFactor());
@@ -19,7 +20,7 @@ public class SoftTimeoutTestCase {
}
@Test
- public void testQueryOverride() {
+ void testQueryOverride() {
Query query = new Query("?query=test&ranking.softtimeout.factor=0.7&ranking.softtimeout.tailcost=0.3");
assertTrue(query.getRanking().getSoftTimeout().getEnable());
assertEquals(Double.valueOf(0.7), query.getRanking().getSoftTimeout().getFactor());
@@ -31,16 +32,16 @@ public class SoftTimeoutTestCase {
}
@Test
- public void testDisable() {
- Query query=new Query("?query=test&ranking.softtimeout.enable=false");
+ void testDisable() {
+ Query query = new Query("?query=test&ranking.softtimeout.enable=false");
assertFalse(query.getRanking().getSoftTimeout().getEnable());
query.prepare();
assertEquals("false", query.getRanking().getProperties().get("vespa.softtimeout.enable").get(0));
}
@Test
- public void testEnable() {
- Query query=new Query("?query=test&ranking.softtimeout.enable=true");
+ void testEnable() {
+ Query query = new Query("?query=test&ranking.softtimeout.enable=true");
assertTrue(query.getRanking().getSoftTimeout().getEnable());
query.prepare();
assertEquals("true", query.getRanking().getProperties().get("vespa.softtimeout.enable").get(0));
@@ -57,7 +58,7 @@ public class SoftTimeoutTestCase {
}
@Test
- public void testLimits() {
+ void testLimits() {
verifyException("factor", "-0.1");
verifyException("factor", "1.1");
verifyException("tailcost", "-0.1");
diff --git a/container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java
index 4f14ae066cb..facb620b63b 100644
--- a/container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/SortingTestCase.java
@@ -5,20 +5,19 @@ import com.ibm.icu.lang.UScript;
import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RuleBasedCollator;
import com.ibm.icu.util.ULocale;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
*/
public class SortingTestCase {
@Test
- public void validAttributeName() {
+ void validAttributeName() {
assertNotNull(Sorting.fromString("a"));
assertNotNull(Sorting.fromString("_a"));
assertNotNull(Sorting.fromString("+a"));
@@ -33,8 +32,9 @@ public class SortingTestCase {
fail("I only expect 'IllegalArgumentException', not: + " + e.toString());
}
}
+
@Test
- public void requireThatChineseSortCorrect() {
+ void requireThatChineseSortCorrect() {
requireThatChineseHasCorrectRules(Collator.getInstance(new ULocale("zh")));
Sorting ch = Sorting.fromString("uca(a,zh)");
assertEquals(1, ch.fieldOrders().size());
@@ -69,9 +69,10 @@ public class SortingTestCase {
assertNotEquals("", ((RuleBasedCollator) col).getRules());
}
+
@Test
- @Ignore
- public void requireThatArabicSortCorrect() {
+ @Disabled
+ void requireThatArabicSortCorrect() {
requireThatArabicHasCorrectRules(Collator.getInstance(new ULocale("ar")));
Sorting ar = Sorting.fromString("uca(a,ar)");
assertEquals(1, ar.fieldOrders().size());
diff --git a/container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java
index 0152367915a..d4f1e814980 100644
--- a/container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/context/test/LoggingTestCase.java
@@ -8,10 +8,10 @@ import java.util.Set;
import com.yahoo.processing.execution.Execution;
import com.yahoo.search.Query;
import com.yahoo.search.query.context.QueryContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -19,34 +19,34 @@ import static org.junit.Assert.assertTrue;
public class LoggingTestCase {
@Test
- public void testLogging() {
- Query query=new Query();
+ void testLogging() {
+ Query query = new Query();
QueryContext queryContext = query.getContext(true);
- queryContext.logValue("a","a1");
+ queryContext.logValue("a", "a1");
queryContext.trace("first message", 2);
- queryContext.logValue("a","a2");
- queryContext.logValue("b","b1");
+ queryContext.logValue("a", "a2");
+ queryContext.logValue("b", "b1");
QueryContext h2 = query.clone().getContext(true);
- h2.logValue("b","b2");
+ h2.logValue("b", "b2");
h2.trace("second message", 2);
- h2.logValue("b","b3");
- queryContext.logValue("b","b4");
+ h2.logValue("b", "b3");
+ queryContext.logValue("b", "b4");
QueryContext h3 = query.clone().getContext(true);
- h3.logValue("b","b5");
- h3.logValue("c","c1");
+ h3.logValue("b", "b5");
+ h3.logValue("c", "c1");
h3.trace("third message", 2);
- h2.logValue("c","c2");
+ h2.logValue("c", "c2");
queryContext.trace("fourth message", 2);
- queryContext.logValue("d","d1");
+ queryContext.logValue("d", "d1");
h2.trace("fifth message", 2);
- h2.logValue("c","c3");
- queryContext.logValue("c","c4");
+ h2.logValue("c", "c3");
+ queryContext.logValue("c", "c4");
// Assert that all of the above is in the log, in some undefined order
- Set<String> logValues=new HashSet<>();
- for (Iterator<Execution.Trace.LogValue> logValueIterator=queryContext.logValueIterator(); logValueIterator.hasNext(); )
+ Set<String> logValues = new HashSet<>();
+ for (Iterator<Execution.Trace.LogValue> logValueIterator = queryContext.logValueIterator(); logValueIterator.hasNext(); )
logValues.add(logValueIterator.next().toString());
- assertEquals(12,logValues.size());
+ assertEquals(12, logValues.size());
assertTrue(logValues.contains("a=a1"));
assertTrue(logValues.contains("a=a2"));
assertTrue(logValues.contains("b=b1"));
diff --git a/container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java
index 61e1f06ed28..8505da0e814 100644
--- a/container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/context/test/PropertiesTestCase.java
@@ -3,10 +3,10 @@ package com.yahoo.search.query.context.test;
import com.yahoo.search.Query;
import com.yahoo.search.query.context.QueryContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author bratseth
@@ -14,34 +14,34 @@ import static org.junit.Assert.assertNull;
public class PropertiesTestCase {
@Test
- public void testProperties() {
- Query query=new Query();
+ void testProperties() {
+ Query query = new Query();
QueryContext h = query.getContext(true);
- h.setProperty("a","a1");
+ h.setProperty("a", "a1");
h.trace("first message", 2);
- h.setProperty("a","a2");
- h.setProperty("b","b1");
+ h.setProperty("a", "a2");
+ h.setProperty("b", "b1");
query.clone();
QueryContext h2 = query.clone().getContext(true);
- h2.setProperty("b","b2");
+ h2.setProperty("b", "b2");
h2.trace("second message", 2);
- h2.setProperty("b","b3");
- h.setProperty("b","b4");
+ h2.setProperty("b", "b3");
+ h.setProperty("b", "b4");
QueryContext h3 = query.clone().getContext(true);
- h3.setProperty("b","b5");
- h3.setProperty("c","c1");
+ h3.setProperty("b", "b5");
+ h3.setProperty("c", "c1");
h3.trace("third message", 2);
- h2.setProperty("c","c2");
+ h2.setProperty("c", "c2");
h.trace("fourth message", 2);
- h.setProperty("d","d1");
+ h.setProperty("d", "d1");
h2.trace("fifth message", 2);
- h2.setProperty("c","c3");
- h.setProperty("c","c4");
+ h2.setProperty("c", "c3");
+ h.setProperty("c", "c4");
- assertEquals("a2",h.getProperty("a"));
- assertEquals("b5",h.getProperty("b"));
- assertEquals("c4",h.getProperty("c"));
- assertEquals("d1",h.getProperty("d"));
+ assertEquals("a2", h.getProperty("a"));
+ assertEquals("b5", h.getProperty("b"));
+ assertEquals("c4", h.getProperty("c"));
+ assertEquals("d1", h.getProperty("d"));
assertNull(h.getProperty("e"));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java b/container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java
index 76f243e4592..a340e83a77c 100644
--- a/container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/context/test/TraceTestCase.java
@@ -3,15 +3,15 @@ package com.yahoo.search.query.context.test;
import com.yahoo.search.Query;
import com.yahoo.search.query.context.QueryContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Iterator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Steinar Knutsen
@@ -19,8 +19,8 @@ import static org.junit.Assert.assertTrue;
public class TraceTestCase {
@Test
- public void testBasicTracing() {
- Query query=new Query();
+ void testBasicTracing() {
+ Query query = new Query();
QueryContext h = query.getContext(true);
h.trace("first message", 0);
h.trace("second message", 0);
@@ -28,8 +28,8 @@ public class TraceTestCase {
}
@Test
- public void testCloning() throws IOException {
- Query query=new Query();
+ void testCloning() throws IOException {
+ Query query = new Query();
QueryContext h = query.getContext(true);
h.trace("first message", 0);
QueryContext h2 = query.clone().getContext(true);
@@ -49,19 +49,19 @@ public class TraceTestCase {
assertEquals(toplevel, finishedBelow);
// basic sanity test
assertEquals("trace: [ [ " +
- "first message second message third message " +
- "fourth message fifth message ] ]",h.toString());
+ "first message second message third message " +
+ "fourth message fifth message ] ]", h.toString());
Iterator<String> i = h.getTrace().traceNode().root().descendants(String.class).iterator();
- assertEquals("first message",i.next());
- assertEquals("second message",i.next());
- assertEquals("third message",i.next());
- assertEquals("fourth message",i.next());
- assertEquals("fifth message",i.next());
+ assertEquals("first message", i.next());
+ assertEquals("second message", i.next());
+ assertEquals("third message", i.next());
+ assertEquals("fourth message", i.next());
+ assertEquals("fifth message", i.next());
}
@Test
- public void testEmpty() throws IOException {
- Query query=new Query();
+ void testEmpty() throws IOException {
+ Query query = new Query();
QueryContext h = query.getContext(true);
Writer w = new StringWriter();
h.render(w);
@@ -69,20 +69,20 @@ public class TraceTestCase {
}
@Test
- public void testEmptySubSequence() {
- Query query=new Query();
+ void testEmptySubSequence() {
+ Query query = new Query();
QueryContext h = query.getContext(true);
query.clone().getContext(true);
Writer w = new StringWriter();
try {
h.render(w);
} catch (IOException e) {
- assertTrue("rendering empty subsequence crashed", false);
+ assertTrue(false, "rendering empty subsequence crashed");
}
}
@Test
- public void testAttachedTraces() throws IOException {
+ void testAttachedTraces() throws IOException {
String needle0 = "nalle";
String needle1 = "tralle";
String needle2 = "trolle";
@@ -101,10 +101,10 @@ public class TraceTestCase {
int tralle = trace.indexOf(needle1);
int trolle = trace.indexOf(needle2);
int bamse = trace.indexOf(needle3);
- assertTrue("Could not find first manual context to main query.", nalle > 0);
- assertTrue("Could not find second manual context to main query.", bamse > 0);
- assertTrue("Could not find first manual context to attached query.", tralle > 0);
- assertTrue("Could not find second manual context to attached query.", trolle > 0);
+ assertTrue(nalle > 0, "Could not find first manual context to main query.");
+ assertTrue(bamse > 0, "Could not find second manual context to main query.");
+ assertTrue(tralle > 0, "Could not find first manual context to attached query.");
+ assertTrue(trolle > 0, "Could not find second manual context to attached query.");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java
index 22847772ff3..a73d12a5a4e 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/ChainedMapTestCase.java
@@ -1,28 +1,27 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.Set;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author baldersheim
*/
public class ChainedMapTestCase {
@Test
- public void testIsEmpty() {
+ void testIsEmpty() {
assertTrue(new ChainedMap<String, String>(Map.of(), Map.of()).isEmpty());
assertFalse(new ChainedMap<>(Map.of("k", "v"), Map.of()).isEmpty());
assertFalse(new ChainedMap<>(Map.of(), Map.of("k", "v")).isEmpty());
assertFalse(new ChainedMap<>(Map.of("k", "v"), Map.of("k", "v")).isEmpty());
}
+
@Test
- public void testSize() {
+ void testSize() {
assertEquals(0, new ChainedMap<String, String>(Map.of(), Map.of()).size());
assertEquals(1, new ChainedMap<>(Map.of("k", "v"), Map.of()).size());
assertEquals(1, new ChainedMap<>(Map.of(), Map.of("k", "v")).size());
@@ -30,8 +29,9 @@ public class ChainedMapTestCase {
assertEquals(2, new ChainedMap<>(Map.of("k", "v"), Map.of("K", "v")).size());
assertEquals(2, new ChainedMap<>(Map.of("k", "v"), Map.of("K", "v", "k", "v")).size());
}
+
@Test
- public void testGetUsesBoth() {
+ void testGetUsesBoth() {
Map<String, String> a = Map.of("a", "a_1");
Map<String, String> b = Map.of("b", "b_1");
Map<String, String> ab = Map.of("a", "a_2", "b", "b_2");
@@ -53,7 +53,7 @@ public class ChainedMapTestCase {
}
@Test
- public void testKeySet() {
+ void testKeySet() {
assertTrue(new ChainedMap<String, String>(Map.of(), Map.of()).keySet().isEmpty());
Map<String, String> a = Map.of("a", "a_1");
Map<String, String> b = Map.of("b", "b_1");
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java
index bebdda15983..013de292cb7 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/compiled/BindingTestCase.java
@@ -2,13 +2,13 @@
package com.yahoo.search.query.profile.compiled;
import com.yahoo.search.query.profile.DimensionBinding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -16,7 +16,7 @@ import static org.junit.Assert.assertTrue;
public class BindingTestCase {
@Test
- public void testGeneralizes() {
+ void testGeneralizes() {
Map<String, String> m1 = new HashMap<>();
m1.put("a", "a1");
m1.put("b", "b1");
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java b/container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java
index 511921ac047..c2faeb899c9 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/compiled/CompiledQueryProfileRegistryTest.java
@@ -2,12 +2,12 @@
package com.yahoo.search.query.profile.compiled;
import com.yahoo.search.query.profile.config.QueryProfilesConfig;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.Executors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author gjoranv
@@ -15,13 +15,13 @@ import static org.junit.Assert.assertTrue;
public class CompiledQueryProfileRegistryTest {
@Test
- public void registry_can_be_created_from_config() {
+ void registry_can_be_created_from_config() {
var config = new QueryProfilesConfig.Builder()
.queryprofile(new QueryProfilesConfig.Queryprofile.Builder()
- .id("profile1")
- .property(new QueryProfilesConfig.Queryprofile.Property.Builder()
- .name("hits")
- .value("5")))
+ .id("profile1")
+ .property(new QueryProfilesConfig.Queryprofile.Property.Builder()
+ .name("hits")
+ .value("5")))
.build();
var executor = Executors.newCachedThreadPool();
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java
index 21f20e70ddb..ebe9c9d3c04 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/MultiProfileTestCase.java
@@ -7,10 +7,10 @@ import java.util.Map;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileXMLReader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author bratseth
@@ -18,31 +18,31 @@ import static org.junit.Assert.assertNotNull;
public class MultiProfileTestCase {
@Test
- public void testValid() {
- QueryProfileRegistry registry=
+ void testValid() {
+ QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/multiprofile");
- QueryProfile multiprofile1=registry.getComponent("multiprofile1");
+ 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("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);
+ 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);
+ 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);
}
private void assertGet(String expectedValue,String parameter,String[] dimensionValues,QueryProfile profile) {
@@ -50,7 +50,7 @@ public class MultiProfileTestCase {
context.put("region",dimensionValues[0]);
context.put("model",dimensionValues[1]);
context.put("bucket",dimensionValues[2]);
- assertEquals("Looking up '" + parameter + "' for '" + toString(dimensionValues) + "'",expectedValue,profile.get(parameter,context,null));
+ assertEquals(expectedValue,profile.get(parameter,context,null),"Looking up '" + parameter + "' for '" + toString(dimensionValues) + "'");
}
private String toString(String[] array) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java
index 29a8969233b..bf3afecc115 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileConfigurationTestCase.java
@@ -7,15 +7,13 @@ import com.yahoo.search.query.profile.QueryProfileProperties;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.search.query.profile.config.QueryProfileConfigurer;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
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.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -25,9 +23,9 @@ public class QueryProfileConfigurationTestCase {
public final String CONFIG_DIR ="src/test/java/com/yahoo/search/query/profile/config/test/";
@Test
- public void testConfiguration() {
+ void testConfiguration() {
var profile = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "query-profiles-configuration.cfg")
- .getComponent("default");
+ .getComponent("default");
assertEquals("a-value", profile.get("a"));
assertEquals("b-value", profile.get("b"));
@@ -43,9 +41,9 @@ public class QueryProfileConfigurationTestCase {
}
@Test
- public void testBug3197426() {
+ void testBug3197426() {
var profile = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "bug3197426.cfg")
- .getComponent("default").compile(null);
+ .getComponent("default").compile(null);
Map<String, Object> properties = new QueryProfileProperties(profile).listProperties("source.image");
assertEquals("yes", properties.get("mlr"));
@@ -63,42 +61,42 @@ public class QueryProfileConfigurationTestCase {
}
@Test
- public void testVariantConfiguration() {
+ void testVariantConfiguration() {
var registry = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "query-profile-variants-configuration.cfg");
// Variant 1
QueryProfile variants1 = registry.getComponent("variants1");
- assertGet("x1.y1.a", "a", new String[] { "x1","y1" }, variants1);
- assertGet("x1.y1.b", "b", new String[] { "x1","y1" }, variants1);
- assertGet("x1.y?.a", "a", new String[] { "x1","zz" }, variants1);
- assertGet("x?.y1.a", "a", new String[] { "zz","y1" }, variants1);
- assertGet("a-deflt", "a", new String[] { "z1","z2" }, variants1);
+ assertGet("x1.y1.a", "a", new String[]{"x1", "y1"}, variants1);
+ assertGet("x1.y1.b", "b", new String[]{"x1", "y1"}, variants1);
+ assertGet("x1.y?.a", "a", new String[]{"x1", "zz"}, variants1);
+ assertGet("x?.y1.a", "a", new String[]{"zz", "y1"}, variants1);
+ assertGet("a-deflt", "a", new String[]{"z1", "z2"}, variants1);
// ...inherited
- assertGet("parent1-value", "parent1", new String[] { "x1","y1" }, variants1);
- assertGet("parent2-value", "parent2", new String[] { "x1","y1" }, variants1);
- assertGet(null, "parent1", new String[] { "x1","y2" }, variants1);
- assertGet(null, "parent2", new String[] { "x1","y2" }, variants1);
+ assertGet("parent1-value", "parent1", new String[]{"x1", "y1"}, variants1);
+ assertGet("parent2-value", "parent2", new String[]{"x1", "y1"}, variants1);
+ assertGet(null, "parent1", new String[]{"x1", "y2"}, variants1);
+ assertGet(null, "parent2", new String[]{"x1", "y2"}, variants1);
// Variant 2
QueryProfile variants2 = registry.getComponent("variants2");
- assertGet("variant2:y1.c", "c", new String[] { "*","y1" }, variants2);
- assertGet("variant2:y2.c", "c", new String[] { "*","y2" }, variants2);
- assertGet("variant2:c-df", "c", new String[] { "*","z1" }, variants2);
- assertGet("variant2:c-df", "c", new String[] { }, variants2);
- assertGet("variant2:c-df", "c", new String[] { "*" }, variants2);
- assertGet(null, "d", new String[] { "*","y1" }, variants2);
+ assertGet("variant2:y1.c", "c", new String[]{"*", "y1"}, variants2);
+ assertGet("variant2:y2.c", "c", new String[]{"*", "y2"}, variants2);
+ assertGet("variant2:c-df", "c", new String[]{"*", "z1"}, variants2);
+ assertGet("variant2:c-df", "c", new String[]{ }, variants2);
+ assertGet("variant2:c-df", "c", new String[]{"*" }, variants2);
+ assertGet(null, "d", new String[]{"*", "y1"}, variants2);
// Reference following from variant 1
- assertGet("variant2:y1.c", "toVariants.c", new String[] { "**", "y1" } , variants1);
- assertGet("variant3:c-df", "toVariants.c", new String[] { "x1", "**" } , variants1);
- assertGet("variant3:y1.c", "toVariants.c", new String[] { "x1", "y1" } , variants1); // variant3 by order priority
- assertGet("variant3:y2.c", "toVariants.c", new String[] { "x1", "y2" } , variants1);
+ assertGet("variant2:y1.c", "toVariants.c", new String[]{"**", "y1"}, variants1);
+ assertGet("variant3:c-df", "toVariants.c", new String[]{"x1", "**"}, variants1);
+ assertGet("variant3:y1.c", "toVariants.c", new String[]{"x1", "y1"}, variants1); // variant3 by order priority
+ assertGet("variant3:y2.c", "toVariants.c", new String[]{"x1", "y2"}, variants1);
}
@Test
- public void testVariantConfigurationThroughQueryLookup() {
+ void testVariantConfigurationThroughQueryLookup() {
var registry = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "query-profile-variants-configuration.cfg")
- .compile();
+ .compile();
CompiledQueryProfile variants1 = registry.getComponent("variants1");
@@ -107,7 +105,7 @@ public class QueryProfileConfigurationTestCase {
assertEquals("x1.y1.b", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=y1"), variants1).properties().get("b"));
assertEquals("x1.y1.defaultIndex", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=y1"), variants1).getModel().getDefaultIndex());
assertEquals("x1.y?.a", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=zz"), variants1).properties().get("a"));
- assertEquals("x1.y?.defaultIndex", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=zz"),variants1).getModel().getDefaultIndex());
+ assertEquals("x1.y?.defaultIndex", new Query(QueryTestCase.httpEncode("?query=foo&x=x1&y=zz"), variants1).getModel().getDefaultIndex());
assertEquals("x?.y1.a", new Query(QueryTestCase.httpEncode("?query=foo&x=zz&y=y1"), variants1).properties().get("a"));
assertEquals("x?.y1.defaultIndex", new Query(QueryTestCase.httpEncode("?query=foo&x=zz&y=y1"), variants1).getModel().getDefaultIndex());
assertEquals("x?.y1.filter", new Query(QueryTestCase.httpEncode("?query=foo&x=zz&y=y1"), variants1).getModel().getFilter());
@@ -130,14 +128,14 @@ public class QueryProfileConfigurationTestCase {
}
@Test
- public void testVariant2ConfigurationThroughQueryLookup() {
+ void testVariant2ConfigurationThroughQueryLookup() {
final double delta = 0.0000001;
var registry = QueryProfileConfigurer.createFromConfigId("file:" + CONFIG_DIR + "query-profile-variants2.cfg")
- .compile();
+ .compile();
Query query = new Query(QueryTestCase.httpEncode("?query=heh&queryProfile=multi&myindex=default&myquery=lo ve&tracelevel=5"),
- registry.findQueryProfile("multi"));
+ registry.findQueryProfile("multi"));
assertEquals("love", query.properties().get("model.queryString"));
assertEquals("default", query.properties().get("model.defaultIndex"));
@@ -152,8 +150,7 @@ public class QueryProfileConfigurationTestCase {
Map<String, String> context = new HashMap<>();
for (int i = 0; i<dimensionValues.length; i++)
context.put(profile.getVariants().getDimensions().get(i), dimensionValues[i]); // Lookup dim. names to ease test...
- assertEquals("Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'",
- expectedValue, profile.get(parameter, context, null));
+ assertEquals(expectedValue, profile.get(parameter, context, null), "Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java
index c64d5df64f9..ce6f6264623 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/QueryProfileIntegrationTestCase.java
@@ -14,10 +14,10 @@ import com.yahoo.search.handler.HttpSearchResponse;
import com.yahoo.search.handler.SearchHandler;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Tests using query profiles in searches
@@ -26,13 +26,13 @@ import static org.junit.Assert.assertNotNull;
*/
public class QueryProfileIntegrationTestCase {
- @org.junit.After
+ @org.junit.jupiter.api.AfterEach
public void tearDown() {
System.getProperties().remove("config.id");
}
@Test
- public void testUntyped() {
+ void testUntyped() {
String configId = "dir:src/test/java/com/yahoo/search/query/profile/config/test/untyped";
System.setProperty("config.id", configId);
Container container = new Container();
@@ -41,79 +41,79 @@ public class QueryProfileIntegrationTestCase {
// Should get "default" query profile containing the "test" search chain containing the "test" searcher
HttpRequest request = HttpRequest.createTestRequest("search", Method.GET);
- HttpSearchResponse response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ HttpSearchResponse response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:test"));
// Should get the "test' query profile containing the "default" search chain containing the "default" searcher
request = HttpRequest.createTestRequest("search?queryProfile=test", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:default"));
// Should get "default" query profile, but override the search chain to default
request = HttpRequest.createTestRequest("search?searchChain=default", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:default"));
// Tests a profile setting hits and offset
request = HttpRequest.createTestRequest("search?queryProfile=hitsoffset", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertEquals(20, response.getQuery().getHits());
assertEquals(80, response.getQuery().getOffset());
// Tests a non-resolved profile request
request = HttpRequest.createTestRequest("search?queryProfile=none", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertNotNull("Got an error", response.getResult().hits().getError());
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertNotNull(response.getResult().hits().getError(), "Got an error");
assertEquals("Could not resolve query profile 'none'", response.getResult().hits().getError().getDetailedMessage());
// Tests that properties in objects owned by query is handled correctly
request = HttpRequest.createTestRequest("search?query=word&queryProfile=test", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertEquals("index" ,response.getQuery().getModel().getDefaultIndex());
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertEquals("index", response.getQuery().getModel().getDefaultIndex());
assertEquals("WEAKAND(100) index:word", response.getQuery().getModel().getQueryTree().toString());
configurer.shutdown();
}
@Test
- public void testTyped() {
+ void testTyped() {
String configId = "dir:src/test/java/com/yahoo/search/query/profile/config/test/typed";
System.setProperty("config.id", configId);
Container container = new Container();
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper(container, configId);
- SearchHandler searchHandler = (SearchHandler)configurer.getRequestHandlerRegistry().getComponent(SearchHandler.class.getName());
+ SearchHandler searchHandler = (SearchHandler) configurer.getRequestHandlerRegistry().getComponent(SearchHandler.class.getName());
// Should get "default" query profile containing the "test" search chain containing the "test" searcher
HttpRequest request = HttpRequest.createTestRequest("search", Method.GET);
- HttpSearchResponse response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ HttpSearchResponse response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:test"));
// Should get the "test' query profile containing the "default" search chain containing the "default" searcher
request = HttpRequest.createTestRequest("search?queryProfile=test", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:default"));
// Should get "default" query profile, but override the search chain to default
request = HttpRequest.createTestRequest("search?searchChain=default", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
assertNotNull(response.getResult().hits().get("from:default"));
// Tests a profile setting hits and offset
request = HttpRequest.createTestRequest("search?queryProfile=hitsoffset", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertEquals(22,response.getQuery().getHits());
- assertEquals(80,response.getQuery().getOffset());
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertEquals(22, response.getQuery().getHits());
+ assertEquals(80, response.getQuery().getOffset());
// Tests a non-resolved profile request
request = HttpRequest.createTestRequest("search?queryProfile=none", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertNotNull("Got an error",response.getResult().hits().getError());
- assertEquals("Could not resolve query profile 'none'",response.getResult().hits().getError().getDetailedMessage());
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertNotNull(response.getResult().hits().getError(), "Got an error");
+ assertEquals("Could not resolve query profile 'none'", response.getResult().hits().getError().getDetailedMessage());
// Test overriding a sub-profile in the request
request = HttpRequest.createTestRequest("search?queryProfile=root&sub=newsub", Method.GET);
- response = (HttpSearchResponse)searchHandler.handle(request); // Cast to access content directly
- assertEquals("newsubvalue1",response.getQuery().properties().get("sub.value1"));
- assertEquals("newsubvalue2",response.getQuery().properties().get("sub.value2"));
+ response = (HttpSearchResponse) searchHandler.handle(request); // Cast to access content directly
+ assertEquals("newsubvalue1", response.getQuery().properties().get("sub.value1"));
+ assertEquals("newsubvalue2", response.getQuery().properties().get("sub.value2"));
configurer.shutdown();
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java
index 944ee6d79ef..de46e6ee77c 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/TypedProfilesConfigurationTestCase.java
@@ -4,11 +4,9 @@ package com.yahoo.search.query.profile.config.test;
import com.yahoo.search.query.profile.config.QueryProfileConfigurer;
import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -17,7 +15,7 @@ public class TypedProfilesConfigurationTestCase {
/** Asserts that everything is read correctly from this configuration */
@Test
- public void testIt() {
+ void testIt() {
var registry = QueryProfileConfigurer.createFromConfigId("file:src/test/java/com/yahoo/search/query/profile/config/test/typed-profiles.cfg");
var types = registry.getTypeRegistry();
@@ -33,19 +31,19 @@ public class TypedProfilesConfigurationTestCase {
assertTrue(testType.getField("myString").isOverridable());
assertFalse(testType.getField("myInteger").isMandatory());
assertFalse(testType.getField("myInteger").isOverridable());
- FieldDescription field= testType.getField("myUserQueryProfile");
+ FieldDescription field = testType.getField("myUserQueryProfile");
assertEquals("reference to a query profile of type 'user'", field.getType().toInstanceDescription());
assertTrue(field.getAliases().contains("myqp"));
assertTrue(field.getAliases().contains("user-profile"));
- QueryProfileType testTypeStrict=types.getComponent("testtypestrict");
+ QueryProfileType testTypeStrict = types.getComponent("testtypestrict");
assertTrue(testTypeStrict.isStrict());
assertTrue(testTypeStrict.getMatchAsPath());
assertEquals(7, testTypeStrict.fields().size());
assertEquals("reference to a query profile of type 'userstrict'",
- testTypeStrict.getField("myUserQueryProfile").getType().toInstanceDescription());
+ testTypeStrict.getField("myUserQueryProfile").getType().toInstanceDescription());
- QueryProfileType user=types.getComponent("user");
+ QueryProfileType user = types.getComponent("user");
assertFalse(user.isStrict());
assertFalse(user.getMatchAsPath());
assertEquals(2, user.fields().size());
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java
index 62bc89c8453..dcb41dc5e31 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java
@@ -19,17 +19,13 @@ import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileXMLReader;
import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
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;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -37,7 +33,7 @@ import static org.junit.Assert.fail;
public class XmlReadingTestCase {
@Test
- public void testInheritance() {
+ void testInheritance() {
QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/inheritance");
@@ -48,7 +44,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testValid() {
+ void testValid() {
QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/validxml");
CompiledQueryProfileRegistry cRegistry = registry.compile();
@@ -106,8 +102,8 @@ public class XmlReadingTestCase {
assertEquals(3, query.getTrace().getLevel());
QueryProfile someUser = registry.getComponent("someUser");
- assertEquals("5",someUser.get("sub.test"));
- assertEquals(18,someUser.get("age"));
+ assertEquals("5", someUser.get("sub.test"));
+ assertEquals(18, someUser.get("age"));
// aliases
assertEquals(18, someUser.get("alder"));
@@ -129,19 +125,19 @@ public class XmlReadingTestCase {
}
@Test
- public void testBasicsNoProfile() {
- Query q=new Query(HttpRequest.createTestRequest("?query=test", Method.GET));
- assertEquals("test",q.properties().get("query"));
- assertEquals("test",q.properties().get("QueRY"));
- assertEquals("test",q.properties().get("model.queryString"));
- assertEquals("test",q.getModel().getQueryString());
+ void testBasicsNoProfile() {
+ Query q = new Query(HttpRequest.createTestRequest("?query=test", Method.GET));
+ assertEquals("test", q.properties().get("query"));
+ assertEquals("test", q.properties().get("QueRY"));
+ assertEquals("test", q.properties().get("model.queryString"));
+ assertEquals("test", q.getModel().getQueryString());
}
@Test
- public void testBasicsWithProfile() {
+ void testBasicsWithProfile() {
QueryProfile p = new QueryProfile("default");
p.set("a", "foo", null);
- Query q=new Query(HttpRequest.createTestRequest("?query=test", Method.GET), p.compile(null));
+ Query q = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), p.compile(null));
assertEquals("test", q.properties().get("query"));
assertEquals("test", q.properties().get("QueRY"));
assertEquals("test", q.properties().get("model.queryString"));
@@ -150,7 +146,7 @@ public class XmlReadingTestCase {
/** Tests a subset of the configuration in the system test of this */
@Test
- public void testSystemtest() {
+ void testSystemtest() {
String queryString = "?query=test";
QueryProfileXMLReader reader = new QueryProfileXMLReader();
@@ -170,7 +166,7 @@ public class XmlReadingTestCase {
assertEquals("le", p.get("subst.end"));
assertEquals("title", p.get("model.defaultIndex"));
- Map<String,Object> ps = p.listProperties();
+ Map<String, Object> ps = p.listProperties();
assertEquals("bar", ps.get("foo"));
assertEquals(5, ps.get("hits"));
assertEquals("tit", ps.get("subst"));
@@ -180,7 +176,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testInvalid1() {
+ void testInvalid1() {
try {
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml1");
fail("Should have failed");
@@ -191,7 +187,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testInvalid2() {
+ void testInvalid2() {
try {
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml2");
fail("Should have failed");
@@ -202,7 +198,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testInvalid3() {
+ void testInvalid3() {
try {
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml3");
fail("Should have failed");
@@ -213,7 +209,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testQueryProfileVariants() {
+ void testQueryProfileVariants() {
String query = "?query=test&dim1=yahoo&dim2=uk&dim3=test";
QueryProfileXMLReader reader = new QueryProfileXMLReader();
@@ -227,7 +223,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testQueryProfileVariantsWithOverridableFalse() {
+ void testQueryProfileVariantsWithOverridableFalse() {
QueryProfileXMLReader reader = new QueryProfileXMLReader();
CompiledQueryProfileRegistry registry = reader.read("src/test/java/com/yahoo/search/query/profile/config/test/variants/").compile();
CompiledQueryProfile profile = registry.findQueryProfile("default");
@@ -240,156 +236,156 @@ public class XmlReadingTestCase {
}
@Test
- public void testNewsFE1() {
- CompiledQueryProfileRegistry registry=new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe").compile();
+ void testNewsFE1() {
+ CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe").compile();
- String queryString="tiled?vertical=news&query=barack&intl=us&resulttypes=article&testid=&clientintl=us&SpellState=&rss=0&tracelevel=5";
+ String queryString = "tiled?vertical=news&query=barack&intl=us&resulttypes=article&testid=&clientintl=us&SpellState=&rss=0&tracelevel=5";
- Query query=new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
- assertEquals("13",query.properties().listProperties().get("source.news.discovery.sources.count"));
- assertEquals("13",query.properties().get("source.news.discovery.sources.count"));
- assertEquals("sources",query.properties().listProperties().get("source.news.discovery"));
- assertEquals("sources",query.properties().get("source.news.discovery"));
+ Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
+ assertEquals("13", query.properties().listProperties().get("source.news.discovery.sources.count"));
+ assertEquals("13", query.properties().get("source.news.discovery.sources.count"));
+ assertEquals("sources", query.properties().listProperties().get("source.news.discovery"));
+ assertEquals("sources", query.properties().get("source.news.discovery"));
}
@Test
- public void testQueryProfileVariants2() {
+ void testQueryProfileVariants2() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/queryprofilevariants2").compile();
CompiledQueryProfile multi = registry.getComponent("multi");
{
- Query query=new Query(HttpRequest.createTestRequest("?queryProfile=multi", Method.GET), multi);
+ Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi", Method.GET), multi);
query.validate();
- assertEquals("best",query.properties().get("model.queryString"));
- assertEquals("best",query.getModel().getQueryString());
+ assertEquals("best", query.properties().get("model.queryString"));
+ assertEquals("best", query.getModel().getQueryString());
}
{
- Query query=new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default", Method.GET), multi);
+ Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default", Method.GET), multi);
query.validate();
assertEquals("best", query.properties().get("model.queryString"));
assertEquals("best", query.getModel().getQueryString());
assertEquals("default", query.getModel().getDefaultIndex());
}
{
- Query query=new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default&myquery=love", Method.GET), multi);
+ Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default&myquery=love", Method.GET), multi);
query.validate();
assertEquals("love", query.properties().get("model.queryString"));
assertEquals("love", query.getModel().getQueryString());
assertEquals("default", query.getModel().getDefaultIndex());
}
{
- Query query=new Query(HttpRequest.createTestRequest("?model=querybest", Method.GET), multi);
+ Query query = new Query(HttpRequest.createTestRequest("?model=querybest", Method.GET), multi);
query.validate();
- assertEquals("best",query.getModel().getQueryString());
- assertEquals("title",query.properties().get("model.defaultIndex"));
- assertEquals("title",query.getModel().getDefaultIndex());
+ assertEquals("best", query.getModel().getQueryString());
+ assertEquals("title", query.properties().get("model.defaultIndex"));
+ assertEquals("title", query.getModel().getDefaultIndex());
}
}
@Test
- public void testKlee() {
- QueryProfileRegistry registry=
+ 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 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");
- assertEquals("",p.getId().getVersion().toString()); // that is 0.0.0
- assertEquals("[query profile 'twitter_dd']",p.inherited().toString());
+ QueryProfile p = registry.getComponent("twitter_dd-us:0.0.0");
+ assertEquals("", p.getId().getVersion().toString()); // that is 0.0.0
+ assertEquals("[query profile 'twitter_dd']", p.inherited().toString());
}
@Test
- public void testVersions() {
- QueryProfileRegistry registry=
+ void testVersions() {
+ QueryProfileRegistry registry =
new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/versions");
registry.freeze();
- assertEquals("1.20.100",registry.findQueryProfile("testprofile:1.20.100").getId().getVersion().toString());
- assertEquals("1.20.100",registry.findQueryProfile("testprofile:1.20").getId().getVersion().toString());
- assertEquals("1.20.100",registry.findQueryProfile("testprofile:1").getId().getVersion().toString());
- assertEquals("1.20.100",registry.findQueryProfile("testprofile").getId().getVersion().toString());
+ assertEquals("1.20.100", registry.findQueryProfile("testprofile:1.20.100").getId().getVersion().toString());
+ assertEquals("1.20.100", registry.findQueryProfile("testprofile:1.20").getId().getVersion().toString());
+ assertEquals("1.20.100", registry.findQueryProfile("testprofile:1").getId().getVersion().toString());
+ assertEquals("1.20.100", registry.findQueryProfile("testprofile").getId().getVersion().toString());
}
@Test
- public void testNewsFE2() {
- CompiledQueryProfileRegistry registry=new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe2").compile();
+ void testNewsFE2() {
+ CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe2").compile();
- String queryString="tiled?query=a&intl=tw&mode=adv&mode=adv";
+ String queryString = "tiled?query=a&intl=tw&mode=adv&mode=adv";
- Query query=new Query(HttpRequest.createTestRequest(queryString, Method.GET),registry.getComponent("default"));
- assertEquals("news_adv",query.properties().listProperties().get("provider"));
- assertEquals("news_adv",query.properties().get("provider"));
+ Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
+ assertEquals("news_adv", query.properties().listProperties().get("provider"));
+ assertEquals("news_adv", query.properties().get("provider"));
}
@Test
- public void testSourceProvider() {
- CompiledQueryProfileRegistry registry=new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/sourceprovider").compile();
+ void testSourceProvider() {
+ CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/sourceprovider").compile();
- String queryString="tiled?query=india&queryProfile=myprofile&source.common.intl=tw&source.common.mode=adv";
+ String queryString = "tiled?query=india&queryProfile=myprofile&source.common.intl=tw&source.common.mode=adv";
- Query query=new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("myprofile"));
- assertEquals("news",query.properties().listProperties().get("source.common.provider"));
- assertEquals("news",query.properties().get("source.common.provider"));
+ Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("myprofile"));
+ assertEquals("news", query.properties().listProperties().get("source.common.provider"));
+ assertEquals("news", query.properties().get("source.common.provider"));
}
@Test
- public void testNewsCase1() {
+ void testNewsCase1() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase1").compile();
Query query;
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals(0.0, query.properties().get("ranking.features.b"));
assertEquals("0.0", query.properties().listProperties().get("ranking.features.b"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals(0.1, query.properties().get("ranking.features.b"));
assertEquals("0.1", query.properties().listProperties().get("ranking.features.b"));
}
@Test
- public void testNewsCase2() {
+ void testNewsCase2() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase2").compile();
Query query;
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals("0.0", query.properties().get("a.features.b"));
assertEquals("0.0", query.properties().listProperties().get("a.features.b"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals("0.1", query.properties().get("a.features.b"));
assertEquals("0.1", query.properties().listProperties().get("a.features.b"));
}
@Test
- public void testNewsCase3() {
+ void testNewsCase3() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase3").compile();
Query query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET),
- registry.getComponent("default"));
- assertEquals("0.0",query.properties().get("a.features"));
+ registry.getComponent("default"));
+ assertEquals("0.0", query.properties().get("a.features"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET),
- registry.getComponent("default"));
- assertEquals("0.1",query.properties().get("a.features"));
+ registry.getComponent("default"));
+ assertEquals("0.1", query.properties().get("a.features"));
}
@Test
- public void testNewsCase4() {
+ void testNewsCase4() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase4").compile();
Query query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals(0.0, query.properties().get("ranking.features.foo"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals(0.1, query.properties().get("ranking.features.foo"));
}
@Test
- public void testVersionRefs() {
+ void testVersionRefs() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/versionrefs").compile();
Query query = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), registry.getComponent("default"));
@@ -397,14 +393,14 @@ public class XmlReadingTestCase {
}
@Test
- public void testRefOverride() {
+ void testRefOverride() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/refoverride").compile();
{
// Original reference
Query query = new Query(HttpRequest.createTestRequest("?query=test", Method.GET),
- registry.getComponent("default"));
- assertEquals(null, query.properties().get("profileRef"));
+ registry.getComponent("default"));
+ assertNull(query.properties().get("profileRef"));
assertEquals("MyProfile1", query.properties().get("profileRef.name"));
assertEquals("myProfile1Only", query.properties().get("profileRef.myProfile1Only"));
assertNull(query.properties().get("profileRef.myProfile2Only"));
@@ -412,8 +408,8 @@ public class XmlReadingTestCase {
{
// Overridden reference
- Query query = new Query(HttpRequest.createTestRequest("?query=test&profileRef=ref:MyProfile2", Method.GET),registry.getComponent("default"));
- assertEquals(null,query.properties().get("profileRef"));
+ Query query = new Query(HttpRequest.createTestRequest("?query=test&profileRef=ref:MyProfile2", Method.GET), registry.getComponent("default"));
+ assertNull(query.properties().get("profileRef"));
assertEquals("MyProfile2", query.properties().get("profileRef.name"));
assertEquals("myProfile2Only", query.properties().get("profileRef.myProfile2Only"));
assertNull(query.properties().get("profileRef.myProfile1Only"));
@@ -423,20 +419,20 @@ public class XmlReadingTestCase {
assertEquals("newName", query.properties().get("profileRef.name"));
// ...will not impact others
query = new Query(HttpRequest.createTestRequest("?query=test&profileRef=ref:MyProfile2", Method.GET),
- registry.getComponent("default"));
+ registry.getComponent("default"));
assertEquals("MyProfile2", query.properties().get("profileRef.name"));
}
}
@Test
- public void testRefOverrideTyped() {
+ void testRefOverrideTyped() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/refoverridetyped").compile();
{
// Original reference
Query query = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), registry.getComponent("default"));
- assertEquals(null, query.properties().get("profileRef"));
+ assertNull(query.properties().get("profileRef"));
assertEquals("MyProfile1", query.properties().get("profileRef.name"));
assertEquals("myProfile1Only", query.properties().get("profileRef.myProfile1Only"));
assertNull(query.properties().get("profileRef.myProfile2Only"));
@@ -445,7 +441,7 @@ public class XmlReadingTestCase {
{
// Overridden reference
Query query = new Query(HttpRequest.createTestRequest("?query=test&profileRef=MyProfile2", Method.GET), registry.getComponent("default"));
- assertEquals(null, query.properties().get("profileRef"));
+ assertNull(query.properties().get("profileRef"));
assertEquals("MyProfile2", query.properties().get("profileRef.name"));
assertEquals("myProfile2Only", query.properties().get("profileRef.myProfile2Only"));
assertNull(query.properties().get("profileRef.myProfile1Only"));
@@ -461,7 +457,7 @@ public class XmlReadingTestCase {
}
@Test
- public void testAnonymousIdsAreStableBetweenImports() {
+ void testAnonymousIdsAreStableBetweenImports() {
QueryProfileRegistry registry1 = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/typedinheritance");
var childIn1 = registry1.findQueryProfile("child");
var childTypeIn1 = registry1.getType("childType");
@@ -470,50 +466,50 @@ public class XmlReadingTestCase {
var childIn2 = registry2.findQueryProfile("child");
var childTypeIn2 = registry2.getType("childType");
- assertEquals(((QueryProfile)childIn1.lookup("a", Map.of())).getId().stringValue(),
- ((QueryProfile)childIn2.lookup("a", Map.of())).getId().stringValue());
+ assertEquals(((QueryProfile) childIn1.lookup("a", Map.of())).getId().stringValue(),
+ ((QueryProfile) childIn2.lookup("a", Map.of())).getId().stringValue());
assertEquals(childTypeIn1.getType("a").getId().stringValue(),
- childTypeIn2.getType("a").getId().stringValue());
+ childTypeIn2.getType("a").getId().stringValue());
}
@Test
- public void testTensorTypes() {
+ void testTensorTypes() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/tensortypes").compile();
QueryProfileType type1 = registry.getTypeRegistry().getComponent("type1");
assertEquals(TensorType.fromSpec("tensor<float>(x[1])"),
- type1.getFieldType(new CompoundName("ranking.features.query(tensor_1)")).asTensorType());
+ type1.getFieldType(new CompoundName("ranking.features.query(tensor_1)")).asTensorType());
assertNull(type1.getFieldType(new CompoundName("ranking.features.query(tensor_2)")));
assertNull(type1.getFieldType(new CompoundName("ranking.features.query(tensor_3)")));
assertEquals(TensorType.fromSpec("tensor(key{})"),
- type1.getFieldType(new CompoundName("ranking.features.query(tensor_4)")).asTensorType());
+ type1.getFieldType(new CompoundName("ranking.features.query(tensor_4)")).asTensorType());
QueryProfileType type2 = registry.getTypeRegistry().getComponent("type2");
assertNull(type2.getFieldType(new CompoundName("ranking.features.query(tensor_1)")));
assertEquals(TensorType.fromSpec("tensor<float>(x[2])"),
- type2.getFieldType(new CompoundName("ranking.features.query(tensor_2)")).asTensorType());
+ type2.getFieldType(new CompoundName("ranking.features.query(tensor_2)")).asTensorType());
assertEquals(TensorType.fromSpec("tensor<float>(x[3])"),
- type2.getFieldType(new CompoundName("ranking.features.query(tensor_3)")).asTensorType());
+ type2.getFieldType(new CompoundName("ranking.features.query(tensor_3)")).asTensorType());
Query queryProfile1 = new Query.Builder().setQueryProfile(registry.getComponent("profile1"))
- .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
- .build();
- assertEquals("tensor_1 received as a tensor tensor",
- Tensor.from("tensor<float>(x[1]):[1.2]"),
- queryProfile1.properties().get("ranking.features.query(tensor_1)"));
- assertEquals("tensor_4 contained in the profile is a tensor",
- Tensor.from("tensor(key{}):{pre_key1_post:1.0}"),
- queryProfile1.properties().get("ranking.features.query(tensor_4)"));
+ .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
+ .build();
+ assertEquals(Tensor.from("tensor<float>(x[1]):[1.2]"),
+ queryProfile1.properties().get("ranking.features.query(tensor_1)"),
+ "tensor_1 received as a tensor tensor");
+ assertEquals(Tensor.from("tensor(key{}):{pre_key1_post:1.0}"),
+ queryProfile1.properties().get("ranking.features.query(tensor_4)"),
+ "tensor_4 contained in the profile is a tensor");
Query queryProfile2 = new Query.Builder().setQueryProfile(registry.getComponent("profile2"))
- .setEmbedder(new MockEmbedder("text-to-embed",
- Tensor.from("tensor(x[3]):[1, 2, 3]")))
- .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
- .build();
- assertEquals("tensor_1 received as a string as it is not in type2",
- "[1.200]",
- queryProfile2.properties().get("ranking.features.query(tensor_1)"));
+ .setEmbedder(new MockEmbedder("text-to-embed",
+ Tensor.from("tensor(x[3]):[1, 2, 3]")))
+ .setRequest("?query=test&ranking.features.query(tensor_1)=[1.200]")
+ .build();
+ assertEquals("[1.200]",
+ queryProfile2.properties().get("ranking.features.query(tensor_1)"),
+ "tensor_1 received as a string as it is not in type2");
//assertEquals(Tensor.from("tensor(x[3]):[1, 2, 3]"),
// queryProfile2.properties().get("ranking.features.query(tensor_3)"));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java
index 433b87363b3..437d5e3b943 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/CloningTestCase.java
@@ -6,9 +6,9 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.jdisc.http.HttpRequest.Method;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -16,185 +16,185 @@ import static org.junit.Assert.assertEquals;
public class CloningTestCase {
@Test
- public void testCloningWithVariants() {
+ void testCloningWithVariants() {
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] {"x"} );
+ test.setDimensions(new String[]{"x"});
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
- q1.properties().set("a","a1");
+ q1.properties().set("a", "a1");
Query q2 = q1.clone();
- q2.properties().set("a","a2");
- assertEquals("a1",q1.properties().get("a"));
- assertEquals("a2",q2.properties().get("a"));
+ q2.properties().set("a", "a2");
+ assertEquals("a1", q1.properties().get("a"));
+ assertEquals("a2", q2.properties().get("a"));
}
@Test
- public void testShallowCloning() {
+ void testShallowCloning() {
QueryProfile test = new QueryProfile("test");
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- q1.properties().set("a",new MutableString("a1"));
+ q1.properties().set("a", new MutableString("a1"));
Query q2 = q1.clone();
- ((MutableString)q2.properties().get("a")).set("a2");
- assertEquals("a2",q1.properties().get("a").toString());
- assertEquals("a2",q2.properties().get("a").toString());
+ ((MutableString) q2.properties().get("a")).set("a2");
+ assertEquals("a2", q1.properties().get("a").toString());
+ assertEquals("a2", q2.properties().get("a").toString());
}
@Test
- public void testShallowCloningWithVariants() {
+ void testShallowCloningWithVariants() {
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] {"x"} );
+ test.setDimensions(new String[]{"x"});
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
- q1.properties().set("a",new MutableString("a1"));
+ q1.properties().set("a", new MutableString("a1"));
Query q2 = q1.clone();
- ((MutableString)q2.properties().get("a")).set("a2");
- assertEquals("a2",q1.properties().get("a").toString());
- assertEquals("a2",q2.properties().get("a").toString());
+ ((MutableString) q2.properties().get("a")).set("a2");
+ assertEquals("a2", q1.properties().get("a").toString());
+ assertEquals("a2", q2.properties().get("a").toString());
}
@Test
- public void testDeepCloning() {
- QueryProfile test=new QueryProfile("test");
+ void testDeepCloning() {
+ QueryProfile test = new QueryProfile("test");
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- q1.properties().set("a",new CloneableMutableString("a1"));
- Query q2=q1.clone();
- ((MutableString)q2.properties().get("a")).set("a2");
- assertEquals("a1",q1.properties().get("a").toString());
- assertEquals("a2",q2.properties().get("a").toString());
+ q1.properties().set("a", new CloneableMutableString("a1"));
+ Query q2 = q1.clone();
+ ((MutableString) q2.properties().get("a")).set("a2");
+ assertEquals("a1", q1.properties().get("a").toString());
+ assertEquals("a2", q2.properties().get("a").toString());
}
@Test
- public void testDeepCloningWithVariants() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"} );
+ void testDeepCloningWithVariants() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
- q1.properties().set("a",new CloneableMutableString("a1"));
- Query q2=q1.clone();
- ((MutableString)q2.properties().get("a")).set("a2");
- assertEquals("a1",q1.properties().get("a").toString());
- assertEquals("a2",q2.properties().get("a").toString());
+ q1.properties().set("a", new CloneableMutableString("a1"));
+ Query q2 = q1.clone();
+ ((MutableString) q2.properties().get("a")).set("a2");
+ assertEquals("a1", q1.properties().get("a").toString());
+ assertEquals("a2", q2.properties().get("a").toString());
}
@Test
- public void testReAssignment() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"} );
+ void testReAssignment() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
- q1.properties().set("a","a1");
- q1.properties().set("a","a2");
- assertEquals("a2",q1.properties().get("a"));
+ q1.properties().set("a", "a1");
+ q1.properties().set("a", "a2");
+ assertEquals("a2", q1.properties().get("a"));
}
@Test
- public void testThreeLevelsOfCloning() {
+ void testThreeLevelsOfCloning() {
QueryProfile test = new QueryProfile("test");
- test.set("a", "config-a", (QueryProfileRegistry)null);
+ test.set("a", "config-a", (QueryProfileRegistry) null);
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- q1.properties().set("a","q1-a");
- Query q2=q1.clone();
- q2.properties().set("a","q2-a");
- Query q31=q2.clone();
- q31.properties().set("a","q31-a");
- Query q32=q2.clone();
- q32.properties().set("a","q32-a");
-
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
- q2.properties().set("a","q2-a-2");
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a-2",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
+ q1.properties().set("a", "q1-a");
+ Query q2 = q1.clone();
+ q2.properties().set("a", "q2-a");
+ Query q31 = q2.clone();
+ q31.properties().set("a", "q31-a");
+ Query q32 = q2.clone();
+ q32.properties().set("a", "q32-a");
+
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
+ q2.properties().set("a", "q2-a-2");
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a-2", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
}
@Test
- public void testThreeLevelsOfCloningReverseSetOrder() {
+ void testThreeLevelsOfCloningReverseSetOrder() {
QueryProfile test = new QueryProfile("test");
- test.set("a", "config-a", (QueryProfileRegistry)null);
+ test.set("a", "config-a", (QueryProfileRegistry) null);
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- Query q2=q1.clone();
- Query q31=q2.clone();
- Query q32=q2.clone();
- q32.properties().set("a","q32-a");
- q31.properties().set("a","q31-a");
- q2.properties().set("a","q2-a");
- q1.properties().set("a","q1-a");
-
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
- q2.properties().set("a","q2-a-2");
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a-2",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
+ Query q2 = q1.clone();
+ Query q31 = q2.clone();
+ Query q32 = q2.clone();
+ q32.properties().set("a", "q32-a");
+ q31.properties().set("a", "q31-a");
+ q2.properties().set("a", "q2-a");
+ q1.properties().set("a", "q1-a");
+
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
+ q2.properties().set("a", "q2-a-2");
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a-2", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
}
@Test
- public void testThreeLevelsOfCloningMiddleFirstSetOrder1() {
+ void testThreeLevelsOfCloningMiddleFirstSetOrder1() {
QueryProfile test = new QueryProfile("test");
- test.set("a", "config-a", (QueryProfileRegistry)null);
+ test.set("a", "config-a", (QueryProfileRegistry) null);
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- Query q2=q1.clone();
- Query q31=q2.clone();
- Query q32=q2.clone();
- q2.properties().set("a","q2-a");
- q32.properties().set("a","q32-a");
- q31.properties().set("a","q31-a");
- q1.properties().set("a","q1-a");
-
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
- q2.properties().set("a","q2-a-2");
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a-2",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("q32-a",q32.properties().get("a").toString());
+ Query q2 = q1.clone();
+ Query q31 = q2.clone();
+ Query q32 = q2.clone();
+ q2.properties().set("a", "q2-a");
+ q32.properties().set("a", "q32-a");
+ q31.properties().set("a", "q31-a");
+ q1.properties().set("a", "q1-a");
+
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
+ q2.properties().set("a", "q2-a-2");
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a-2", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("q32-a", q32.properties().get("a").toString());
}
@Test
- public void testThreeLevelsOfCloningMiddleFirstSetOrder2() {
+ void testThreeLevelsOfCloningMiddleFirstSetOrder2() {
QueryProfile test = new QueryProfile("test");
- test.set("a", "config-a", (QueryProfileRegistry)null);
+ test.set("a", "config-a", (QueryProfileRegistry) null);
test.freeze();
Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
- Query q2=q1.clone();
- Query q31=q2.clone();
- Query q32=q2.clone();
- q2.properties().set("a","q2-a");
- q31.properties().set("a","q31-a");
- q1.properties().set("a","q1-a");
-
- assertEquals("q1-a",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("config-a",q32.properties().get("a").toString());
- q1.properties().set("a","q1-a-2");
- assertEquals("q1-a-2",q1.properties().get("a").toString());
- assertEquals("q2-a",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("config-a",q32.properties().get("a").toString());
- q2.properties().set("a","q2-a-2");
- assertEquals("q1-a-2",q1.properties().get("a").toString());
- assertEquals("q2-a-2",q2.properties().get("a").toString());
- assertEquals("q31-a",q31.properties().get("a").toString());
- assertEquals("config-a",q32.properties().get("a").toString());
+ Query q2 = q1.clone();
+ Query q31 = q2.clone();
+ Query q32 = q2.clone();
+ q2.properties().set("a", "q2-a");
+ q31.properties().set("a", "q31-a");
+ q1.properties().set("a", "q1-a");
+
+ assertEquals("q1-a", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("config-a", q32.properties().get("a").toString());
+ q1.properties().set("a", "q1-a-2");
+ assertEquals("q1-a-2", q1.properties().get("a").toString());
+ assertEquals("q2-a", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("config-a", q32.properties().get("a").toString());
+ q2.properties().set("a", "q2-a-2");
+ assertEquals("q1-a-2", q1.properties().get("a").toString());
+ assertEquals("q2-a-2", q2.properties().get("a").toString());
+ assertEquals("q31-a", q31.properties().get("a").toString());
+ assertEquals("config-a", q32.properties().get("a").toString());
}
public static class MutableString {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java
index 0fca7a566e2..62ed8413d92 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/DimensionBindingTestCase.java
@@ -2,14 +2,14 @@
package com.yahoo.search.query.profile.test;
import com.yahoo.search.query.profile.DimensionBinding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -17,47 +17,47 @@ import static org.junit.Assert.*;
public class DimensionBindingTestCase {
@Test
- public void testCombining() {
+ void testCombining() {
assertEquals(binding("a, b, c", "a=1", "b=1", "c=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("c", "c=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("c", "c=1")));
assertEquals(binding("a, b, c", "a=1", "b=1", "c=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("a, c", "a=1", "c=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("a, c", "a=1", "c=1")));
assertEquals(binding("c, a, b", "c=1", "a=1", "b=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("c, a", "a=1", "c=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("c, a", "a=1", "c=1")));
assertEquals(binding("a, b", "a=1", "b=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("a, b", "a=1", "b=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("a, b", "a=1", "b=1")));
assertEquals(DimensionBinding.invalidBinding,
- binding("a, b", "a=1", "b=1").combineWith(binding("b, a", "a=1", "b=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("b, a", "a=1", "b=1")));
assertEquals(binding("a, b", "a=1", "b=1"),
- binding("a, b", "a=1", "b=1").combineWith(binding("b", "b=1")));
+ binding("a, b", "a=1", "b=1").combineWith(binding("b", "b=1")));
assertEquals(binding("a, b, c", "a=1", "b=1", "c=1"),
- binding("a, b, c", "a=1", "c=1").combineWith(binding("a, b, c", "a=1", "b=1", "c=1")));
+ binding("a, b, c", "a=1", "c=1").combineWith(binding("a, b, c", "a=1", "b=1", "c=1")));
assertEquals(binding("a, b, c", "a=1", "b=1", "c=1"),
- binding("a, c", "a=1", "c=1").combineWith(binding("a, b, c", "a=1", "b=1", "c=1")));
+ binding("a, c", "a=1", "c=1").combineWith(binding("a, b, c", "a=1", "b=1", "c=1")));
}
// found DimensionBinding [custid_1=yahoo, custid_2=ca, custid_3=sc, custid_4=null, custid_5=null, custid_6=null], combined with DimensionBinding [custid_1=yahoo, custid_2=null, custid_3=sc, custid_4=null, custid_5=null, custid_6=null] to Invalid DimensionBinding
@Test
- public void testCombiningBindingsWithNull() {
+ void testCombiningBindingsWithNull() {
List<String> dimensions = list("a,b");
Map<String, String> map1 = new HashMap<>();
- map1.put("a","a1");
- map1.put("b","b1");
+ map1.put("a", "a1");
+ map1.put("b", "b1");
Map<String, String> map2 = new HashMap<>();
- map2.put("a","a1");
- map2.put("b",null);
+ map2.put("a", "a1");
+ map2.put("b", null);
assertEquals(DimensionBinding.createFrom(dimensions, map1),
- DimensionBinding.createFrom(dimensions, map1).combineWith(DimensionBinding.createFrom(dimensions, map2)));
+ DimensionBinding.createFrom(dimensions, map1).combineWith(DimensionBinding.createFrom(dimensions, map2)));
}
private DimensionBinding binding(String dimensions, String ... dimensionPoints) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java
index 3ed044601f0..00e48a639c1 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.search.query.profile.test;
import com.yahoo.search.query.profile.DumpTool;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -14,28 +14,28 @@ public class DumpToolTestCase {
private final String profileDir = "src/test/java/com/yahoo/search/query/profile/config/test/multiprofile";
@Test
- public void testNoParameters() {
+ void testNoParameters() {
assertTrue(new DumpTool().resolveAndDump().startsWith("Dumps all resolved"));
}
@Test
- public void testHelpParameter() {
+ void testHelpParameter() {
assertTrue(new DumpTool().resolveAndDump("-help").startsWith("Dumps all resolved"));
}
@Test
- public void testNoDimensionValues() {
+ void testNoDimensionValues() {
System.out.println(new DumpTool().resolveAndDump("multiprofile1", profileDir));
assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir).contains("a=general-a\n"));
}
@Test
- public void testAllParametersSet() {
+ void testAllParametersSet() {
assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir, "").contains("a=general-a\n"));
}
@Test
- public void testVariant() {
+ void testVariant() {
String result = new DumpTool().resolveAndDump("multiprofile1", profileDir, "region=us");
assertTrue(result.contains("a=us-a"));
assertTrue(result.contains("b=us-b"));
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java
index 7a92aa8081b..6a9896188f9 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryFromProfileTestCase.java
@@ -8,9 +8,9 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Test using the profile to set the query to execute
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
public class QueryFromProfileTestCase {
@Test
- public void testQueryFromProfile1() {
+ void testQueryFromProfile1() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile topLevel = new QueryProfile("topLevel");
topLevel.setType(registry.getTypeRegistry().getComponent("native"));
@@ -39,7 +39,7 @@ public class QueryFromProfileTestCase {
}
@Test
- public void testQueryFromProfile2() {
+ void testQueryFromProfile2() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType rootType = new QueryProfileType("root");
rootType.inherited().add(registry.getTypeRegistry().getComponent("native"));
@@ -49,7 +49,7 @@ public class QueryFromProfileTestCase {
root.setType(rootType);
registry.register(root);
- QueryProfile queryBest=new QueryProfile("querybest");
+ QueryProfile queryBest = new QueryProfile("querybest");
queryBest.setType(registry.getTypeRegistry().getComponent("model"));
queryBest.set("queryString", "best", registry);
registry.register(queryBest);
@@ -62,7 +62,7 @@ public class QueryFromProfileTestCase {
}
@Test
- public void testQueryFromProfile3() {
+ void testQueryFromProfile3() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType rootType = new QueryProfileType("root");
rootType.inherited().add(registry.getTypeRegistry().getComponent("native"));
@@ -72,7 +72,7 @@ public class QueryFromProfileTestCase {
root.setType(rootType);
registry.register(root);
- QueryProfile queryBest=new QueryProfile("querybest");
+ QueryProfile queryBest = new QueryProfile("querybest");
queryBest.setType(registry.getTypeRegistry().getComponent("model"));
queryBest.set("queryString", "best", registry);
registry.register(queryBest);
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java
index 2173d72cab9..9c162df02bf 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileSubstitutionTestCase.java
@@ -6,10 +6,10 @@ import com.yahoo.yolean.Exceptions;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileProperties;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author bratseth
@@ -17,17 +17,17 @@ import static org.junit.Assert.fail;
public class QueryProfileSubstitutionTestCase {
@Test
- public void testSubstitutionOnly() {
+ void testSubstitutionOnly() {
QueryProfile p = new QueryProfile("test");
- p.set("message","%{world}", null);
+ p.set("message", "%{world}", null);
p.set("world", "world", null);
assertEquals("world", p.compile(null).get("message"));
}
@Test
- public void testSingleSubstitution() {
+ void testSingleSubstitution() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{world}!", null);
+ p.set("message", "Hello %{world}!", null);
p.set("world", "world", null);
assertEquals("Hello world!", p.compile(null).get("message"));
@@ -38,15 +38,15 @@ public class QueryProfileSubstitutionTestCase {
}
@Test
- public void testRelativeSubstitution() {
+ void testRelativeSubstitution() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{.world}!", null);
+ p.set("message", "Hello %{.world}!", null);
p.set("world", "world", null);
assertEquals("Hello world!", p.compile(null).get("message"));
}
@Test
- public void testRelativeSubstitutionNotFound() {
+ void testRelativeSubstitutionNotFound() {
try {
QueryProfile p = new QueryProfile("test");
p.set("message", "Hello %{.world}!", null);
@@ -55,80 +55,80 @@ public class QueryProfileSubstitutionTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("Invalid query profile 'test': Could not resolve local substitution 'world' in variant []",
- Exceptions.toMessageString(e));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testMultipleSubstitutions() {
+ void testMultipleSubstitutions() {
QueryProfile p = new QueryProfile("test");
- p.set("message","%{greeting} %{entity}%{exclamation}", null);
- p.set("greeting","Hola", null);
- p.set("entity","local group", null);
- p.set("exclamation","?", null);
+ p.set("message", "%{greeting} %{entity}%{exclamation}", null);
+ p.set("greeting", "Hola", null);
+ p.set("entity", "local group", null);
+ p.set("exclamation", "?", null);
assertEquals("Hola local group?", p.compile(null).get("message"));
QueryProfile p2 = new QueryProfile("test2");
p2.addInherited(p);
- p2.set("entity","milky way", null);
+ p2.set("entity", "milky way", null);
assertEquals("Hola milky way?", p2.compile(null).get("message"));
}
@Test
- public void testUnclosedSubstitution1() {
+ void testUnclosedSubstitution1() {
try {
QueryProfile p = new QueryProfile("test");
- p.set("message1","%{greeting} %{entity}%{exclamation", null);
+ p.set("message1", "%{greeting} %{entity}%{exclamation", 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));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testUnclosedSubstitution2() {
+ void testUnclosedSubstitution2() {
try {
QueryProfile p = new QueryProfile("test");
- p.set("message1","%{greeting} %{entity%{exclamation}", null);
+ p.set("message1", "%{greeting} %{entity%{exclamation}", 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));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testNullSubstitution() {
+ void testNullSubstitution() {
QueryProfile p = new QueryProfile("test");
- p.set("message","%{greeting} %{entity}%{exclamation}", null);
- p.set("greeting","Hola", null);
+ p.set("message", "%{greeting} %{entity}%{exclamation}", null);
+ p.set("greeting", "Hola", null);
assertEquals("Hola ", p.compile(null).get("message"));
QueryProfile p2 = new QueryProfile("test2");
p2.addInherited(p);
- p2.set("greeting","Hola", null);
+ p2.set("greeting", "Hola", null);
p2.set("exclamation", "?", null);
assertEquals("Hola ?", p2.compile(null).get("message"));
}
@Test
- public void testNoOverridingOfPropertiesSetAtRuntime() {
+ void testNoOverridingOfPropertiesSetAtRuntime() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{world}!", null);
- p.set("world","world", null);
+ p.set("message", "Hello %{world}!", null);
+ p.set("world", "world", null);
p.freeze();
Properties runtime = new QueryProfileProperties(p.compile(null));
- runtime.set("runtimeMessage","Hello %{world}!");
+ runtime.set("runtimeMessage", "Hello %{world}!");
assertEquals("Hello world!", runtime.get("message"));
- assertEquals("Hello %{world}!",runtime.get("runtimeMessage"));
+ assertEquals("Hello %{world}!", runtime.get("runtimeMessage"));
}
@Test
- public void testButPropertiesSetAtRuntimeAreUsedInSubstitutions() {
+ void testButPropertiesSetAtRuntimeAreUsedInSubstitutions() {
QueryProfile p = new QueryProfile("test");
p.set("message", "Hello %{world}!", null);
p.set("world", "world", null);
@@ -139,21 +139,22 @@ public class QueryProfileSubstitutionTestCase {
}
@Test
- public void testInspection() {
+ void testInspection() {
QueryProfile p = new QueryProfile("test");
p.set("message", "%{greeting} %{entity}%{exclamation}", null);
- assertEquals("message","%{greeting} %{entity}%{exclamation}",
- p.declaredContent().entrySet().iterator().next().getValue().toString());
+ assertEquals("%{greeting} %{entity}%{exclamation}",
+ p.declaredContent().entrySet().iterator().next().getValue().toString(),
+ "message");
}
@Test
- public void testVariants() {
+ void testVariants() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{world}!", null);
- p.set("world","world", null);
- p.setDimensions(new String[] {"x"});
- p.set("message","Halo %{world}!",new String[] {"x1"}, null);
- p.set("world","Europe",new String[] {"x2"}, null);
+ p.set("message", "Hello %{world}!", null);
+ p.set("world", "world", null);
+ p.setDimensions(new String[]{"x"});
+ p.set("message", "Halo %{world}!", new String[]{"x1"}, null);
+ p.set("world", "Europe", new String[]{"x2"}, null);
CompiledQueryProfile cp = p.compile(null);
assertEquals("Hello world!", cp.get("message", QueryProfileVariantsTestCase.toMap("x=x?")));
@@ -162,12 +163,12 @@ public class QueryProfileSubstitutionTestCase {
}
@Test
- public void testRecursion() {
+ void testRecursion() {
QueryProfile p = new QueryProfile("test");
- p.set("message","Hello %{world}!", null);
- p.set("world","sol planet number %{number}", null);
- p.set("number",3, null);
- assertEquals("Hello sol planet number 3!",p.compile(null).get("message"));
+ p.set("message", "Hello %{world}!", null);
+ p.set("world", "sol planet number %{number}", null);
+ p.set("number", 3, null);
+ assertEquals("Hello sol planet number 3!", p.compile(null).get("message"));
}
}
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 39ed9b829d2..7a4247f2584 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
@@ -13,7 +13,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.search.query.profile.compiled.ValueWithSource;
import com.yahoo.yolean.trace.TraceNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -21,11 +21,7 @@ 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;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests untyped query profiles
@@ -35,60 +31,60 @@ import static org.junit.Assert.fail;
public class QueryProfileTestCase {
@Test
- public void testBasics() {
+ void testBasics() {
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);
+ 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);
- assertEquals("a-value",cprofile.get("a"));
- assertEquals("b.c-value",cprofile.get("b.c"));
- assertEquals("d.e.f-value",cprofile.get("d.e.f"));
+ assertEquals("a-value", cprofile.get("a"));
+ assertEquals("b.c-value", cprofile.get("b.c"));
+ assertEquals("d.e.f-value", cprofile.get("d.e.f"));
assertNull(cprofile.get("nonexistent"));
assertNull(cprofile.get("nested.nonexistent"));
- assertTrue(profile.lookup("b",null).getClass()==QueryProfile.class);
- assertTrue(profile.lookup("b",null).getClass()==QueryProfile.class);
+ assertEquals(profile.lookup("b", null).getClass(), QueryProfile.class);
+ assertEquals(profile.lookup("b", null).getClass(), QueryProfile.class);
}
/** Tests cloning, with wrappers used in production in place */
@Test
- public void testCloning() {
+ void testCloning() {
QueryProfile classProfile = new QueryProfile("test");
- classProfile.set("a","aValue", null);
- classProfile.set("b",3, null);
+ classProfile.set("a", "aValue", null);
+ classProfile.set("b", 3, null);
Properties properties = new QueryProfileProperties(classProfile.compile(null));
- Properties propertiesClone=properties.clone();
- assertEquals("aValue",propertiesClone.get("a"));
- assertEquals(3,propertiesClone.get("b"));
- properties.set("a","aNewValue");
- assertEquals("aNewValue",properties.get("a"));
- assertEquals("aValue",propertiesClone.get("a"));
+ Properties propertiesClone = properties.clone();
+ assertEquals("aValue", propertiesClone.get("a"));
+ assertEquals(3, propertiesClone.get("b"));
+ properties.set("a", "aNewValue");
+ assertEquals("aNewValue", properties.get("a"));
+ assertEquals("aValue", propertiesClone.get("a"));
}
@Test
- public void testFreezing() {
+ void testFreezing() {
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);
+ 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"));
+ assertEquals("a-value", profile.get("a"));
profile.freeze();
assertTrue(profile.isFrozen());
- assertTrue(((QueryProfile)profile.lookup("b",null)).isFrozen());
- assertTrue(((QueryProfile)profile.lookup("d.e",null)).isFrozen());
+ assertTrue(((QueryProfile) profile.lookup("b", null)).isFrozen());
+ assertTrue(((QueryProfile) profile.lookup("d.e", null)).isFrozen());
try {
- profile.set("a","value", null);
+ profile.set("a", "value", null);
fail("Expected exception");
}
catch (IllegalStateException e) {
@@ -97,15 +93,15 @@ public class QueryProfileTestCase {
private void assertSameObjects(CompiledQueryProfile profile, String path, List<String> expectedKeys) {
Map<String, Object> subObjects = profile.listValues(path);
- assertEquals("Sub-objects list equal for path " + path, new HashSet<>(expectedKeys), subObjects.keySet());
+ assertEquals(new HashSet<>(expectedKeys), subObjects.keySet(), "Sub-objects list equal for path " + path);
for(String key : expectedKeys) {
- assertEquals("Equal for key " + key, profile.get(key),subObjects.get(path + "." + key));
+ assertEquals(profile.get(key),subObjects.get(path + "." + key),"Equal for key " + key);
}
}
@Test
- public void testGetSubObjects() {
+ void testGetSubObjects() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -117,21 +113,21 @@ public class QueryProfileTestCase {
far.addInherited(farfar);
barn.addInherited(mor);
barn.addInherited(far);
- mormor.set("a.mormor","a.mormor", null);
- barn.set("a.barn","a.barn", 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);
+ far.set("a.far", "a.far", null);
CompiledQueryProfile cbarn = barn.compile(null);
- assertSameObjects(cbarn, "a", Arrays.asList("mormor","far","barn"));
+ assertSameObjects(cbarn, "a", Arrays.asList("mormor", "far", "barn"));
assertEquals("b.mor", cbarn.get("b.mor"));
assertEquals("b.far", cbarn.get("b.far"));
}
@Test
- public void testInheritance() {
+ void testInheritance() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -144,24 +140,24 @@ public class QueryProfileTestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- 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);
+ 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", null);
- far.set("b","far-b", 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);
+ mor.set("c", "mor-c", null);
+ far.set("c", "far-c", null);
- mor.set("d.a","mor-d.a", null);
- barn.set("d.b","barn-d.b", 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, null);
+ QueryProfile annetBarn = new QueryProfile("annetBarn");
+ annetBarn.set("venn", barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -179,7 +175,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testInheritance2Level() {
+ void testInheritance2Level() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -192,24 +188,24 @@ public class QueryProfileTestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- 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);
+ 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", null);
- far.set("b.x","far-b", null);
+ mormor.set("b.x", "mormor-b", null);
+ far.set("b.x", "far-b", null);
- mor.set("c.x","mor-c", null);
- far.set("c.x","far-c", null);
+ mor.set("c.x", "mor-c", null);
+ far.set("c.x", "far-c", null);
- mor.set("d.a.x","mor-d.a", null);
- barn.set("d.b.x","barn-d.b", 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, null);
+ QueryProfile annetBarn = new QueryProfile("annetBarn");
+ annetBarn.set("venn", barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -227,7 +223,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testInheritance3Level() {
+ void testInheritance3Level() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -240,24 +236,24 @@ public class QueryProfileTestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- 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);
+ 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", null);
- far.set("y.b.x","far-b", null);
+ mormor.set("y.b.x", "mormor-b", null);
+ far.set("y.b.x", "far-b", null);
- mor.set("y.c.x","mor-c", null);
- far.set("y.c.x","far-c", 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", null);
- barn.set("y.d.b.x","barn-d.b", 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, null);
+ QueryProfile annetBarn = new QueryProfile("annetBarn");
+ annetBarn.set("venn", barn, null);
CompiledQueryProfile cbarn = barn.compile(null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
@@ -275,7 +271,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testListProperties() {
+ void testListProperties() {
QueryProfile barn = new QueryProfile("barn");
QueryProfile mor = new QueryProfile("mor");
QueryProfile far = new QueryProfile("far");
@@ -288,18 +284,18 @@ public class QueryProfileTestCase {
mor.addInherited(morfar);
far.addInherited(farfar);
- 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);
+ 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);
@@ -316,8 +312,8 @@ public class QueryProfileTestCase {
Map<String, Object> modelMap = properties.listProperties("model");
assertEquals("mormor-model.b", modelMap.get("b"));
- QueryProfile annetBarn=new QueryProfile("annetBarn");
- annetBarn.set("venn", barn, (QueryProfileRegistry)null);
+ QueryProfile annetBarn = new QueryProfile("annetBarn");
+ annetBarn.set("venn", barn, (QueryProfileRegistry) null);
CompiledQueryProfile cannetBarn = annetBarn.compile(null);
Map<String, Object> annetBarnMap = new QueryProfileProperties(cannetBarn).listProperties();
@@ -329,12 +325,12 @@ public class QueryProfileTestCase {
/** Dots are followed when setting overridability */
@Test
- public void testInstanceOverridable() {
+ void testInstanceOverridable() {
QueryProfile profile = new QueryProfile("root/unoverridableIndex");
- profile.set("model.defaultIndex","default", null);
+ profile.set("model.defaultIndex", "default", null);
profile.setOverridable("model.defaultIndex", false, DimensionValues.empty);
- assertFalse(profile.isDeclaredOverridable("model.defaultIndex",null));
+ assertFalse(profile.isDeclaredOverridable("model.defaultIndex", null));
// Parameters should be ignored
Query query = new Query(HttpRequest.createTestRequest("?model.defaultIndex=title", Method.GET), profile.compile(null));
@@ -348,13 +344,13 @@ public class QueryProfileTestCase {
/** Dots are followed when setting overridability, also with variants */
@Test
- public void testInstanceOverridableWithVariants() {
+ void testInstanceOverridableWithVariants() {
QueryProfile profile = new QueryProfile("root/unoverridableIndex");
- profile.setDimensions(new String[] {"x"});
- profile.set("model.defaultIndex","default", null);
+ profile.setDimensions(new String[]{"x"});
+ profile.set("model.defaultIndex", "default", null);
profile.setOverridable("model.defaultIndex", false, DimensionValues.empty);
- assertFalse(profile.isDeclaredOverridable("model.defaultIndex",null));
+ assertFalse(profile.isDeclaredOverridable("model.defaultIndex", null));
// Parameters should be ignored
Query query = new Query(HttpRequest.createTestRequest("?x=x1&model.defaultIndex=title", Method.GET), profile.compile(null));
@@ -367,47 +363,47 @@ public class QueryProfileTestCase {
}
@Test
- public void testSimpleInstanceOverridableWithVariants1() {
- QueryProfile profile=new QueryProfile("test");
- profile.setDimensions(new String[] {"x"});
- profile.set("a","original", null);
+ void testSimpleInstanceOverridableWithVariants1() {
+ QueryProfile profile = new QueryProfile("test");
+ profile.setDimensions(new String[]{"x"});
+ profile.set("a", "original", null);
profile.setOverridable("a", false, DimensionValues.empty);
- assertFalse(profile.isDeclaredOverridable("a",null));
+ assertFalse(profile.isDeclaredOverridable("a", null));
Query query = new Query(HttpRequest.createTestRequest("?x=x1&a=overridden", Method.GET), profile.compile(null));
assertEquals("original", query.properties().get("a"));
}
@Test
- public void testSimpleInstanceOverridableWithVariants2() {
+ void testSimpleInstanceOverridableWithVariants2() {
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"x"});
- profile.set("a", "original", new String[] {"x1"}, null);
+ profile.setDimensions(new String[]{"x"});
+ profile.set("a", "original", new String[]{"x1"}, null);
profile.setOverridable("a", false, DimensionValues.empty);
assertFalse(profile.isDeclaredOverridable("a", null));
Query query = new Query(HttpRequest.createTestRequest("?x=x1&a=overridden", Method.GET), profile.compile(null));
- assertEquals("original",query.properties().get("a"));
+ assertEquals("original", query.properties().get("a"));
}
/** Tests having both an explicit reference and an override */
@Test
- public void testExplicitReferenceOverride() {
+ void testExplicitReferenceOverride() {
QueryProfile a1 = new QueryProfile("a1");
- a1.set("b","a1.b", null);
+ a1.set("b", "a1.b", null);
QueryProfile profile = new QueryProfile("test");
- profile.set("a",a1, null);
- profile.set("a.b","a.b", 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", null);
- p.set("a.b","a.b-value", null);
+ void testSettingNonLeaf1() {
+ QueryProfile p = new QueryProfile("test");
+ 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"));
@@ -415,10 +411,10 @@ public class QueryProfileTestCase {
}
@Test
- public void testSettingNonLeaf2() {
+ void testSettingNonLeaf2() {
QueryProfile p = new QueryProfile("test");
- p.set("a.b","a.b-value", null);
- p.set("a","a-value", 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"));
@@ -426,48 +422,48 @@ public class QueryProfileTestCase {
}
@Test
- public void testSettingNonLeaf3a() {
+ void testSettingNonLeaf3a() {
QueryProfile p = new QueryProfile("test");
- p.setDimensions(new String[] {"x"});
- p.set("a.b","a.b-value", null);
- p.set("a","a-value",new String[] {"x1"}, null);
+ p.setDimensions(new String[]{"x"});
+ p.set("a.b", "a.b-value", null);
+ p.set("a", "a-value", new String[]{"x1"}, null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertNull(p.get("a"));
assertEquals("a.b-value", cp.get("a.b"));
- assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
- assertEquals("a.b-value", cp.get("a.b", new String[] {"x1"}));
+ assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
+ assertEquals("a.b-value", cp.get("a.b", new String[]{"x1"}));
}
@Test
- public void testSettingNonLeaf3b() {
+ 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", null);
+ p.setDimensions(new String[]{"x"});
+ p.set("a", "a-value", new String[]{"x1"}, null);
+ p.set("a.b", "a.b-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertNull(cp.get("a"));
assertEquals("a.b-value", cp.get("a.b"));
- assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
- assertEquals("a.b-value", cp.get("a.b",new String[] {"x1"}));
+ assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
+ assertEquals("a.b-value", cp.get("a.b", new String[]{"x1"}));
}
@Test
- public void testSettingNonLeaf4a() {
+ 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", null);
+ p.setDimensions(new String[]{"x"});
+ p.set("a.b", "a.b-value", new String[]{"x1"}, null);
+ p.set("a", "a-value", null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertEquals("a-value", cp.get("a"));
assertNull(cp.get("a.b"));
- assertEquals("a-value", cp.get("a",new String[] {"x1"}));
- assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
+ assertEquals("a-value", cp.get("a", new String[]{"x1"}));
+ assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
}
public void testSettingNonLeaf4b() {
@@ -485,36 +481,36 @@ public class QueryProfileTestCase {
}
@Test
- public void testSettingNonLeaf5() {
+ void testSettingNonLeaf5() {
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",new String[] {"x1"}, null);
+ p.setDimensions(new String[]{"x"});
+ p.set("a.b", "a.b-value", new String[]{"x1"}, null);
+ p.set("a", "a-value", new String[]{"x1"}, null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertNull(cp.get("a"));
assertNull(cp.get("a.b"));
- assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
- assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[] {"x1"})));
+ assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
+ assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[]{"x1"})));
}
@Test
- public void testListingWithNonLeafs() {
+ void testListingWithNonLeafs() {
QueryProfile p = new QueryProfile("test");
- p.set("a","a-value", null);
- p.set("a.b","a.b-value", 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(2, values.size());
- p.set("a","a-value", null);
+ p.set("a", "a-value", null);
assertEquals("a.b-value", values.get("b"));
}
@Test
- public void testListingSources() {
+ void testListingSources() {
QueryProfile p = new QueryProfile("test");
- p.set("a","a-value", null);
- p.set("a.b","a.b-value", null);
+ p.set("a", "a-value", null);
+ p.set("a.b", "a.b-value", null);
{
Map<String, ValueWithSource> values = p.compile(null).listValuesWithSources(new CompoundName(""), new HashMap<>(), null);
@@ -534,30 +530,30 @@ public class QueryProfileTestCase {
}
@Test
- public void testRankTypeNames() {
- QueryProfile p = new QueryProfile("test");
- 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"));
- assertEquals("bar", cp.get("a.query(b)"));
- assertEquals("fuu", cp.get("a.b.default-index"));
-
- Map<String,Object> p1 = cp.listValues("");
- assertEquals("foo", p1.get("a.$b"));
- assertEquals("bar", p1.get("a.query(b)"));
- assertEquals("fuu", p1.get("a.b.default-index"));
-
- Map<String,Object> p2 = cp.listValues("a");
- assertEquals("foo", p2.get("$b"));
- assertEquals("bar", p2.get("query(b)"));
- assertEquals("fuu", p2.get("b.default-index"));
+ void testRankTypeNames() {
+ QueryProfile p = new QueryProfile("test");
+ 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"));
+ assertEquals("bar", cp.get("a.query(b)"));
+ assertEquals("fuu", cp.get("a.b.default-index"));
+
+ Map<String, Object> p1 = cp.listValues("");
+ assertEquals("foo", p1.get("a.$b"));
+ assertEquals("bar", p1.get("a.query(b)"));
+ assertEquals("fuu", p1.get("a.b.default-index"));
+
+ Map<String, Object> p2 = cp.listValues("a");
+ assertEquals("foo", p2.get("$b"));
+ assertEquals("bar", p2.get("query(b)"));
+ assertEquals("fuu", p2.get("b.default-index"));
}
@Test
- public void testQueryProfileInlineValueReassignment() {
+ void testQueryProfileInlineValueReassignment() {
QueryProfile p = new QueryProfile("test");
p.set("source.rel.params.query", "%{model.queryString}", null);
p.freeze();
@@ -570,9 +566,9 @@ public class QueryProfileTestCase {
}
@Test
- public void testQueryProfileInlineValueReassignmentSimpleName() {
+ void testQueryProfileInlineValueReassignmentSimpleName() {
QueryProfile p = new QueryProfile("test");
- p.set("key","%{model.queryString}", 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"));
@@ -583,7 +579,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testQueryProfileInlineValueReassignmentSimpleNameGenericProperty() {
+ void testQueryProfileInlineValueReassignmentSimpleNameGenericProperty() {
QueryProfile p = new QueryProfile("test");
p.set("key", "%{value}", null);
p.freeze();
@@ -596,7 +592,7 @@ public class QueryProfileTestCase {
}
@Test
- public void testQueryProfileModelValueListing() {
+ void testQueryProfileModelValueListing() {
QueryProfile p = new QueryProfile("test");
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?query=bar", Method.GET), p.compile(null));
@@ -608,21 +604,21 @@ public class QueryProfileTestCase {
}
@Test
- public void testEmptyBoolean() {
+ void testEmptyBoolean() {
QueryProfile p = new QueryProfile("test");
- p.setDimensions(new String[] {"x","y"});
- p.set("clustering.something","bar", null);
- p.set("clustering.something","bar", new String[] {"x1","y1"}, null);
+ p.setDimensions(new String[]{"x", "y"});
+ 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=-" +
- "7d/3h&clustering.timeline.tophit=false&clustering.timeli" +
- "ne=true", Method.GET), p.compile(null));
+ "clustering.enable=true&clustering.timeline.bucketspec=-" +
+ "7d/3h&clustering.timeline.tophit=false&clustering.timeli" +
+ "ne=true", Method.GET), p.compile(null));
assertTrue(q.properties().getBoolean("clustering.timeline", false));
}
@Test
- public void testSubstitutionInTrace() {
+ void testSubstitutionInTrace() {
QueryProfile profile = new QueryProfile("test");
profile.set("property", "%{foo}", null);
CompiledQueryProfile cProfile = profile.compile(null);
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java
index 3e1a101628c..43078db66d0 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsCloneTestCase.java
@@ -5,13 +5,13 @@ package com.yahoo.search.query.profile.test;
import com.yahoo.search.query.profile.DimensionValues;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Tony Vaagenes
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals;
public class QueryProfileVariantsCloneTestCase {
@Test
- public void test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning() {
+ 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");
@@ -32,10 +32,10 @@ public class QueryProfileVariantsCloneTestCase {
CompiledQueryProfile clone = profile.compile(null).clone();
assertEquals(profile.get("interior", dimensionBinding, null),
- clone.get("interior", dimensionBinding));
+ clone.get("interior", dimensionBinding));
assertEquals(profile.get("interior.leaf", dimensionBinding, null),
- clone.get("interior.leaf", dimensionBinding));
+ clone.get("interior.leaf", dimensionBinding));
}
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 3cf2949f33c..1a6cfee75a5 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
@@ -19,8 +19,8 @@ import com.yahoo.search.query.profile.QueryProfileVariant;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.ValueWithSource;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.HashMap;
@@ -28,9 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -38,75 +36,75 @@ import static org.junit.Assert.assertTrue;
public class QueryProfileVariantsTestCase {
@Test
- public void testSimple() {
+ void testSimple() {
QueryProfile profile = new QueryProfile("a");
- 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);
- profile.set("a","a.1.*.5", new String[] {"x1",null,"z5"}, null);
- profile.set("a","a.1.1.*", new String[] {"x1","y1",null}, null);
- profile.set("a","a.1.5.*", new String[] {"x1","y5",null}, null);
- profile.set("a","a.1.1.1", new String[] {"x1","y1","z1"}, null);
- profile.set("a","a.2.1.1", new String[] {"x2","y1","z1"}, null);
- profile.set("a","a.1.2.2", new String[] {"x1","y2","z2"}, null);
- profile.set("a","a.1.2.3", new String[] {"x1","y2","z3"}, null);
- profile.set("a","a.2.*.*", new String[] {"x2" }, null); // Same as ,null,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);
+ profile.set("a", "a.1.*.5", new String[]{"x1", null, "z5"}, null);
+ profile.set("a", "a.1.1.*", new String[]{"x1", "y1", null}, null);
+ profile.set("a", "a.1.5.*", new String[]{"x1", "y5", null}, null);
+ profile.set("a", "a.1.1.1", new String[]{"x1", "y1", "z1"}, null);
+ profile.set("a", "a.2.1.1", new String[]{"x2", "y1", "z1"}, null);
+ profile.set("a", "a.1.2.2", new String[]{"x1", "y2", "z2"}, null);
+ profile.set("a", "a.1.2.3", new String[]{"x1", "y2", "z3"}, null);
+ profile.set("a", "a.2.*.*", new String[]{"x2" }, null); // Same as ,null,null
CompiledQueryProfile cprofile = profile.compile(null);
// Perfect matches
- assertGet("a.deflt","a", new String[] {null,null,null}, profile, cprofile);
- assertGet("a.1.*.*","a", new String[] {"x1",null,null}, profile, cprofile);
- assertGet("a.1.1.*","a", new String[] {"x1","y1",null}, profile, cprofile);
- assertGet("a.1.5.*","a", new String[] {"x1","y5",null}, profile, cprofile);
- assertGet("a.1.*.1","a", new String[] {"x1",null,"z1"}, profile, cprofile);
- assertGet("a.1.*.5","a", new String[] {"x1",null,"z5"}, profile, cprofile);
- assertGet("a.1.1.1","a", new String[] {"x1","y1","z1"}, profile, cprofile);
- assertGet("a.2.1.1","a", new String[] {"x2","y1","z1"}, profile, cprofile);
- assertGet("a.1.2.2","a", new String[] {"x1","y2","z2"}, profile, cprofile);
- assertGet("a.1.2.3","a", new String[] {"x1","y2","z3"}, profile, cprofile);
- assertGet("a.2.*.*","a", new String[] {"x2",null,null}, profile, cprofile);
+ assertGet("a.deflt", "a", new String[]{null, null, null}, profile, cprofile);
+ assertGet("a.1.*.*", "a", new String[]{"x1", null, null}, profile, cprofile);
+ assertGet("a.1.1.*", "a", new String[]{"x1", "y1", null}, profile, cprofile);
+ assertGet("a.1.5.*", "a", new String[]{"x1", "y5", null}, profile, cprofile);
+ assertGet("a.1.*.1", "a", new String[]{"x1", null, "z1"}, profile, cprofile);
+ assertGet("a.1.*.5", "a", new String[]{"x1", null, "z5"}, profile, cprofile);
+ assertGet("a.1.1.1", "a", new String[]{"x1", "y1", "z1"}, profile, cprofile);
+ assertGet("a.2.1.1", "a", new String[]{"x2", "y1", "z1"}, profile, cprofile);
+ assertGet("a.1.2.2", "a", new String[]{"x1", "y2", "z2"}, profile, cprofile);
+ assertGet("a.1.2.3", "a", new String[]{"x1", "y2", "z3"}, profile, cprofile);
+ assertGet("a.2.*.*", "a", new String[]{"x2", null, null}, profile, cprofile);
// Wildcard matches
- assertGet("a.deflt","a", new String[] {"x?","y?","z?"}, profile, cprofile);
- assertGet("a.deflt","a", new String[] {"x?","y1","z1"}, profile, cprofile);
- assertGet("a.1.*.*","a", new String[] {"x1","y?","z?"}, profile, cprofile);
- assertGet("a.1.*.*","a", new String[] {"x1","y?","z?"}, profile, cprofile);
- assertGet("a.1.1.*","a", new String[] {"x1","y1","z?"}, profile, cprofile);
- assertGet("a.1.*.1","a", new String[] {"x1","y?","z1"}, profile, cprofile);
- assertGet("a.1.5.*","a", new String[] {"x1","y5","z?"}, profile, cprofile);
- assertGet("a.1.*.5","a", new String[] {"x1","y?","z5"}, profile, cprofile);
- assertGet("a.1.5.*","a", new String[] {"x1","y5","z5"}, profile, cprofile); // Left dimension gets precedence
- assertGet("a.2.*.*","a", new String[] {"x2","y?","z?"}, profile, cprofile);
+ assertGet("a.deflt", "a", new String[]{"x?", "y?", "z?"}, profile, cprofile);
+ assertGet("a.deflt", "a", new String[]{"x?", "y1", "z1"}, profile, cprofile);
+ assertGet("a.1.*.*", "a", new String[]{"x1", "y?", "z?"}, profile, cprofile);
+ assertGet("a.1.*.*", "a", new String[]{"x1", "y?", "z?"}, profile, cprofile);
+ assertGet("a.1.1.*", "a", new String[]{"x1", "y1", "z?"}, profile, cprofile);
+ assertGet("a.1.*.1", "a", new String[]{"x1", "y?", "z1"}, profile, cprofile);
+ assertGet("a.1.5.*", "a", new String[]{"x1", "y5", "z?"}, profile, cprofile);
+ assertGet("a.1.*.5", "a", new String[]{"x1", "y?", "z5"}, profile, cprofile);
+ assertGet("a.1.5.*", "a", new String[]{"x1", "y5", "z5"}, profile, cprofile); // Left dimension gets precedence
+ assertGet("a.2.*.*", "a", new String[]{"x2", "y?", "z?"}, profile, cprofile);
}
@Test
- public void testReferenceInVariant() {
+ void testReferenceInVariant() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] { "d1" });
+ test.setDimensions(new String[]{"d1"});
registry.register(test);
QueryProfile references = new QueryProfile("referenced");
- references.setDimensions(new String[] { "d1" });
+ references.setDimensions(new String[]{"d1"});
registry.register(references);
QueryProfile other = new QueryProfile("other");
- other.setDimensions(new String[] { "d1" });
+ other.setDimensions(new String[]{"d1"});
registry.register(other);
- test.set( "a", references, new String[] { "d1v"}, registry);
- test.set( "a.b", "test-value", new String[] { "d1v"}, registry);
- other.set( "a", references, new String[] { "d1v"}, registry);
- other.set("a.b", "other-value", new String[] { "d1v"}, registry);
+ test.set("a", references, new String[]{"d1v"}, registry);
+ test.set("a.b", "test-value", new String[]{"d1v"}, registry);
+ other.set("a", references, new String[]{"d1v"}, registry);
+ other.set("a.b", "other-value", new String[]{"d1v"}, registry);
- assertEquals("test-value", test.get("a.b", new String[] { "d1v"}));
- assertEquals("other-value", other.get("a.b", new String[] { "d1v"}));
- assertNull(references.get("b", new String[] { "d1v"}));
+ assertEquals("test-value", test.get("a.b", new String[]{"d1v"}));
+ assertEquals("other-value", other.get("a.b", new String[]{"d1v"}));
+ assertNull(references.get("b", new String[]{"d1v"}));
var cRegistry = registry.compile();
assertEquals("test-value",
- cRegistry.getComponent("test").get("a.b", Map.of("d1", "d1v")));
+ cRegistry.getComponent("test").get("a.b", Map.of("d1", "d1v")));
}
/**
@@ -114,7 +112,7 @@ public class QueryProfileVariantsTestCase {
* and also setting a value within that variants subspace.
*/
@Test
- public void testVariantReference() {
+ void testVariantReference() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile parent = new QueryProfile("parent");
@@ -123,24 +121,24 @@ public class QueryProfileVariantsTestCase {
QueryProfile referenced = new QueryProfile("referenced");
referenced.addInherited(parent);
- referenced.setDimensions(new String[] {"d2", "d3"});
+ referenced.setDimensions(new String[]{"d2", "d3"});
registry.register(referenced);
QueryProfile base = new QueryProfile("base");
base.setDimensions(new String[]{"d1", "d2", "d3"});
- base.set("a", referenced, new String[] {null, null, "d3-val"}, registry);
- assertEquals("Variant dimensions are not overridden by the referenced dimensions",
- "[d1, d2, d3]",
- ((QueryProfile)base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString());
- base.set("a.b", 1, new String[] {null, null, "d3-val"}, registry);
+ base.set("a", referenced, new String[]{null, null, "d3-val"}, registry);
+ assertEquals("[d1, d2, d3]",
+ ((QueryProfile) base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString(),
+ "Variant dimensions are not overridden by the referenced dimensions");
+ base.set("a.b", 1, new String[]{null, null, "d3-val"}, registry);
QueryProfileVariant aVariants = base.getVariants().getVariants().get(0);
- assertEquals("Variant dimensions are not overridden by the referenced dimensions",
- "[d1, d2, d3]",
- ((QueryProfile)base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString());
+ assertEquals("[d1, d2, d3]",
+ ((QueryProfile) base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString(),
+ "Variant dimensions are not overridden by the referenced dimensions");
}
@Test
- public void testReference() {
+ void testReference() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
registry.register(test);
@@ -151,9 +149,9 @@ public class QueryProfileVariantsTestCase {
QueryProfile other = new QueryProfile("other");
registry.register(other);
- test.set( "a", references, registry);
- test.set( "a.b", "test-value", registry);
- other.set( "a", references, registry);
+ test.set("a", references, registry);
+ test.set("a.b", "test-value", registry);
+ other.set("a", references, registry);
other.set("a.b", "other-value", registry);
assertEquals("test-value", test.get("a.b"));
@@ -162,21 +160,21 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantInReferencedAndParentWithOtherMatchingVariant() {
+ void testVariantInReferencedAndParentWithOtherMatchingVariant() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] { "x", "y" } );
- parent.set("other", "otherValue", new String[] { "x1", "y1" }, registry );
+ parent.setDimensions(new String[]{"x", "y"});
+ parent.set("other", "otherValue", new String[]{"x1", "y1"}, registry);
QueryProfile profile = new QueryProfile("test");
profile.addInherited(parent);
QueryProfile referenced = new QueryProfile("referenced");
- referenced.setDimensions(new String[] { "x", "y", "z" });
+ referenced.setDimensions(new String[]{"x", "y", "z"});
registry.register(parent);
registry.register(profile);
registry.register(referenced);
profile.set("a.b", referenced, registry);
referenced.set("c", "default_value", registry);
- referenced.set("c", "variant_value", new String[] { "x1", null, "z1" }, registry);
+ referenced.set("c", "variant_value", new String[]{"x1", null, "z1"}, registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
@@ -186,9 +184,9 @@ public class QueryProfileVariantsTestCase {
{
Map<String, ValueWithSource> values = cRegistry.findQueryProfile("test")
- .listValuesWithSources(new CompoundName(""),
- new HashMap<>(),
- null);
+ .listValuesWithSources(new CompoundName(""),
+ new HashMap<>(),
+ null);
assertEquals(1, values.size());
assertEquals("default_value", values.get("a.b.c").value());
assertEquals("referenced", values.get("a.b.c").source());
@@ -197,9 +195,9 @@ public class QueryProfileVariantsTestCase {
{
Map<String, ValueWithSource> values = cRegistry.findQueryProfile("test")
- .listValuesWithSources(new CompoundName(""),
- toMap("x=x1", "y=y1", "z=z1"),
- null);
+ .listValuesWithSources(new CompoundName(""),
+ toMap("x=x1", "y=y1", "z=z1"),
+ null);
assertEquals(2, values.size());
assertEquals("variant_value", values.get("a.b.c").value());
assertEquals("referenced", values.get("a.b.c").source());
@@ -212,16 +210,16 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testSwitchingDimensionOrderInReferencedVariantWithFullOverlap() {
+ void testSwitchingDimensionOrderInReferencedVariantWithFullOverlap() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "x", "i", "j", "y" });
+ profile.setDimensions(new String[]{"x", "i", "j", "y"});
QueryProfile referenced = new QueryProfile("referenced");
- referenced.setDimensions(new String[] { "y", "x" });
+ referenced.setDimensions(new String[]{"y", "x"});
registry.register(profile);
registry.register(referenced);
- profile.set("a.b", referenced, new String[] { "x1", "i1", "j1", "y1" }, registry);
- referenced.set("c", "variant_value", new String[] { "y1" }, registry);
+ profile.set("a.b", referenced, new String[]{"x1", "i1", "j1", "y1"}, registry);
+ referenced.set("c", "variant_value", new String[]{"y1"}, registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
@@ -230,16 +228,16 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testSameDimensionOrderInReferencedVariantWithPartialOverlap() {
+ void testSameDimensionOrderInReferencedVariantWithPartialOverlap() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "x", "i", "j", "y" });
+ profile.setDimensions(new String[]{"x", "i", "j", "y"});
QueryProfile referenced = new QueryProfile("referenced");
- referenced.setDimensions(new String[] { "x", "y" });
+ referenced.setDimensions(new String[]{"x", "y"});
registry.register(profile);
registry.register(referenced);
- profile.set("a.b", referenced, new String[] { "x1", "i1", "j1" }, registry);
- referenced.set("c", "variant_value", new String[] { null, "y1" }, registry);
+ profile.set("a.b", referenced, new String[]{"x1", "i1", "j1"}, registry);
+ referenced.set("c", "variant_value", new String[]{null, "y1"}, registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
@@ -247,18 +245,19 @@ public class QueryProfileVariantsTestCase {
assertEquals("variant_value", new Query("?x=x1&i=i1&j=j1&y=y1", cTest).properties().get("a.b.c"));
}
+ // Switching order is not supported
@Test
- @Ignore // Switching order is not supported
- public void testSwitchingDimensionOrderInReferencedVariantWithPartialOverlap() {
+ @Disabled
+ void testSwitchingDimensionOrderInReferencedVariantWithPartialOverlap() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "x", "i", "j", "y" });
+ profile.setDimensions(new String[]{"x", "i", "j", "y"});
QueryProfile referenced = new QueryProfile("referenced");
- referenced.setDimensions(new String[] { "y", "x" });
+ referenced.setDimensions(new String[]{"y", "x"});
registry.register(profile);
registry.register(referenced);
- profile.set("a.b", referenced, new String[] { "x1", "i1", "j1" }, registry);
- referenced.set("c", "variant_value", new String[] { "y1" }, registry);
+ profile.set("a.b", referenced, new String[]{"x1", "i1", "j1"}, registry);
+ referenced.set("c", "variant_value", new String[]{"y1"}, registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
@@ -267,12 +266,12 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testMultipleMatchingVariantsAndDefault() {
+ void testMultipleMatchingVariantsAndDefault() {
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "a", "b" });
+ profile.setDimensions(new String[]{"a", "b"});
profile.set("property1", "property1_default", null);
- profile.set("property1", "property1_variantB", new String[] { null, "b1" }, null);
- profile.set("property2", "property2_variantA", new String[] { "a1", null }, null);
+ profile.set("property1", "property1_variantB", new String[]{null, "b1"}, null);
+ profile.set("property2", "property2_variantA", new String[]{"a1", null}, null);
CompiledQueryProfile cProfile = profile.compile(null);
Query query = new Query("?a=a1&b=b1&b=b1", cProfile);
@@ -281,16 +280,16 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testInheritedVariants() {
+ void testInheritedVariants() {
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] { "parentDim" });
+ parent.setDimensions(new String[]{"parentDim"});
parent.set("property", "defaultValue", null);
- parent.set("property", "variantValue", new String[] { "V2" }, null);
+ parent.set("property", "variantValue", new String[]{"V2"}, null);
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
- child.setDimensions(new String[] { "childDim" });
- child.set("otherProperty", "otherPropertyValue", new String[] { "V1" }, null);
+ child.setDimensions(new String[]{"childDim"});
+ child.set("otherProperty", "otherPropertyValue", new String[]{"V1"}, null);
CompiledQueryProfile cchild = child.compile(null);
assertEquals("defaultValue", new Query("?query=test", cchild).properties().get("property"));
@@ -301,19 +300,19 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testInheritedVariantsMultipleInheritance() {
+ void testInheritedVariantsMultipleInheritance() {
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] { "parentDim" });
+ parent.setDimensions(new String[]{"parentDim"});
parent.set("property", "defaultValue", null);
- parent.set("property", "variantValue", new String[] { "V2" }, null);
+ parent.set("property", "variantValue", new String[]{"V2"}, null);
QueryProfile otherParent = new QueryProfile("otherParent");
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
child.addInherited(otherParent);
- child.setDimensions(new String[] { "childDim" });
- child.set("otherProperty", "otherPropertyValue", new String[] { "V1" }, null);
+ child.setDimensions(new String[]{"childDim"});
+ child.set("otherProperty", "otherPropertyValue", new String[]{"V1"}, null);
CompiledQueryProfile cchild = child.compile(null);
assertEquals("defaultValue", new Query("?query=test", cchild).properties().get("property"));
@@ -324,12 +323,12 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantsOfInlineCompound() {
+ void testVariantsOfInlineCompound() {
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"x"});
+ profile.setDimensions(new String[]{"x"});
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);
+ profile.set("a.b", "a.b.x1", new String[]{"x1"}, null);
+ profile.set("a.b", "a.b.x2", new String[]{"x2"}, null);
CompiledQueryProfile cprofile = profile.compile(null);
@@ -339,13 +338,13 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testOverlappingProfiles() {
+ void testOverlappingProfiles() {
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"region", "model", "bucket"});
- profile.set("a", "us,nokia,* : a", new String[] {"us", "nokia", null }, null);
- profile.set("b", "us,nokia,* : b", new String[] {"us", "nokia", null }, null);
- profile.set("c", "us,*,bucket1: c", new String[] {"us", null, "bucket1"}, null);
- profile.set("d", "us,*,bucket1: d", new String[] {"us", null, "bucket1"}, null);
+ profile.setDimensions(new String[]{"region", "model", "bucket"});
+ profile.set("a", "us,nokia,* : a", new String[]{"us", "nokia", null }, null);
+ profile.set("b", "us,nokia,* : b", new String[]{"us", "nokia", null }, null);
+ profile.set("c", "us,*,bucket1: c", new String[]{"us", null, "bucket1"}, null);
+ profile.set("d", "us,*,bucket1: d", new String[]{"us", null, "bucket1"}, null);
CompiledQueryProfile cprofile = profile.compile(null);
var parameters = toMap("region=us", "model=nokia", "bucket=bucket1");
@@ -360,15 +359,15 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantsOfExplicitCompound() {
+ void testVariantsOfExplicitCompound() {
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a.b", null);
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"x"});
+ profile.setDimensions(new String[]{"x"});
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);
+ profile.set("a.b", "a.b.x1", new String[]{"x1"}, null);
+ profile.set("a.b", "a.b.x2", new String[]{"x2"}, null);
CompiledQueryProfile cprofile = profile.compile(null);
@@ -378,11 +377,11 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testCompound() {
+ void testCompound() {
// Configuration phase
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] {"x","y"});
+ profile.setDimensions(new String[]{"x", "y"});
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a1.b.default", null);
@@ -396,23 +395,23 @@ public class QueryProfileVariantsTestCase {
a2.set("d", "a2.d.default", null);
a2.set("e", "a2.e.default", null);
- profile.set("a",a1, null); // Must set profile references before overrides
+ 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" };
+ String[] d1 = new String[]{"x1", "y1"};
profile.set("a", a1, d1, null);
profile.set("a.b", "x1.y1.a.b.default-override", d1, null);
profile.set("a.c", "x1.y1.a.c.default-override", d1, null);
profile.set("a.g", "x1.y1.a.g.default-override", d1, null); // This value is never manifest because the runtime override overrides all variants
- String[] d2 = new String[] { "x1","y2" };
- profile.set("a.b","x1.y2.a.b.default-override", d2, null);
- profile.set("a.c","x1.y2.a.c.default-override", d2, null);
+ String[] d2 = new String[]{"x1", "y2"};
+ profile.set("a.b", "x1.y2.a.b.default-override", d2, null);
+ profile.set("a.c", "x1.y2.a.c.default-override", d2, null);
- String[] d3 = new String[] { "x2","y1" };
+ String[] d3 = new String[]{"x2", "y1"};
profile.set("a", a2, d3, null);
profile.set("a.b", "x2.y1.a.b.default-override", d3, null);
profile.set("a.c", "x2.y1.a.c.default-override", d3, null);
@@ -466,39 +465,39 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantNotInBase() {
+ void testVariantNotInBase() {
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
- test.set("InX1Only", "x1", new String[] { "x1" }, null);
+ test.setDimensions(new String[]{"x"});
+ test.set("InX1Only", "x1", new String[]{"x1"}, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals("x1", ctest.get("InX1Only", toMap("x=x1")));
- assertEquals(null, ctest.get("InX1Only", toMap("x=x2")));
- assertEquals(null, ctest.get("InX1Only"));
+ assertNull(ctest.get("InX1Only", toMap("x=x2")));
+ assertNull(ctest.get("InX1Only"));
}
@Test
- public void testVariantNotInBaseSpaceVariantValue() {
+ void testVariantNotInBaseSpaceVariantValue() {
QueryProfile test = new QueryProfile("test");
- test.setDimensions(new String[] { "x" });
- test.set("InX1Only", "x1", new String[] { "x 1" }, null);
+ test.setDimensions(new String[]{"x"});
+ test.set("InX1Only", "x1", new String[]{"x 1"}, null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals("x1", ctest.get("InX1Only", toMap("x=x 1")));
- assertEquals(null, ctest.get("InX1Only", toMap("x=x 2")));
- assertEquals(null, ctest.get("InX1Only"));
+ assertNull(ctest.get("InX1Only", toMap("x=x 2")));
+ assertNull(ctest.get("InX1Only"));
}
@Test
- public void testDimensionsInSuperType() {
+ void testDimensionsInSuperType() {
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] {"x", "y"});
+ parent.setDimensions(new String[]{"x", "y"});
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
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);
+ child.set("a", "a.x1.y1", new String[]{"x1", "y1"}, null);
+ child.set("a", "a.x1.y2", new String[]{"x1", "y2"}, null);
CompiledQueryProfile cchild = child.compile(null);
@@ -508,15 +507,15 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testDimensionsInSuperTypeRuntime() {
+ void testDimensionsInSuperTypeRuntime() {
QueryProfile parent = new QueryProfile("parent");
- parent.setDimensions(new String[] { "x", "y" });
+ parent.setDimensions(new String[]{"x", "y"});
QueryProfile child = new QueryProfile("child");
child.addInherited(parent);
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));
+ Properties overridable = new QueryProfileProperties(child.compile(null));
assertEquals("a.default", child.get("a"));
assertEquals("a.x1.y1", overridable.get("a", toMap("x=x1", "y=y1")));
@@ -524,220 +523,220 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testVariantsAreResolvedBeforeInheritance() {
- QueryProfile parent=new QueryProfile("parent");
- parent.setDimensions(new String[] {"x","y"});
- 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", 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"});
+ void testVariantsAreResolvedBeforeInheritance() {
+ QueryProfile parent = new QueryProfile("parent");
+ parent.setDimensions(new String[]{"x", "y"});
+ 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", 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", null);
- child.set("a","c.a.x1.y1",new String[] {"x1","y1"}, 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);
- assertEquals("c.a.default",cchild.get("a"));
- assertEquals("c.a.x1.y1",cchild.get("a", toMap("x=x1", "y=y1")));
- assertEquals("c.a.default",cchild.get("a", toMap("x=x1", "y=y2")));
- assertEquals("p.b.default",cchild.get("b"));
- assertEquals("p.b.x1.y1",cchild.get("b", toMap("x=x1", "y=y1")));
- assertEquals("p.b.x1.y2",cchild.get("b", toMap("x=x1", "y=y2")));
+ assertEquals("c.a.default", cchild.get("a"));
+ assertEquals("c.a.x1.y1", cchild.get("a", toMap("x=x1", "y=y1")));
+ assertEquals("c.a.default", cchild.get("a", toMap("x=x1", "y=y2")));
+ assertEquals("p.b.default", cchild.get("b"));
+ assertEquals("p.b.x1.y1", cchild.get("b", toMap("x=x1", "y=y1")));
+ 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"});
- parent.set("a","p.a.x1.y2",new String[] {"x1","y2"}, null);
+ void testVariantsAreResolvedBeforeInheritanceSimplified() {
+ QueryProfile parent = new QueryProfile("parent");
+ parent.setDimensions(new String[]{"x", "y"});
+ parent.set("a", "p.a.x1.y2", new String[]{"x1", "y2"}, null);
- QueryProfile child=new QueryProfile("child");
- child.setDimensions(new String[] {"x","y"});
+ QueryProfile child = new QueryProfile("child");
+ child.setDimensions(new String[]{"x", "y"});
child.addInherited(parent);
- child.set("a","c.a.default", null);
+ child.set("a", "c.a.default", null);
- assertEquals("c.a.default",child.compile(null).get("a", toMap("x=x1", "y=y2")));
+ 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", null);
- QueryProfile x1Parent=new QueryProfile("x1Parent");
- 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", null);
- QueryProfile x1y2Parent=new QueryProfile("x1y2Parent");
- x1y2Parent.set("a","a-x1y2", null);
- x1y2Parent.set("b","b-x1y2", null);
- x1y2Parent.set("c","c-x1y2", null);
+ void testVariantInheritance() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x", "y"});
+ QueryProfile defaultParent = new QueryProfile("defaultParent");
+ defaultParent.set("a", "a-default", null);
+ QueryProfile x1Parent = new QueryProfile("x1Parent");
+ 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", null);
+ QueryProfile x1y2Parent = new QueryProfile("x1y2Parent");
+ 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"});
- test.addInherited(x1y2Parent,new String[] {"x1","y2"});
- test.set("c","c-x1",new String[] {"x1"}, null);
- test.set("e","e-x1y2",new String[] {"x1","y2"}, null);
+ test.addInherited(x1Parent, new String[]{"x1"});
+ test.addInherited(x1y1Parent, new String[]{"x1", "y1"});
+ test.addInherited(x1y2Parent, new String[]{"x1", "y2"});
+ test.set("c", "c-x1", new String[]{"x1"}, null);
+ test.set("e", "e-x1y2", new String[]{"x1", "y2"}, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("a-default",ctest.get("a"));
- assertEquals("a-x1",ctest.get("a", toMap("x=x1")));
- assertEquals("a-x1y1",ctest.get("a", toMap("x=x1", "y=y1")));
- assertEquals("a-x1y2",ctest.get("a", toMap("x=x1", "y=y2")));
+ assertEquals("a-default", ctest.get("a"));
+ assertEquals("a-x1", ctest.get("a", toMap("x=x1")));
+ assertEquals("a-x1y1", ctest.get("a", toMap("x=x1", "y=y1")));
+ assertEquals("a-x1y2", ctest.get("a", toMap("x=x1", "y=y2")));
- assertEquals(null,ctest.get("b"));
- assertEquals(null,ctest.get("b", toMap("x=x1")));
- assertEquals(null,ctest.get("b", toMap("x=x1", "y=y1")));
- assertEquals("b-x1y2",ctest.get("b", toMap("x=x1", "y=y2")));
+ assertNull(ctest.get("b"));
+ assertNull(ctest.get("b", toMap("x=x1")));
+ assertNull(ctest.get("b", toMap("x=x1", "y=y1")));
+ assertEquals("b-x1y2", ctest.get("b", toMap("x=x1", "y=y2")));
- assertEquals(null,ctest.get("c"));
- assertEquals("c-x1",ctest.get("c", toMap("x=x1")));
- assertEquals("c-x1",ctest.get("c", toMap("x=x1", "y=y1")));
- assertEquals("c-x1y2",ctest.get("c", toMap("x=x1", "y=y2")));
+ assertNull(ctest.get("c"));
+ assertEquals("c-x1", ctest.get("c", toMap("x=x1")));
+ assertEquals("c-x1", ctest.get("c", toMap("x=x1", "y=y1")));
+ assertEquals("c-x1y2", ctest.get("c", toMap("x=x1", "y=y2")));
- assertEquals(null,ctest.get("d"));
- assertEquals("d-x1",ctest.get("d", toMap("x=x1")));
+ assertNull(ctest.get("d"));
+ assertEquals("d-x1", ctest.get("d", toMap("x=x1")));
- assertEquals("d-x1",ctest.get("d", toMap("x=x1", "y=y1")));
- assertEquals("d-x1",ctest.get("d", toMap("x=x1", "y=y2")));
+ assertEquals("d-x1", ctest.get("d", toMap("x=x1", "y=y1")));
+ assertEquals("d-x1", ctest.get("d", toMap("x=x1", "y=y2")));
- assertEquals(null,ctest.get("d"));
- assertEquals("e-x1",ctest.get("e", toMap("x=x1")));
- assertEquals("e-x1",ctest.get("e", toMap("x=x1", "y=y1")));
- assertEquals("e-x1y2",ctest.get("e", toMap("x=x1", "y=y2")));
+ assertNull(ctest.get("d"));
+ assertEquals("e-x1", ctest.get("e", toMap("x=x1")));
+ assertEquals("e-x1", ctest.get("e", toMap("x=x1", "y=y1")));
+ 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", null);
- test.addInherited(x1y2Parent,new String[] {"x1","y2"});
- test.set("c","c-x1",new String[] {"x1"}, null);
+ void testVariantInheritanceSimplified() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x", "y"});
+ QueryProfile x1y2Parent = new QueryProfile("x1y2Parent");
+ x1y2Parent.set("c", "c-x1y2", null);
+ test.addInherited(x1y2Parent, new String[]{"x1", "y2"});
+ test.set("c", "c-x1", new String[]{"x1"}, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals(null,ctest.get("c"));
- assertEquals("c-x1",ctest.get("c", toMap("x=x1")));
+ assertNull(ctest.get("c"));
+ assertEquals("c-x1", ctest.get("c", toMap("x=x1")));
assertEquals("c-x1", ctest.get("c", toMap("x=x1", "y=y1")));
- assertEquals("c-x1y2",ctest.get("c", toMap("x=x1", "y=y2")));
+ 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", null);
+ void testVariantInheritanceWithCompoundReferences() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
+ test.set("a.b", "default-a.b", null);
- QueryProfile ac=new QueryProfile("ac");
- 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 ac = new QueryProfile("ac");
+ 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);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("Basic functionality","default-a.b",ctest.get("a.b"));
- assertEquals("Inherited variance reference works","referenced-a.c",ctest.get("a.c", toMap("x=x1")));
- assertEquals("Inherited variance reference overriding works","x1-a.b",ctest.get("a.b", toMap("x=x1")));
+ assertEquals("default-a.b", ctest.get("a.b"), "Basic functionality");
+ assertEquals("referenced-a.c", ctest.get("a.c", toMap("x=x1")), "Inherited variance reference works");
+ assertEquals("x1-a.b", ctest.get("a.b", toMap("x=x1")), "Inherited variance reference overriding works");
}
@Test
- public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
- test.set("o.a.b","default-a.b", null);
+ void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
+ test.set("o.a.b", "default-a.b", null);
- QueryProfile ac=new QueryProfile("ac");
- 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);
+ QueryProfile ac = new QueryProfile("ac");
+ 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);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("Basic functionality","default-a.b",ctest.get("o.a.b"));
- assertEquals("Inherited variance reference works","referenced-a.c",ctest.get("o.a.c", toMap("x=x1")));
- assertEquals("Inherited variance reference overriding works","x1-a.b",ctest.get("o.a.b", toMap("x=x1")));
+ assertEquals("default-a.b", ctest.get("o.a.b"), "Basic functionality");
+ assertEquals("referenced-a.c", ctest.get("o.a.c", toMap("x=x1")), "Inherited variance reference works");
+ assertEquals("x1-a.b", ctest.get("o.a.b", toMap("x=x1")), "Inherited variance reference overriding works");
}
@Test
- public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
+ void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
- QueryProfile ac=new QueryProfile("ac");
- 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 ac = new QueryProfile("ac");
+ 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", null);
- top.set("o",test, null);
+ QueryProfile top = new QueryProfile("top");
+ 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"));
- assertEquals("Inherited variance reference works","referenced-a.c",ctop.get("o.a.c", toMap("x=x1")));
- 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
+ assertEquals("default-a.b", ctop.get("o.a.b"), "Basic functionality");
+ assertEquals("referenced-a.c", ctop.get("o.a.c", toMap("x=x1")), "Inherited variance reference works");
+ assertEquals("default-a.b", ctop.get("o.a.b", toMap("x=x1")), "Inherited variance reference does not override value set in referent"); // 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", null);
- QueryProfile variantInherited=new QueryProfile("variantInherited");
- variantInherited.set("a.b","variantInherited-a.b", null);
- test.setDimensions(new String[] {"x"});
+ void testVariantInheritanceOverridesBaseInheritance1() {
+ QueryProfile test = new QueryProfile("test");
+ QueryProfile baseInherited = new QueryProfile("baseInherited");
+ baseInherited.set("a.b", "baseInherited-a.b", null);
+ QueryProfile variantInherited = new QueryProfile("variantInherited");
+ variantInherited.set("a.b", "variantInherited-a.b", null);
+ test.setDimensions(new String[]{"x"});
test.addInherited(baseInherited);
- test.addInherited(variantInherited,new String[] {"x1"});
+ test.addInherited(variantInherited, new String[]{"x1"});
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("baseInherited-a.b",ctest.get("a.b"));
- assertEquals("variantInherited-a.b",ctest.get("a.b",toMap("x=x1")));
+ assertEquals("baseInherited-a.b", ctest.get("a.b"));
+ 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", null);
- QueryProfile variantInherited=new QueryProfile("variantInherited");
- variantInherited.set("a.b","variantInherited-a.b", null);
- test.setDimensions(new String[] {"x"});
+ void testVariantInheritanceOverridesBaseInheritance2() {
+ QueryProfile test = new QueryProfile("test");
+ QueryProfile baseInherited = new QueryProfile("baseInherited");
+ baseInherited.set("a.b", "baseInherited-a.b", null);
+ QueryProfile variantInherited = new QueryProfile("variantInherited");
+ variantInherited.set("a.b", "variantInherited-a.b", null);
+ test.setDimensions(new String[]{"x"});
test.addInherited(baseInherited);
- test.addInherited(variantInherited,new String[] {"x1"});
- test.set("a.c","variant-a.c",new String[] {"x1"}, null);
+ test.addInherited(variantInherited, new String[]{"x1"});
+ test.set("a.c", "variant-a.c", new String[]{"x1"}, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("baseInherited-a.b",ctest.get("a.b"));
- assertEquals("variantInherited-a.b",ctest.get("a.b", toMap("x=x1")));
- assertEquals("variant-a.c",ctest.get("a.c", toMap("x=x1")));
+ assertEquals("baseInherited-a.b", ctest.get("a.b"));
+ assertEquals("variantInherited-a.b", ctest.get("a.b", toMap("x=x1")));
+ 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", null);
+ void testVariantInheritanceOverridesBaseInheritanceComplex() {
+ QueryProfile defaultQP = new QueryProfile("default");
+ defaultQP.set("model.defaultIndex", "title", null);
- QueryProfile root=new QueryProfile("root");
+ QueryProfile root = new QueryProfile("root");
root.addInherited(defaultQP);
- root.set("model.defaultIndex","default", null);
+ root.set("model.defaultIndex", "default", null);
- QueryProfile querybest=new QueryProfile("querybest");
- querybest.set("defaultIndex","title", null);
- querybest.set("queryString","best", null);
+ QueryProfile querybest = new QueryProfile("querybest");
+ querybest.set("defaultIndex", "title", null);
+ querybest.set("queryString", "best", null);
- QueryProfile multi=new QueryProfile("multi");
- multi.setDimensions(new String[] {"x"});
+ QueryProfile multi = new QueryProfile("multi");
+ multi.setDimensions(new String[]{"x"});
multi.addInherited(defaultQP);
- multi.set("model",querybest, null);
- multi.addInherited(root,new String[] {"x1"});
- multi.set("model.queryString","love",new String[] {"x1"}, null);
+ multi.set("model", querybest, null);
+ multi.addInherited(root, new String[]{"x1"});
+ multi.set("model.queryString", "love", new String[]{"x1"}, null);
// Rumtimize
defaultQP.freeze();
@@ -746,461 +745,461 @@ public class QueryProfileVariantsTestCase {
multi.freeze();
Properties runtime = new QueryProfileProperties(multi.compile(null));
- assertEquals("default",runtime.get("model.defaultIndex", toMap("x=x1")));
- assertEquals("love",runtime.get("model.queryString", toMap("x=x1")));
+ assertEquals("default", runtime.get("model.defaultIndex", toMap("x=x1")));
+ assertEquals("love", runtime.get("model.queryString", toMap("x=x1")));
}
@Test
- public void testVariantInheritanceOverridesBaseInheritanceComplexSimplified() {
- QueryProfile root=new QueryProfile("root");
- root.set("model.defaultIndex","default", null);
+ void testVariantInheritanceOverridesBaseInheritanceComplexSimplified() {
+ QueryProfile root = new QueryProfile("root");
+ root.set("model.defaultIndex", "default", null);
- QueryProfile multi=new QueryProfile("multi");
- multi.setDimensions(new String[] {"x"});
- multi.set("model.defaultIndex","title", null);
- multi.addInherited(root,new String[] {"x1"});
+ QueryProfile multi = new QueryProfile("multi");
+ multi.setDimensions(new String[]{"x"});
+ multi.set("model.defaultIndex", "title", null);
+ multi.addInherited(root, new String[]{"x1"});
- assertEquals("default",multi.compile(null).get("model.defaultIndex", toMap("x=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", null);
+ void testVariantInheritanceOverridesBaseInheritanceMixed() {
+ QueryProfile root = new QueryProfile("root");
+ root.set("model.defaultIndex", "default", null);
- QueryProfile multi=new QueryProfile("multi");
- multi.setDimensions(new String[] {"x"});
- 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);
+ QueryProfile multi = new QueryProfile("multi");
+ multi.setDimensions(new String[]{"x"});
+ 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);
CompiledQueryProfile cmulti = multi.compile(null);
- assertEquals("default",cmulti.get("model.defaultIndex", toMap("x=x1")));
- assertEquals("modelVariantQuery",cmulti.get("model.queryString", toMap("x=x1")));
+ assertEquals("default", cmulti.get("model.defaultIndex", toMap("x=x1")));
+ assertEquals("modelVariantQuery", cmulti.get("model.queryString", toMap("x=x1")));
}
@Test
- public void testListVariantPropertiesNoCompounds() {
- QueryProfile parent1=new QueryProfile("parent1");
- 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", 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"});
+ void testListVariantPropertiesNoCompounds() {
+ QueryProfile parent1 = new QueryProfile("parent1");
+ 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", 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", 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
- main.set("a","main-a-x1.y1",new String[] {"x1","y1"}, null);
- 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", null);
-
- QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- 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", 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", null); // Only defined in one inherited variant, but inherited twice
-
- main.addInherited(inheritedVariant1,new String[] {"x1"});
- main.addInherited(inheritedVariant3,new String[] {"x1"});
- main.addInherited(inheritedVariant2,new String[] {"x1","y2"});
- main.addInherited(inheritedVariant3,new String[] {"x1","y2"});
+ 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
+ main.set("a", "main-a-x1.y1", new String[]{"x1", "y1"}, null);
+ 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", null);
+
+ QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
+ 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", 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", null); // Only defined in one inherited variant, but inherited twice
+
+ main.addInherited(inheritedVariant1, new String[]{"x1"});
+ main.addInherited(inheritedVariant3, new String[]{"x1"});
+ main.addInherited(inheritedVariant2, new String[]{"x1", "y2"});
+ main.addInherited(inheritedVariant3, new String[]{"x1", "y2"});
// Runtime-ify
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
- int expectedBaseSize=4;
+ int expectedBaseSize = 4;
// No context
- Map<String,Object> listed=properties.listProperties();
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
+ Map<String, Object> listed = properties.listProperties();
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
// Context x=x1
- listed=properties.listProperties(toMap(main, new String[] {"x1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
- assertEquals("main-e-x1",listed.get("e"));
- assertEquals("main-f-x1",listed.get("f"));
- assertEquals("inheritedVariant1-h",listed.get("h"));
- assertEquals("inheritedVariant3-j",listed.get("j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
+ assertEquals("main-e-x1", listed.get("e"));
+ assertEquals("main-f-x1", listed.get("f"));
+ assertEquals("inheritedVariant1-h", listed.get("h"));
+ assertEquals("inheritedVariant3-j", listed.get("j"));
// Context x=x1,y=y1
- listed=properties.listProperties(toMap(main, new String[] {"x1","y1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1.y1",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
- assertEquals("main-e-x1",listed.get("e"));
- assertEquals("main-f-x1",listed.get("f"));
- assertEquals("inheritedVariant1-h",listed.get("h"));
- assertEquals("inheritedVariant3-j",listed.get("j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1.y1", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
+ assertEquals("main-e-x1", listed.get("e"));
+ assertEquals("main-f-x1", listed.get("f"));
+ assertEquals("inheritedVariant1-h", listed.get("h"));
+ assertEquals("inheritedVariant3-j", listed.get("j"));
// Context x=x1,y=y2
- listed=properties.listProperties(toMap(main, new String[] {"x1","y2"}));
- assertEquals(expectedBaseSize+6,listed.size());
- assertEquals("main-a-x1.y2",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
- assertEquals("main-e-x1.y2",listed.get("e"));
- assertEquals("main-f-x1",listed.get("f"));
- assertEquals("main-g-x1.y2",listed.get("g"));
- assertEquals("inheritedVariant2-h",listed.get("h"));
- assertEquals("inheritedVariant2-i",listed.get("i"));
- assertEquals("inheritedVariant3-j",listed.get("j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y2"}));
+ assertEquals(expectedBaseSize + 6, listed.size());
+ assertEquals("main-a-x1.y2", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
+ assertEquals("main-e-x1.y2", listed.get("e"));
+ assertEquals("main-f-x1", listed.get("f"));
+ assertEquals("main-g-x1.y2", listed.get("g"));
+ assertEquals("inheritedVariant2-h", listed.get("h"));
+ assertEquals("inheritedVariant2-i", listed.get("i"));
+ assertEquals("inheritedVariant3-j", listed.get("j"));
// Context x=x1,y=y3
- listed=properties.listProperties(toMap(main, new String[] {"x1","y3"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
- assertEquals("main-e-x1",listed.get("e"));
- assertEquals("main-f-x1",listed.get("f"));
- assertEquals("inheritedVariant1-h",listed.get("h"));
- assertEquals("inheritedVariant3-j",listed.get("j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y3"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ assertEquals("parent2-d", listed.get("d"));
+ assertEquals("main-e-x1", listed.get("e"));
+ assertEquals("main-f-x1", listed.get("f"));
+ assertEquals("inheritedVariant1-h", listed.get("h"));
+ assertEquals("inheritedVariant3-j", listed.get("j"));
// Context x=x2,y=y1
- listed=properties.listProperties(toMap(main, new String[] {"x2","y1"}));
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("a"));
- assertEquals("main-b",listed.get("b"));
- assertEquals("parent1-c",listed.get("c"));
- assertEquals("parent2-d",listed.get("d"));
+ listed = properties.listProperties(toMap(main, new String[]{"x2", "y1"}));
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("a"));
+ assertEquals("main-b", listed.get("b"));
+ assertEquals("parent1-c", listed.get("c"));
+ 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);
+ 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", null);
- main.addInherited(inheritedVariant1,new String[] {"x1"});
+ QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
+ inheritedVariant1.set("a.p1", "inheritedVariant1-a", null);
+ main.addInherited(inheritedVariant1, new String[]{"x1"});
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
// Context x=x1
- Map<String,Object> listed=properties.listProperties(toMap(main,new String[] {"x1"}));
- assertEquals("main-a-x1",listed.get("a.p1"));
+ Map<String, Object> listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals("main-a-x1", listed.get("a.p1"));
}
@Test
- public void testListVariantPropertiesCompounds1() {
- QueryProfile parent1=new QueryProfile("parent1");
- 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", 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"});
+ void testListVariantPropertiesCompounds1() {
+ QueryProfile parent1 = new QueryProfile("parent1");
+ 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", 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", 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
- main.set("a.p1","main-a-x1.y1",new String[] {"x1","y1"}, null);
- 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", 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
+ main.set("a.p1", "main-a-x1.y1", new String[]{"x1", "y1"}, null);
+ 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", null);
+
+ QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
+ 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", 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", null); // Only defined in one inherited variant, but inherited twice
+
+ main.addInherited(inheritedVariant1, new String[]{"x1"});
+ main.addInherited(inheritedVariant3, new String[]{"x1"});
+ main.addInherited(inheritedVariant2, new String[]{"x1", "y2"});
+ main.addInherited(inheritedVariant3, new String[]{"x1", "y2"});
- QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- 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", 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", null); // Only defined in one inherited variant, but inherited twice
-
- main.addInherited(inheritedVariant1,new String[] {"x1"});
- main.addInherited(inheritedVariant3,new String[] {"x1"});
- main.addInherited(inheritedVariant2,new String[] {"x1","y2"});
- main.addInherited(inheritedVariant3,new String[] {"x1","y2"});
-
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
- int expectedBaseSize=4;
+ int expectedBaseSize = 4;
// No context
- Map<String,Object> listed=properties.listProperties();
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
+ Map<String, Object> listed = properties.listProperties();
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
// Context x=x1
- listed=properties.listProperties(toMap(main,new String[] {"x1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
- assertEquals("main-e-x1",listed.get("e.p1"));
- assertEquals("main-f-x1",listed.get("f.p1"));
- assertEquals("inheritedVariant1-h",listed.get("h.p1"));
- assertEquals("inheritedVariant3-j",listed.get("j.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
+ assertEquals("main-e-x1", listed.get("e.p1"));
+ assertEquals("main-f-x1", listed.get("f.p1"));
+ assertEquals("inheritedVariant1-h", listed.get("h.p1"));
+ assertEquals("inheritedVariant3-j", listed.get("j.p1"));
// Context x=x1,y=y1
- listed=properties.listProperties(toMap(main,new String[] {"x1","y1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1.y1",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
- assertEquals("main-e-x1",listed.get("e.p1"));
- assertEquals("main-f-x1",listed.get("f.p1"));
- assertEquals("inheritedVariant1-h",listed.get("h.p1"));
- assertEquals("inheritedVariant3-j",listed.get("j.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1.y1", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
+ assertEquals("main-e-x1", listed.get("e.p1"));
+ assertEquals("main-f-x1", listed.get("f.p1"));
+ assertEquals("inheritedVariant1-h", listed.get("h.p1"));
+ assertEquals("inheritedVariant3-j", listed.get("j.p1"));
// Context x=x1,y=y2
- listed=properties.listProperties(toMap(main,new String[] {"x1","y2"}));
- assertEquals(expectedBaseSize+6,listed.size());
- assertEquals("main-a-x1.y2",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
- assertEquals("main-e-x1.y2",listed.get("e.p1"));
- assertEquals("main-f-x1",listed.get("f.p1"));
- assertEquals("main-g-x1.y2",listed.get("g.p1"));
- assertEquals("inheritedVariant2-h",listed.get("h.p1"));
- assertEquals("inheritedVariant2-i",listed.get("i.p1"));
- assertEquals("inheritedVariant3-j",listed.get("j.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y2"}));
+ assertEquals(expectedBaseSize + 6, listed.size());
+ assertEquals("main-a-x1.y2", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
+ assertEquals("main-e-x1.y2", listed.get("e.p1"));
+ assertEquals("main-f-x1", listed.get("f.p1"));
+ assertEquals("main-g-x1.y2", listed.get("g.p1"));
+ assertEquals("inheritedVariant2-h", listed.get("h.p1"));
+ assertEquals("inheritedVariant2-i", listed.get("i.p1"));
+ assertEquals("inheritedVariant3-j", listed.get("j.p1"));
// Context x=x1,y=y3
- listed=properties.listProperties(toMap(main,new String[] {"x1","y3"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
- assertEquals("main-e-x1",listed.get("e.p1"));
- assertEquals("main-f-x1",listed.get("f.p1"));
- assertEquals("inheritedVariant1-h",listed.get("h.p1"));
- assertEquals("inheritedVariant3-j",listed.get("j.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y3"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
+ assertEquals("main-e-x1", listed.get("e.p1"));
+ assertEquals("main-f-x1", listed.get("f.p1"));
+ assertEquals("inheritedVariant1-h", listed.get("h.p1"));
+ assertEquals("inheritedVariant3-j", listed.get("j.p1"));
// Context x=x2,y=y1
- listed=properties.listProperties(toMap(main,new String[] {"x2","y1"}));
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("a.p1"));
- assertEquals("main-b",listed.get("b.p1"));
- assertEquals("parent1-c",listed.get("c.p1"));
- assertEquals("parent2-d",listed.get("d.p1"));
+ listed = properties.listProperties(toMap(main, new String[]{"x2", "y1"}));
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("a.p1"));
+ assertEquals("main-b", listed.get("b.p1"));
+ assertEquals("parent1-c", listed.get("c.p1"));
+ assertEquals("parent2-d", listed.get("d.p1"));
}
@Test
- public void testListVariantPropertiesCompounds2() {
- QueryProfile parent1=new QueryProfile("parent1");
- 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", 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"});
+ void testListVariantPropertiesCompounds2() {
+ QueryProfile parent1 = new QueryProfile("parent1");
+ 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", 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", 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
- main.set("p1.a","main-a-x1.y1",new String[] {"x1","y1"}, null);
- 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", null);
-
- QueryProfile inheritedVariant1=new QueryProfile("inheritedVariant1");
- 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", 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", null); // Only defined in one inherited variant, but inherited twice
+ 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
+ main.set("p1.a", "main-a-x1.y1", new String[]{"x1", "y1"}, null);
+ 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", null);
+
+ QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
+ 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", 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", null); // Only defined in one inherited variant, but inherited twice
+
+ main.addInherited(inheritedVariant1, new String[]{"x1"});
+ main.addInherited(inheritedVariant3, new String[]{"x1"});
+ main.addInherited(inheritedVariant2, new String[]{"x1", "y2"});
+ main.addInherited(inheritedVariant3, new String[]{"x1", "y2"});
- main.addInherited(inheritedVariant1,new String[] {"x1"});
- main.addInherited(inheritedVariant3,new String[] {"x1"});
- main.addInherited(inheritedVariant2,new String[] {"x1","y2"});
- main.addInherited(inheritedVariant3,new String[] {"x1","y2"});
-
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
- int expectedBaseSize=4;
+ int expectedBaseSize = 4;
// No context
- Map<String,Object> listed=properties.listProperties();
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
+ Map<String, Object> listed = properties.listProperties();
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
// Context x=x1
- listed=properties.listProperties(toMap(main,new String[] {"x1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
- assertEquals("main-e-x1",listed.get("p1.e"));
- assertEquals("main-f-x1",listed.get("p1.f"));
- assertEquals("inheritedVariant1-h",listed.get("p1.h"));
- assertEquals("inheritedVariant3-j",listed.get("p1.j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
+ assertEquals("main-e-x1", listed.get("p1.e"));
+ assertEquals("main-f-x1", listed.get("p1.f"));
+ assertEquals("inheritedVariant1-h", listed.get("p1.h"));
+ assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y1
- listed=properties.listProperties(toMap(main,new String[] {"x1","y1"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1.y1",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
- assertEquals("main-e-x1",listed.get("p1.e"));
- assertEquals("main-f-x1",listed.get("p1.f"));
- assertEquals("inheritedVariant1-h",listed.get("p1.h"));
- assertEquals("inheritedVariant3-j",listed.get("p1.j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y1"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1.y1", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
+ assertEquals("main-e-x1", listed.get("p1.e"));
+ assertEquals("main-f-x1", listed.get("p1.f"));
+ assertEquals("inheritedVariant1-h", listed.get("p1.h"));
+ assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y2
- listed=properties.listProperties(toMap(main,new String[] {"x1","y2"}));
- assertEquals(expectedBaseSize+6,listed.size());
- assertEquals("main-a-x1.y2",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
- assertEquals("main-e-x1.y2",listed.get("p1.e"));
- assertEquals("main-f-x1",listed.get("p1.f"));
- assertEquals("main-g-x1.y2",listed.get("p1.g"));
- assertEquals("inheritedVariant2-h",listed.get("p1.h"));
- assertEquals("inheritedVariant2-i",listed.get("p1.i"));
- assertEquals("inheritedVariant3-j",listed.get("p1.j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y2"}));
+ assertEquals(expectedBaseSize + 6, listed.size());
+ assertEquals("main-a-x1.y2", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
+ assertEquals("main-e-x1.y2", listed.get("p1.e"));
+ assertEquals("main-f-x1", listed.get("p1.f"));
+ assertEquals("main-g-x1.y2", listed.get("p1.g"));
+ assertEquals("inheritedVariant2-h", listed.get("p1.h"));
+ assertEquals("inheritedVariant2-i", listed.get("p1.i"));
+ assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x1,y=y3
- listed=properties.listProperties(toMap(main,new String[] {"x1","y3"}));
- assertEquals(expectedBaseSize+4,listed.size());
- assertEquals("main-a-x1",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
- assertEquals("main-e-x1",listed.get("p1.e"));
- assertEquals("main-f-x1",listed.get("p1.f"));
- assertEquals("inheritedVariant1-h",listed.get("p1.h"));
- assertEquals("inheritedVariant3-j",listed.get("p1.j"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1", "y3"}));
+ assertEquals(expectedBaseSize + 4, listed.size());
+ assertEquals("main-a-x1", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ assertEquals("parent2-d", listed.get("p1.d"));
+ assertEquals("main-e-x1", listed.get("p1.e"));
+ assertEquals("main-f-x1", listed.get("p1.f"));
+ assertEquals("inheritedVariant1-h", listed.get("p1.h"));
+ assertEquals("inheritedVariant3-j", listed.get("p1.j"));
// Context x=x2,y=y1
- listed=properties.listProperties(toMap(main,new String[] {"x2","y1"}));
- assertEquals(expectedBaseSize,listed.size());
- assertEquals("main-a",listed.get("p1.a"));
- assertEquals("main-b",listed.get("p1.b"));
- assertEquals("parent1-c",listed.get("p1.c"));
- assertEquals("parent2-d",listed.get("p1.d"));
+ listed = properties.listProperties(toMap(main, new String[]{"x2", "y1"}));
+ assertEquals(expectedBaseSize, listed.size());
+ assertEquals("main-a", listed.get("p1.a"));
+ assertEquals("main-b", listed.get("p1.b"));
+ assertEquals("parent1-c", listed.get("p1.c"));
+ 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", null); // In both
- referencedMain.set("r2","mainReferenced-r2", null); // Only in this
- QueryProfile referencedVariant=new QueryProfile("referencedVariant");
- referencedVariant.set("r1","variantReferenced-r1", null); // In both
- referencedVariant.set("r3","variantReferenced-r3", null); // Only in this
+ void testQueryProfileReferences() {
+ QueryProfile main = new QueryProfile("main");
+ main.setDimensions(new String[]{"x1"});
+ QueryProfile referencedMain = new QueryProfile("referencedMain");
+ 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", null); // In both
+ referencedVariant.set("r3", "variantReferenced-r3", null); // Only in this
- main.set("a",referencedMain, null);
- main.set("a",referencedVariant,new String[] {"x1"}, null);
+ main.set("a", referencedMain, null);
+ main.set("a", referencedVariant, new String[]{"x1"}, null);
- Properties properties=new QueryProfileProperties(main.compile(null));
+ Properties properties = new QueryProfileProperties(main.compile(null));
// No context
- Map<String,Object> listed=properties.listProperties();
- assertEquals(2,listed.size());
- assertEquals("mainReferenced-r1",listed.get("a.r1"));
- assertEquals("mainReferenced-r2",listed.get("a.r2"));
+ Map<String, Object> listed = properties.listProperties();
+ assertEquals(2, listed.size());
+ assertEquals("mainReferenced-r1", listed.get("a.r1"));
+ assertEquals("mainReferenced-r2", listed.get("a.r2"));
// Context x=x1
- listed=properties.listProperties(toMap(main,new String[] {"x1"}));
- assertEquals(3,listed.size());
- assertEquals("variantReferenced-r1",listed.get("a.r1"));
- assertEquals("mainReferenced-r2",listed.get("a.r2"));
- assertEquals("variantReferenced-r3",listed.get("a.r3"));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
+ assertEquals(3, listed.size());
+ assertEquals("variantReferenced-r1", listed.get("a.r1"));
+ assertEquals("mainReferenced-r2", listed.get("a.r2"));
+ assertEquals("variantReferenced-r3", listed.get("a.r3"));
}
@Test
- public void testQueryProfileReferencesWithSubstitution() {
+ void testQueryProfileReferencesWithSubstitution() {
QueryProfile main = new QueryProfile("main");
- main.setDimensions(new String[] {"x1"});
+ main.setDimensions(new String[]{"x1"});
QueryProfile referencedMain = new QueryProfile("referencedMain");
- referencedMain.set("r1","%{prefix}mainReferenced-r1", null); // In both
- referencedMain.set("r2","%{prefix}mainReferenced-r2", 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", null); // In both
- referencedVariant.set("r3","%{prefix}variantReferenced-r3", null); // Only in this
+ referencedVariant.set("r1", "%{prefix}variantReferenced-r1", null); // In both
+ referencedVariant.set("r3", "%{prefix}variantReferenced-r3", null); // Only in this
referencedVariant.set("inthis", "local value", null);
- referencedVariant.set("r4","This has %{.inthis}", null); // Relative
+ referencedVariant.set("r4", "This has %{.inthis}", null); // Relative
main.set("a", referencedMain, null);
- main.set("a", referencedVariant,new String[] {"x1"}, null);
+ main.set("a", referencedVariant, new String[]{"x1"}, null);
main.set("prefix", "mainPrefix:", null);
- main.set("prefix", "variantPrefix:", new String[] {"x1"}, null);
+ main.set("prefix", "variantPrefix:", new String[]{"x1"}, null);
Properties properties = new QueryProfileProperties(main.compile(null));
// No context
- Map<String,Object> listed = properties.listProperties();
+ Map<String, Object> listed = properties.listProperties();
assertEquals(3, listed.size());
assertEquals("mainPrefix:mainReferenced-r1", listed.get("a.r1"));
assertEquals("mainPrefix:mainReferenced-r2", listed.get("a.r2"));
// Context x=x1
- listed = properties.listProperties(toMap(main, new String[] {"x1"}));
+ listed = properties.listProperties(toMap(main, new String[]{"x1"}));
assertEquals(6, listed.size());
assertEquals("variantPrefix:variantReferenced-r1", listed.get("a.r1"));
assertEquals("variantPrefix:mainReferenced-r2", listed.get("a.r2"));
@@ -1209,17 +1208,17 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testNewsCase1() {
+ void testNewsCase1() {
QueryProfile shortcuts = new QueryProfile("shortcuts");
- shortcuts.setDimensions(new String[] {"custid_1", "custid_2", "custid_3", "custid_4", "custid_5", "custid_6"});
+ shortcuts.setDimensions(new String[]{"custid_1", "custid_2", "custid_3", "custid_4", "custid_5", "custid_6"});
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);
+ shortcuts.set("testin", "inside", new String[]{"yahoo", "ca", "sc"}, null);
+ shortcuts.set("test.in", "dotinside", new String[]{"yahoo", "ca", "sc"}, null);
- QueryProfile profile=new QueryProfile("default");
- profile.setDimensions(new String[] {"custid_1","custid_2","custid_3","custid_4","custid_5","custid_6"});
- profile.addInherited(shortcuts, new String[] {"yahoo",null,"sc"});
+ QueryProfile profile = new QueryProfile("default");
+ profile.setDimensions(new String[]{"custid_1", "custid_2", "custid_3", "custid_4", "custid_5", "custid_6"});
+ profile.addInherited(shortcuts, new String[]{"yahoo", null, "sc"});
profile.freeze();
Query query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=yahoo&custid_2=ca&custid_3=sc", Method.GET), profile.compile(null));
@@ -1231,103 +1230,103 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testNewsCase2() {
- QueryProfile test=new QueryProfile("test");
+ void testNewsCase2() {
+ QueryProfile test = new QueryProfile("test");
test.setDimensions("sort,resulttypes,rss,age,intl,testid".split(","));
- String[] dimensionValues=new String[] {null,null,"0"};
- test.set("discovery","sources",dimensionValues, null);
- test.set("discoverytypes","article",dimensionValues, null);
- test.set("discovery.sources.count","10",dimensionValues, null);
+ String[] dimensionValues = new String[]{null, null, "0"};
+ test.set("discovery", "sources", dimensionValues, null);
+ test.set("discoverytypes", "article", dimensionValues, null);
+ test.set("discovery.sources.count", "10", dimensionValues, null);
CompiledQueryProfile ctest = test.compile(null);
- assertEquals("sources",ctest.get("discovery", toMap(test, dimensionValues)));
- assertEquals("article",ctest.get("discoverytypes", toMap(test, dimensionValues)));
- assertEquals("10",ctest.get("discovery.sources.count", toMap(test, dimensionValues)));
+ assertEquals("sources", ctest.get("discovery", toMap(test, dimensionValues)));
+ assertEquals("article", ctest.get("discoverytypes", toMap(test, dimensionValues)));
+ assertEquals("10", ctest.get("discovery.sources.count", toMap(test, dimensionValues)));
- Map<String,Object> values=ctest.listValues("",toMap(test,dimensionValues));
- assertEquals(3,values.size());
- assertEquals("sources",values.get("discovery"));
- assertEquals("article",values.get("discoverytypes"));
- assertEquals("10",values.get("discovery.sources.count"));
+ Map<String, Object> values = ctest.listValues("", toMap(test, dimensionValues));
+ assertEquals(3, values.size());
+ assertEquals("sources", values.get("discovery"));
+ assertEquals("article", values.get("discoverytypes"));
+ assertEquals("10", values.get("discovery.sources.count"));
- Map<String,Object> sourceValues=ctest.listValues("discovery.sources",toMap(test,dimensionValues));
- assertEquals(1,sourceValues.size());
- assertEquals("10",sourceValues.get("count"));
+ Map<String, Object> sourceValues = ctest.listValues("discovery.sources", toMap(test, dimensionValues));
+ assertEquals(1, sourceValues.size());
+ assertEquals("10", sourceValues.get("count"));
}
@Test
- public void testRuntimeAssignmentInClone() {
- QueryProfile test=new QueryProfile("test");
- test.setDimensions(new String[] {"x"});
- String[] x1=new String[] {"x1"};
- Map<String,String> x1m=toMap(test,x1);
- test.set("a","30",x1, null);
- test.set("a.b","20",x1, null);
- test.set("a.b.c","10",x1, null);
+ void testRuntimeAssignmentInClone() {
+ QueryProfile test = new QueryProfile("test");
+ test.setDimensions(new String[]{"x"});
+ String[] x1 = new String[]{"x1"};
+ Map<String, String> x1m = toMap(test, x1);
+ test.set("a", "30", x1, null);
+ test.set("a.b", "20", x1, null);
+ test.set("a.b.c", "10", x1, null);
// Setting in one profile works
Query qMain = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), test.compile(null));
- qMain.properties().set("a.b","50",x1m);
- assertEquals("50",qMain.properties().get("a.b",x1m));
+ qMain.properties().set("a.b", "50", x1m);
+ assertEquals("50", qMain.properties().get("a.b", x1m));
// Cloning
- Query qBranch=qMain.clone();
+ Query qBranch = qMain.clone();
// Setting in main still works
- qMain.properties().set("a.b","51",x1m);
- assertEquals("51",qMain.properties().get("a.b",x1m));
+ qMain.properties().set("a.b", "51", x1m);
+ assertEquals("51", qMain.properties().get("a.b", x1m));
// Clone is not affected by change in original
- assertEquals("50",qBranch.properties().get("a.b",x1m));
+ assertEquals("50", qBranch.properties().get("a.b", x1m));
// Setting in clone works
- qBranch.properties().set("a.b","70",x1m);
- assertEquals("70",qBranch.properties().get("a.b",x1m));
+ qBranch.properties().set("a.b", "70", x1m);
+ assertEquals("70", qBranch.properties().get("a.b", x1m));
// Setting in clone does not affect original
- assertEquals("51",qMain.properties().get("a.b",x1m));
+ assertEquals("51", qMain.properties().get("a.b", x1m));
}
@Test
- public void testIncompatibleDimensions() {
+ void testIncompatibleDimensions() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
- backendBase.setDimensions(new String[] { "sort", "resulttypes", "rss" });
+ backendBase.setDimensions(new String[]{"sort", "resulttypes", "rss"});
backendBase.set("custid", "s", null);
QueryProfile backend = new QueryProfile("backend");
- backend.setDimensions(new String[] { "sort", "offset", "resulttypes", "rss", "age", "lang", "fr", "entry" });
+ backend.setDimensions(new String[]{"sort", "offset", "resulttypes", "rss", "age", "lang", "fr", "entry"});
backend.addInherited(backendBase);
QueryProfile web = new QueryProfile("web");
- web.setDimensions(new String[] { "entry", "recency" });
- web.set("fr", "alerts", new String[] { "alert" }, null);
+ web.setDimensions(new String[]{"entry", "recency"});
+ web.set("fr", "alerts", new String[]{"alert"}, 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);
+ 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() {
+ void testIncompatibleDimensionsSimplified() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
backendBase.set("custid", "s", null);
QueryProfile backend = new QueryProfile("backend");
- backend.setDimensions(new String[] { "sort", "lang", "fr", "entry" });
- backend.set("custid", "yahoo/alerts", new String[] { null, "en-US", null, "alert"}, null);
+ backend.setDimensions(new String[]{"sort", "lang", "fr", "entry"});
+ backend.set("custid", "yahoo/alerts", new String[]{null, "en-US", null, "alert"}, null);
backend.addInherited(backendBase);
QueryProfile web = new QueryProfile("web");
- web.setDimensions(new String[] { "entry", "recency" });
- web.set("fr", "alerts", new String[] { "alert" }, null);
+ web.setDimensions(new String[]{"entry", "recency"});
+ web.set("fr", "alerts", new String[]{"alert"}, null);
alert.set("vertical", backend, null);
alert.set("multimedia", web, null);
@@ -1337,23 +1336,23 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testZoneInfoInContext() {
+ void testZoneInfoInContext() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "environment", "region", "instance" });
+ profile.setDimensions(new String[]{"environment", "region", "instance"});
profile.set("value", "default", registry);
profile.set("value", "prod-region1-instance1",
- toMap("environment=prod", "region=region1", "instance=instance1"),
- registry);
+ toMap("environment=prod", "region=region1", "instance=instance1"),
+ registry);
profile.set("value", "prod-instance2",
- toMap("environment=prod", "instance=instance2"),
- registry);
+ toMap("environment=prod", "instance=instance2"),
+ registry);
profile.set("value", "prod-region3",
- toMap("environment=prod", "region=region3"),
- registry);
+ toMap("environment=prod", "region=region3"),
+ registry);
profile.set("value", "dev",
- toMap("environment=dev"),
- registry);
+ toMap("environment=dev"),
+ registry);
registry.register(profile);
CompiledQueryProfileRegistry cRegistry = registry.compile();
@@ -1361,36 +1360,36 @@ public class QueryProfileVariantsTestCase {
assertValueForZone("default", ZoneInfo.defaultInfo(), null, cTest);
assertValueForZone("prod-region1-instance1",
- new ZoneInfo(new ApplicationId("tenant1", "application1", "instance1"),
- new Zone(Environment.prod, "region1")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant1", "application1", "instance1"),
+ new Zone(Environment.prod, "region1")),
+ null,
+ cTest);
assertValueForZone("prod-instance2",
- new ZoneInfo(new ApplicationId("tenant2", "application2", "instance2"),
- new Zone(Environment.prod, "region1")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant2", "application2", "instance2"),
+ new Zone(Environment.prod, "region1")),
+ null,
+ cTest);
assertValueForZone("prod-region3",
- new ZoneInfo(new ApplicationId("tenant3", "application3", "instance3"),
- new Zone(Environment.prod, "region3")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant3", "application3", "instance3"),
+ new Zone(Environment.prod, "region3")),
+ null,
+ cTest);
assertValueForZone("dev",
- new ZoneInfo(new ApplicationId("tenant4", "application4", "instance4"),
- new Zone(Environment.dev, "region4")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant4", "application4", "instance4"),
+ new Zone(Environment.dev, "region4")),
+ null,
+ cTest);
}
@Test
- public void testZoneInfoInContextWithUnoverridability() {
+ void testZoneInfoInContextWithUnoverridability() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "instance", "environment", "region" });
+ profile.setDimensions(new String[]{"instance", "environment", "region"});
profile.set("value", "default", registry);
profile.set("value", "prod-beta",
- toMap("environment=prod", "instance=beta"),
- registry);
+ toMap("environment=prod", "instance=beta"),
+ registry);
profile.setOverridable("value", false, toMap("environment=prod", "instance=beta"));
registry.register(profile);
@@ -1398,10 +1397,10 @@ public class QueryProfileVariantsTestCase {
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
assertValueForZone("prod-beta",
- new ZoneInfo(new ApplicationId("tenant1", "application1", "beta"),
- new Zone(Environment.prod, "region1")),
- "fromRequest",
- cTest);
+ new ZoneInfo(new ApplicationId("tenant1", "application1", "beta"),
+ new Zone(Environment.prod, "region1")),
+ "fromRequest",
+ cTest);
}
@@ -1413,23 +1412,23 @@ public class QueryProfileVariantsTestCase {
}
@Test
- public void testZoneInfoInContextSettingNativeProperty() {
+ void testZoneInfoInContextSettingNativeProperty() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
- profile.setDimensions(new String[] { "instance", "environment", "region" });
+ profile.setDimensions(new String[]{"instance", "environment", "region"});
profile.set("timeout", "0.3",
- toMap("environment=prod", "instance=beta"),
- registry);
+ toMap("environment=prod", "instance=beta"),
+ registry);
registry.register(profile);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
assertTimeoutForZone(300,
- new ZoneInfo(new ApplicationId("tenant1", "application1", "beta"),
- new Zone(Environment.prod, "region1")),
- null,
- cTest);
+ new ZoneInfo(new ApplicationId("tenant1", "application1", "beta"),
+ new Zone(Environment.prod, "region1")),
+ null,
+ cTest);
}
private void assertTimeoutForZone(int expected, ZoneInfo zoneInfo, String requestValue, CompiledQueryProfile cTest) {
@@ -1441,8 +1440,7 @@ public class QueryProfileVariantsTestCase {
private void assertGet(String expectedValue, String parameter, String[] dimensionValues, QueryProfile profile, CompiledQueryProfile cprofile) {
Map<String, String> context = toMap(profile,dimensionValues);
- assertEquals("Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'",
- expectedValue, cprofile.get(parameter,context));
+ assertEquals(expectedValue, cprofile.get(parameter,context), "Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'");
}
public static Map<String,String> toMap(QueryProfile profile, String[] dimensionValues) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java
index 0ace8f93f1d..b245648b861 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/FieldTypeTestCase.java
@@ -4,9 +4,9 @@ package com.yahoo.search.query.profile.types.test;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -14,14 +14,14 @@ import static org.junit.Assert.assertEquals;
public class FieldTypeTestCase {
@Test
- public void testConvertToFromString() {
- QueryProfileTypeRegistry registry=new QueryProfileTypeRegistry();
+ void testConvertToFromString() {
+ QueryProfileTypeRegistry registry = new QueryProfileTypeRegistry();
registry.register(new QueryProfileType("foo"));
- assertEquals("string", FieldType.fromString("string",registry).stringValue());
- assertEquals("boolean", FieldType.fromString("boolean",registry).stringValue());
- assertEquals("query-profile", FieldType.fromString("query-profile",registry).stringValue());
- assertEquals("query-profile:foo", FieldType.fromString("query-profile:foo",registry).stringValue());
+ assertEquals("string", FieldType.fromString("string", registry).stringValue());
+ assertEquals("boolean", FieldType.fromString("boolean", registry).stringValue());
+ assertEquals("query-profile", FieldType.fromString("query-profile", registry).stringValue());
+ assertEquals("query-profile:foo", FieldType.fromString("query-profile:foo", registry).stringValue());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java
index dfe4b24e256..5bde89d0282 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/MandatoryTestCase.java
@@ -13,9 +13,9 @@ import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -55,18 +55,18 @@ public class MandatoryTestCase {
}
@Test
- public void testMandatoryFullySpecifiedQueryProfile() {
+ void testMandatoryFullySpecifiedQueryProfile() {
Fixture1 fixture = new Fixture1();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(fixture.type);
test.set("myString", "aString", fixture.registry);
fixture.registry.register(test);
- QueryProfile myUser=new QueryProfile("user");
+ QueryProfile myUser = new QueryProfile("user");
myUser.setType(fixture.user);
- myUser.set("myUserInteger",1, fixture.registry);
- myUser.set("myUserString",1, fixture.registry);
+ myUser.set("myUserInteger", 1, fixture.registry);
+ myUser.set("myUserString", 1, fixture.registry);
test.set("myUserQueryProfile", myUser, fixture.registry);
fixture.registry.register(myUser);
@@ -77,7 +77,7 @@ public class MandatoryTestCase {
}
@Test
- public void testMandatoryRequestPropertiesNeeded() {
+ void testMandatoryRequestPropertiesNeeded() {
Fixture1 fixture = new Fixture1();
QueryProfile test = new QueryProfile("test");
@@ -94,11 +94,11 @@ public class MandatoryTestCase {
// Underspecified request 1
assertError("Incomplete query: Parameter 'myString' is mandatory in query profile 'test' of type 'testtype' but is not set",
- new Query(HttpRequest.createTestRequest("", Method.GET), cRegistry.getComponent("test")));
+ new Query(HttpRequest.createTestRequest("", Method.GET), cRegistry.getComponent("test")));
// Underspecified request 2
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", Method.GET), cRegistry.getComponent("test")));
+ new Query(HttpRequest.createTestRequest("?myString=aString", Method.GET), cRegistry.getComponent("test")));
// Fully specified request
assertError(null, new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("test")));
@@ -106,7 +106,7 @@ public class MandatoryTestCase {
/** Same as above except the whole thing is nested in maps */
@Test
- public void testMandatoryNestedInMaps() {
+ void testMandatoryNestedInMaps() {
Fixture1 fixture = new Fixture1();
QueryProfile topMap = new QueryProfile("topMap");
@@ -123,7 +123,7 @@ public class MandatoryTestCase {
QueryProfile myUser = new QueryProfile("user");
myUser.setType(fixture.user);
- myUser.set("myUserInteger",1, fixture.registry);
+ myUser.set("myUserInteger", 1, fixture.registry);
test.set("myUserQueryProfile", myUser, fixture.registry);
fixture.registry.register(myUser);
@@ -132,11 +132,11 @@ public class MandatoryTestCase {
// 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")));
+ 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")));
+ 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")));
@@ -144,7 +144,7 @@ public class MandatoryTestCase {
/** Here, no user query profile is referenced in the query profile, but one is chosen in the request */
@Test
- public void testMandatoryUserProfileSetInRequest() {
+ void testMandatoryUserProfileSetInRequest() {
Fixture1 fixture = new Fixture1();
QueryProfile test = new QueryProfile("test");
@@ -161,11 +161,11 @@ public class MandatoryTestCase {
// 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")));
+ 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")));
+ 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")));
@@ -173,7 +173,7 @@ public class MandatoryTestCase {
/** Here, a partially specified query profile is added to a non-mandatory field, making the request underspecified */
@Test
- public void testNonMandatoryUnderspecifiedUserProfileSetInRequest() {
+ void testNonMandatoryUnderspecifiedUserProfileSetInRequest() {
Fixture1 fixture = new Fixture1();
QueryProfile test = new QueryProfile("test");
@@ -199,7 +199,7 @@ public class MandatoryTestCase {
// Underspecified because an underspecified profile is added
assertError("Incomplete query: Parameter 'myQueryProfile.myUserString' is mandatory in query profile 'test' of type 'testtype' but is not set",
- new Query(HttpRequest.createTestRequest("?myString=aString&myQueryProfile=otherUser", Method.GET), cRegistry.getComponent("test")));
+ new Query(HttpRequest.createTestRequest("?myString=aString&myQueryProfile=otherUser", Method.GET), cRegistry.getComponent("test")));
// Back to fully specified
assertError(null, new Query(HttpRequest.createTestRequest("?myString=aString&myQueryProfile=otherUser&myQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("test")));
@@ -223,7 +223,7 @@ public class MandatoryTestCase {
}
@Test
- public void testMandatoryInParentType() {
+ void testMandatoryInParentType() {
Fixture2 fixture = new Fixture2();
QueryProfile defaultProfile = new QueryProfile("default");
@@ -237,11 +237,11 @@ public class MandatoryTestCase {
CompiledQueryProfileRegistry cRegistry = fixture.registry.compile();
assertError("Incomplete query: Parameter 'foobar' is mandatory in query profile 'mandatory' of type 'mandatory-type' but is not set",
- new Query(QueryTestCase.httpEncode("?queryProfile=mandatory"), cRegistry.getComponent("mandatory")));
+ new Query(QueryTestCase.httpEncode("?queryProfile=mandatory"), cRegistry.getComponent("mandatory")));
}
@Test
- public void testMandatoryInParentTypeWithInheritance() {
+ void testMandatoryInParentTypeWithInheritance() {
Fixture2 fixture = new Fixture2();
QueryProfile defaultProfile = new QueryProfile("default");
@@ -256,7 +256,7 @@ public class MandatoryTestCase {
CompiledQueryProfileRegistry cRegistry = fixture.registry.compile();
assertError("Incomplete query: Parameter 'foobar' is mandatory in query profile 'mandatory' of type 'mandatory-type' but is not set",
- new Query(QueryTestCase.httpEncode("?queryProfile=mandatory"), cRegistry.getComponent("mandatory")));
+ new Query(QueryTestCase.httpEncode("?queryProfile=mandatory"), cRegistry.getComponent("mandatory")));
}
private void assertError(String message,Query query) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
index fa7508ea5ac..37991f7f14f 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
@@ -8,10 +8,10 @@ import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* tests creating invalid names
@@ -21,7 +21,7 @@ import static org.junit.Assert.fail;
public class NameTestCase {
@Test
- public void testNames() {
+ void testNames() {
assertLegalName("aB");
assertIllegalName("a.");
assertLegalName("_a_b");
@@ -33,11 +33,11 @@ public class NameTestCase {
}
@Test
- public void testFieldNames() {
+ void testFieldNames() {
assertLegalFieldName("aB");
try {
- QueryProfile profile=new QueryProfile("test");
- profile.set("a.","anyValue", (QueryProfileRegistry)null);
+ QueryProfile profile = new QueryProfile("test");
+ profile.set("a.", "anyValue", (QueryProfileRegistry) null);
fail("Should have failed");
} catch (IllegalArgumentException e) {
assertEquals("'a.' is not a legal compound name. Names can not end with a dot.", e.getMessage());
@@ -48,12 +48,12 @@ public class NameTestCase {
assertLegalFieldName("/a/b");
assertLegalFieldName("/a/b/");
assertIllegalFieldName("aBc.dooEee.ce_d.-some-other.moreHere",
- "Could not set 'aBc.dooEee.ce_d.-some-other.moreHere' to 'anyValue'",
- "Illegal name '-some-other'");
+ "Could not set 'aBc.dooEee.ce_d.-some-other.moreHere' to 'anyValue'",
+ "Illegal name '-some-other'");
}
@Test
- public void testComponentIdAsCompoundName() {
+ void testComponentIdAsCompoundName() {
String name = "a/b";
assertEquals(new CompoundName(name), new QueryProfileType(name).getComponentIdAsCompoundName());
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java
index 6f884650b5d..72499002ba9 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NativePropertiesTestCase.java
@@ -7,10 +7,10 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.yolean.Exceptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests that properties can not be set even if they are native, if declared not settable in the query profile
@@ -20,7 +20,7 @@ import static org.junit.Assert.fail;
public class NativePropertiesTestCase {
@Test
- public void testNativeInStrict() {
+ void testNativeInStrict() {
QueryProfileType strictType = new QueryProfileType("strict");
strictType.setStrict(true);
QueryProfile strict = new QueryProfile("profile");
@@ -39,7 +39,7 @@ public class NativePropertiesTestCase {
} catch (IllegalArgumentException e) {
// As expected.
assertTrue(Exceptions.toMessageString(e).contains(
- "Could not set 'notnative' to '5':"
+ "Could not set 'notnative' to '5':"
+ " 'notnative' is not declared in query profile type 'strict', and the type is strict"));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java
index 906d43790bd..69d577719c5 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/OverrideTestCase.java
@@ -13,10 +13,10 @@ import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests overriding of field values
@@ -29,7 +29,7 @@ public class OverrideTestCase {
private QueryProfileType type, user;
- @Before
+ @BeforeEach
public void setUp() {
type=new QueryProfileType(new ComponentId("testtype"));
user=new QueryProfileType(new ComponentId("user"));
@@ -60,38 +60,38 @@ public class OverrideTestCase {
/** Check that a simple non-overridable string cannot be overridden */
@Test
- public void testSimpleUnoverridable() {
+ void testSimpleUnoverridable() {
QueryProfileRegistry registry = new QueryProfileRegistry();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(type);
- test.set("myString","finalString", (QueryProfileRegistry)null);
+ 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"));
+ 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"));
+ query.properties().set("myString", "newValue");
+ assertEquals("finalString", query.properties().get("myString"));
}
/** Check that a query profile cannot be overridden */
@Test
- public void testUnoverridableQueryProfile() {
+ void testUnoverridableQueryProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
registry.register(test);
- QueryProfile myUser=new QueryProfile("user");
+ QueryProfile myUser = new QueryProfile("user");
myUser.setType(user);
- myUser.set("myUserInteger",1, registry);
- myUser.set("myUserString","userValue", registry);
- test.set("myUserQueryProfile",myUser, registry);
+ myUser.set("myUserInteger", 1, registry);
+ myUser.set("myUserString", "userValue", registry);
+ test.set("myUserQueryProfile", myUser, registry);
registry.register(myUser);
QueryProfile otherUser = new QueryProfile("otherUser");
@@ -102,52 +102,52 @@ public class OverrideTestCase {
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"));
+ assertEquals(0, query.errors().size());
+ assertEquals(1, query.properties().get("myUserQueryProfile.myUserInteger"));
}
/** Check that non-overridables are protected also in nested untyped references */
@Test
- public void testUntypedNestedUnoverridable() {
+ void testUntypedNestedUnoverridable() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile topMap = new QueryProfile("topMap");
registry.register(topMap);
- QueryProfile subMap=new QueryProfile("topSubMap");
- topMap.set("subMap",subMap, registry);
+ 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);
+ subMap.set("test", test, registry);
registry.register(test);
- QueryProfile myUser=new QueryProfile("user");
+ QueryProfile myUser = new QueryProfile("user");
myUser.setType(user);
- myUser.set("myUserString","finalValue", registry);
- test.set("myUserQueryProfile",myUser, registry);
+ 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"));
+ 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"));
+ query.properties().set("subMap.test.myUserQueryProfile.myUserString", "newValue");
+ assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
}
/** Tests overridability in an inherited field */
@Test
- public void testInheritedNonOverridableInType() {
+ void testInheritedNonOverridableInType() {
QueryProfileRegistry registry = new QueryProfileRegistry();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(type);
- test.set("myString","finalString", (QueryProfileRegistry)null);
+ test.set("myString", "finalString", (QueryProfileRegistry) null);
registry.register(test);
- QueryProfile profile=new QueryProfile("profile");
+ QueryProfile profile = new QueryProfile("profile");
profile.addInherited(test);
registry.register(profile);
@@ -155,16 +155,16 @@ public class OverrideTestCase {
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"));
+ assertEquals(0, query.errors().size());
+ assertEquals("finalString", query.properties().get("myString"));
- query.properties().set("myString","newString");
- assertEquals("finalString",query.properties().get("myString"));
+ query.properties().set("myString", "newString");
+ assertEquals("finalString", query.properties().get("myString"));
}
/** Tests overridability in an inherited field */
@Test
- public void testInheritedNonOverridableInProfile() {
+ void testInheritedNonOverridableInProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
@@ -172,7 +172,7 @@ public class OverrideTestCase {
test.setOverridable("myInteger", false, DimensionValues.empty);
registry.register(test);
- QueryProfile profile=new QueryProfile("profile");
+ QueryProfile profile = new QueryProfile("profile");
profile.addInherited(test);
registry.register(profile);
@@ -180,11 +180,11 @@ public class OverrideTestCase {
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"));
+ assertEquals(0, query.errors().size());
+ assertEquals(1, query.properties().get("myInteger"));
- query.properties().set("myInteger",32);
- assertEquals(1,query.properties().get("myInteger"));
+ query.properties().set("myInteger", 32);
+ assertEquals(1, query.properties().get("myInteger"));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java
index d39bfa13126..58d92d84e94 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/PatchMatchingTestCase.java
@@ -4,10 +4,10 @@ package com.yahoo.search.query.profile.types.test;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Tests that matching query profiles by path name works
@@ -17,62 +17,62 @@ import static org.junit.Assert.assertNull;
public class PatchMatchingTestCase {
@Test
- public void testPatchMatching() {
- QueryProfileType type=new QueryProfileType("type");
+ void testPatchMatching() {
+ QueryProfileType type = new QueryProfileType("type");
type.setMatchAsPath(true);
- QueryProfile a=new QueryProfile("a");
+ QueryProfile a = new QueryProfile("a");
a.setType(type);
- QueryProfile abee=new QueryProfile("a/bee");
+ QueryProfile abee = new QueryProfile("a/bee");
abee.setType(type);
abee.addInherited(a);
- QueryProfile abeece=new QueryProfile("a/bee/ce");
+ QueryProfile abeece = new QueryProfile("a/bee/ce");
abeece.setType(type);
abeece.addInherited(abee);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee);
registry.register(abeece);
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("a",registry.findQueryProfile("a").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee/cede").getId().getName());
- assertEquals("a",registry.findQueryProfile("a/foo/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
assertNull(registry.findQueryProfile("abee"));
}
@Test
- public void testNoPatchMatching() {
- QueryProfileType type=new QueryProfileType("type");
+ void testNoPatchMatching() {
+ QueryProfileType type = new QueryProfileType("type");
type.setMatchAsPath(false); // Default, but set here for clarity
- QueryProfile a=new QueryProfile("a");
+ QueryProfile a = new QueryProfile("a");
a.setType(type);
- QueryProfile abee=new QueryProfile("a/bee");
+ QueryProfile abee = new QueryProfile("a/bee");
abee.setType(type);
abee.addInherited(a);
- QueryProfile abeece=new QueryProfile("a/bee/ce");
+ QueryProfile abeece = new QueryProfile("a/bee/ce");
abeece.setType(type);
abeece.addInherited(abee);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee);
registry.register(abeece);
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("a",registry.findQueryProfile("a").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
assertNull(registry.findQueryProfile("a/bee/ce/dee")); // Different from test above
assertNull(registry.findQueryProfile("a/bee/ce/dee/eee/")); // Different from test above
assertNull(registry.findQueryProfile("a/bee/cede")); // Different from test above
@@ -82,59 +82,59 @@ public class PatchMatchingTestCase {
/** Check that the path matching property is inherited to subtypes */
@Test
- public void testPatchMatchingInheritance() {
- QueryProfileType type=new QueryProfileType("type");
- QueryProfileType subType=new QueryProfileType("subType");
+ void testPatchMatchingInheritance() {
+ QueryProfileType type = new QueryProfileType("type");
+ QueryProfileType subType = new QueryProfileType("subType");
subType.inherited().add(type);
type.setMatchAsPath(true); // Supertype only
- QueryProfile a=new QueryProfile("a");
+ QueryProfile a = new QueryProfile("a");
a.setType(type);
- QueryProfile abee=new QueryProfile("a/bee");
+ QueryProfile abee = new QueryProfile("a/bee");
abee.setType(subType);
abee.addInherited(a);
- QueryProfile abeece=new QueryProfile("a/bee/ce");
+ QueryProfile abeece = new QueryProfile("a/bee/ce");
abeece.setType(subType);
abeece.addInherited(abee);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee);
registry.register(abeece);
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("a",registry.findQueryProfile("a").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
- assertEquals("a/bee",registry.findQueryProfile("a/bee/cede").getId().getName());
- assertEquals("a",registry.findQueryProfile("a/foo/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
+ assertEquals("a/bee", registry.findQueryProfile("a/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
assertNull(registry.findQueryProfile("abee"));
}
/** Check that the path matching works with versioned profiles */
@Test
- public void testPatchMatchingVersions() {
- QueryProfileType type=new QueryProfileType("type");
+ void testPatchMatchingVersions() {
+ QueryProfileType type = new QueryProfileType("type");
type.setMatchAsPath(true);
- QueryProfile a=new QueryProfile("a");
+ QueryProfile a = new QueryProfile("a");
a.setType(type);
- QueryProfile abee11=new QueryProfile("a/bee:1.1");
+ QueryProfile abee11 = new QueryProfile("a/bee:1.1");
abee11.setType(type);
abee11.addInherited(a);
- QueryProfile abee13=new QueryProfile("a/bee:1.3");
+ QueryProfile abee13 = new QueryProfile("a/bee:1.3");
abee13.setType(type);
abee13.addInherited(a);
- QueryProfile abeece=new QueryProfile("a/bee/ce");
+ QueryProfile abeece = new QueryProfile("a/bee/ce");
abeece.setType(type);
abeece.addInherited(abee13);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee11);
registry.register(abee13);
@@ -142,52 +142,52 @@ public class PatchMatchingTestCase {
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("a",registry.findQueryProfile("a").getId().getName());
- assertEquals("a/bee:1.1",registry.findQueryProfile("a/bee:1.1").getId().toString());
- assertEquals("a/bee:1.3",registry.findQueryProfile("a/bee").getId().toString());
- assertEquals("a/bee:1.3",registry.findQueryProfile("a/bee:1").getId().toString());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee").getId().getName());
- assertEquals("a/bee/ce",registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
- assertEquals("a/bee:1.1",registry.findQueryProfile("a/bee/cede:1.1").getId().toString());
- assertEquals("a/bee:1.3",registry.findQueryProfile("a/bee/cede").getId().toString());
- assertEquals("a/bee:1.3",registry.findQueryProfile("a/bee/cede:1").getId().toString());
- assertEquals("a",registry.findQueryProfile("a/foo/bee/cede").getId().getName());
+ assertEquals("a", registry.findQueryProfile("a").getId().getName());
+ assertEquals("a/bee:1.1", registry.findQueryProfile("a/bee:1.1").getId().toString());
+ assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee").getId().toString());
+ assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee:1").getId().toString());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
+ assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
+ assertEquals("a/bee:1.1", registry.findQueryProfile("a/bee/cede:1.1").getId().toString());
+ assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee/cede").getId().toString());
+ assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee/cede:1").getId().toString());
+ assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
assertNull(registry.findQueryProfile("abee"));
}
@Test
- public void testQuirkyNames() {
- QueryProfileType type=new QueryProfileType("type");
+ void testQuirkyNames() {
+ QueryProfileType type = new QueryProfileType("type");
type.setMatchAsPath(true);
- QueryProfile a=new QueryProfile("/a");
+ QueryProfile a = new QueryProfile("/a");
a.setType(type);
- QueryProfile abee=new QueryProfile("/a//bee");
+ QueryProfile abee = new QueryProfile("/a//bee");
abee.setType(type);
abee.addInherited(a);
- QueryProfile abeece=new QueryProfile("/a//bee/ce/");
+ QueryProfile abeece = new QueryProfile("/a//bee/ce/");
abeece.setType(type);
abeece.addInherited(abee);
- QueryProfileRegistry registry=new QueryProfileRegistry();
+ QueryProfileRegistry registry = new QueryProfileRegistry();
registry.register(a);
registry.register(abee);
registry.register(abeece);
registry.freeze();
assertNull(registry.findQueryProfile(null)); // No "default" registered
- assertEquals("/a",registry.findQueryProfile("/a").getId().getName());
+ assertEquals("/a", registry.findQueryProfile("/a").getId().getName());
assertNull(registry.findQueryProfile("a"));
- assertEquals("/a//bee",registry.findQueryProfile("/a//bee").getId().getName());
- assertEquals("/a//bee/ce/",registry.findQueryProfile("/a//bee/ce/").getId().getName());
- assertEquals("/a//bee/ce/",registry.findQueryProfile("/a//bee/ce").getId().getName());
- assertEquals("/a//bee/ce/",registry.findQueryProfile("/a//bee/ce/dee").getId().getName());
- assertEquals("/a//bee/ce/",registry.findQueryProfile("/a//bee/ce/dee/eee/").getId().getName());
- assertEquals("/a//bee",registry.findQueryProfile("/a//bee/cede").getId().getName());
- assertEquals("/a",registry.findQueryProfile("/a/foo/bee/cede").getId().getName());
- assertEquals("/a",registry.findQueryProfile("/a/bee").getId().getName());
+ assertEquals("/a//bee", registry.findQueryProfile("/a//bee").getId().getName());
+ assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/").getId().getName());
+ assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce").getId().getName());
+ assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/dee").getId().getName());
+ assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/dee/eee/").getId().getName());
+ assertEquals("/a//bee", registry.findQueryProfile("/a//bee/cede").getId().getName());
+ assertEquals("/a", registry.findQueryProfile("/a/foo/bee/cede").getId().getName());
+ assertEquals("/a", registry.findQueryProfile("/a/bee").getId().getName());
assertNull(registry.findQueryProfile("abee"));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java
index 62551447017..cc7b5c4d666 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeInheritanceTestCase.java
@@ -9,13 +9,10 @@ import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -26,7 +23,7 @@ public class QueryProfileTypeInheritanceTestCase {
private QueryProfileType type, typeStrict, user, userStrict;
- @Before
+ @BeforeEach
public void setUp() {
type=new QueryProfileType(new ComponentId("testtype"));
typeStrict=new QueryProfileType(new ComponentId("testtypeStrict"));
@@ -63,7 +60,7 @@ public class QueryProfileTypeInheritanceTestCase {
}
@Test
- public void testInheritance() {
+ void testInheritance() {
type.inherited().add(user);
type.freeze();
user.freeze();
@@ -71,11 +68,11 @@ public class QueryProfileTypeInheritanceTestCase {
assertFalse(type.isOverridable("myUserString"));
assertEquals("myUserInteger", type.getField("myUserInteger").getName());
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(type);
- test.set("myUserInteger","37", (QueryProfileRegistry)null);
- test.set("myUnknownInteger","38", (QueryProfileRegistry)null);
+ test.set("myUserInteger", "37", (QueryProfileRegistry) null);
+ test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
CompiledQueryProfile ctest = test.compile(null);
assertEquals(37, ctest.get("myUserInteger"));
@@ -83,45 +80,45 @@ public class QueryProfileTypeInheritanceTestCase {
}
@Test
- public void testInheritanceStrict() {
+ void testInheritanceStrict() {
typeStrict.inherited().add(userStrict);
typeStrict.freeze();
userStrict.freeze();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(typeStrict);
- test.set("myUserInteger","37", (QueryProfileRegistry)null);
+ test.set("myUserInteger", "37", (QueryProfileRegistry) null);
try {
- test.set("myUnknownInteger","38", (QueryProfileRegistry)null);
+ 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());
+ e.getCause().getMessage());
}
- assertEquals(37,test.get("myUserInteger"));
+ assertEquals(37, test.get("myUserInteger"));
assertNull(test.get("myUnknownInteger"));
}
@Test
- public void testStrictIsInherited() {
+ void testStrictIsInherited() {
type.inherited().add(userStrict);
type.freeze();
userStrict.freeze();
- QueryProfile test=new QueryProfile("test");
+ QueryProfile test = new QueryProfile("test");
test.setType(type);
- test.set("myUserInteger","37", (QueryProfileRegistry)null);
+ test.set("myUserInteger", "37", (QueryProfileRegistry) null);
try {
- test.set("myUnknownInteger","38", (QueryProfileRegistry)null);
+ test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
fail("Should have failed");
}
catch (IllegalArgumentException e) {
assertEquals("'myUnknownInteger' is not declared in query profile type 'testtype', and the type is strict",
- e.getCause().getMessage());
+ e.getCause().getMessage());
}
CompiledQueryProfile ctest = test.compile(null);
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java
index a77de954b3a..21a9b2fe399 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java
@@ -19,19 +19,15 @@ import com.yahoo.search.query.profile.types.FieldDescription;
import com.yahoo.search.query.profile.types.FieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* tests query profiles with/and types
@@ -44,7 +40,7 @@ public class QueryProfileTypeTestCase {
private QueryProfileType testtype, emptyInheritingTesttype, testtypeStrict, user, userStrict;
- @Before
+ @BeforeEach
public void setUp() {
registry = new QueryProfileRegistry();
@@ -95,24 +91,24 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testTypedOfPrimitivesAssignmentNonStrict() {
+ void testTypedOfPrimitivesAssignmentNonStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
registry.register(profile);
profile.set("myString", "anyValue", registry);
profile.set("nontypedString", "anyValueToo", registry); // legal because this is not strict
- assertWrongType(profile,"integer", "myInteger","notInteger");
+ assertWrongType(profile, "integer", "myInteger", "notInteger");
assertWrongType(profile, "integer", "myInteger", "1.5");
profile.set("myInteger", 3, registry);
- assertWrongType(profile,"long","myLong","notLong");
+ assertWrongType(profile, "long", "myLong", "notLong");
assertWrongType(profile, "long", "myLong", "1.5");
profile.set("myLong", 4000000000000L, registry);
assertWrongType(profile, "float", "myFloat", "notFloat");
profile.set("myFloat", 3.14f, registry);
assertWrongType(profile, "double", "myDouble", "notDouble");
- profile.set("myDouble",2.18, registry);
- profile.set("myBoolean",true, registry);
+ profile.set("myDouble", 2.18, registry);
+ profile.set("myBoolean", true, registry);
String tensorString1 = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
profile.set("ranking.features.query(myTensor1)", tensorString1, registry);
@@ -122,12 +118,12 @@ public class QueryProfileTypeTestCase {
profile.set("ranking.features.query(myTensor3)", tensorString3, registry);
profile.set("myQuery", "...", registry); // TODO
- profile.set("myQueryProfile.anyString","value1", registry);
- profile.set("myQueryProfile.anyDouble",8.76, registry);
- profile.set("myUserQueryProfile.myUserString","value2", registry);
+ profile.set("myQueryProfile.anyString", "value1", registry);
+ profile.set("myQueryProfile.anyDouble", 8.76, registry);
+ profile.set("myUserQueryProfile.myUserString", "value2", registry);
profile.set("myUserQueryProfile.anyString", "value3", registry); // Legal because user is not strict
assertWrongType(profile, "integer", "myUserQueryProfile.myUserInteger", "notInteger");
- profile.set("myUserQueryProfile.uint",1337, registry); // Set using alias
+ profile.set("myUserQueryProfile.uint", 1337, registry); // Set using alias
profile.set("myUserQueryProfile.anyDouble", 9.13, registry); // Legal because user is not strict
CompiledQueryProfileRegistry cRegistry = registry.compile();
@@ -162,22 +158,22 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testTypedOfPrimitivesAssignmentStrict() {
+ void testTypedOfPrimitivesAssignmentStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtypeStrict);
profile.set("myString", "anyValue", registry);
assertNotPermitted(profile, "nontypedString", "anyValueToo"); // Illegal because this is strict
- assertWrongType(profile,"integer","myInteger","notInteger");
+ assertWrongType(profile, "integer", "myInteger", "notInteger");
assertWrongType(profile, "integer", "myInteger", "1.5");
profile.set("myInteger", 3, registry);
- assertWrongType(profile,"long","myLong","notLong");
+ assertWrongType(profile, "long", "myLong", "notLong");
assertWrongType(profile, "long", "myLong", "1.5");
profile.set("myLong", 4000000000000L, registry);
assertWrongType(profile, "float", "myFloat", "notFloat");
profile.set("myFloat", 3.14f, registry);
assertWrongType(profile, "double", "myDouble", "notDouble");
- profile.set("myDouble",2.18, registry);
+ profile.set("myDouble", 2.18, registry);
profile.set("myQueryProfile.anyString", "value1", registry);
profile.set("myQueryProfile.anyDouble", 8.76, registry);
profile.set("myUserQueryProfile.myUserString", "value2", registry);
@@ -204,22 +200,22 @@ public class QueryProfileTypeTestCase {
/** Tests assigning a subprofile directly */
@Test
- public void testTypedAssignmentOfQueryProfilesNonStrict() {
+ void testTypedAssignmentOfQueryProfilesNonStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
- QueryProfile map1=new QueryProfile("myMap1");
+ QueryProfile map1 = new QueryProfile("myMap1");
map1.set("key1", "value1", registry);
- QueryProfile map2=new QueryProfile("myMap2");
+ QueryProfile map2 = new QueryProfile("myMap2");
map2.set("key2", "value2", registry);
- QueryProfile myUser=new QueryProfile("myUser");
+ QueryProfile myUser = new QueryProfile("myUser");
myUser.setType(user);
myUser.set("myUserString", "userValue1", registry);
myUser.set("myUserInteger", 442, registry);
- assertWrongType(profile,"reference to a query profile","myQueryProfile","aString");
+ assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
profile.set("myQueryProfile", map1, registry);
profile.set("someMap", map2, registry); // Legal because this is not strict
assertWrongType(profile, "reference to a query profile of type 'user'", "myUserQueryProfile", map1);
@@ -235,14 +231,14 @@ public class QueryProfileTypeTestCase {
/** Tests assigning a subprofile directly */
@Test
- public void testTypedAssignmentOfQueryProfilesStrict() {
+ void testTypedAssignmentOfQueryProfilesStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtypeStrict);
- QueryProfile map1=new QueryProfile("myMap1");
+ QueryProfile map1 = new QueryProfile("myMap1");
map1.set("key1", "value1", registry);
- QueryProfile map2=new QueryProfile("myMap2");
+ QueryProfile map2 = new QueryProfile("myMap2");
map2.set("key2", "value2", registry);
QueryProfile myUser = new QueryProfile("myUser");
@@ -250,10 +246,10 @@ public class QueryProfileTypeTestCase {
myUser.set("myUserString", "userValue1", registry);
myUser.set("myUserInteger", 442, registry);
- assertWrongType(profile,"reference to a query profile","myQueryProfile","aString");
+ assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
profile.set("myQueryProfile", map1, registry);
- assertNotPermitted(profile,"someMap", map2);
- assertWrongType(profile,"reference to a query profile of type 'userStrict'", "myUserQueryProfile", map1);
+ assertNotPermitted(profile, "someMap", map2);
+ assertWrongType(profile, "reference to a query profile of type 'userStrict'", "myUserQueryProfile", map1);
profile.set("myUserQueryProfile", myUser, registry);
CompiledQueryProfile cprofile = profile.compile(null);
@@ -266,7 +262,7 @@ public class QueryProfileTypeTestCase {
/** Tests assigning a subprofile as an id string */
@Test
- public void testTypedAssignmentOfQueryProfileReferencesNonStrict() {
+ void testTypedAssignmentOfQueryProfileReferencesNonStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
@@ -286,21 +282,21 @@ public class QueryProfileTypeTestCase {
registry.register(map2);
registry.register(myUser);
- assertWrongType(profile,"reference to a query profile", "myQueryProfile", "aString");
+ assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
registry.register(map1);
profile.set("myQueryProfile", "myMap1", registry);
registry.register(map2);
profile.set("someMap", "myMap2", registry); // NOTICE: Will set as a string because we cannot know this is a reference
assertWrongType(profile, "reference to a query profile of type 'user'", "myUserQueryProfile", "myMap1");
registry.register(myUser);
- profile.set("myUserQueryProfile","myUser", registry);
+ profile.set("myUserQueryProfile", "myUser", registry);
CompiledQueryProfileRegistry cRegistry = registry.compile();
CompiledQueryProfile cprofile = cRegistry.getComponent("test");
assertEquals("value1", cprofile.get("myQueryProfile.key1"));
assertEquals("myMap2", cprofile.get("someMap"));
- assertNull("Asking for an value which cannot be completely resolved returns null", cprofile.get("someMap.key2"));
+ assertNull(cprofile.get("someMap.key2"), "Asking for an value which cannot be completely resolved returns null");
assertEquals("userValue1", cprofile.get("myUserQueryProfile.myUserString"));
assertEquals(442, cprofile.get("myUserQueryProfile.myUserInteger"));
}
@@ -310,11 +306,11 @@ public class QueryProfileTypeTestCase {
* Here there exists a user profile already, and then a new one is overwritten
*/
@Test
- public void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQuery() {
+ void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQuery() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
- QueryProfile myUser=new QueryProfile("myUser");
+ QueryProfile myUser = new QueryProfile("myUser");
myUser.setType(user);
myUser.set("myUserString", "userValue1", registry);
myUser.set("myUserInteger", 442, registry);
@@ -332,8 +328,8 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfile cprofile = cRegistry.getComponent("test");
Query query = new Query(HttpRequest.createTestRequest("?myUserQueryProfile=newUser",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cprofile);
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cprofile);
assertEquals(0, query.errors().size());
@@ -346,7 +342,7 @@ public class QueryProfileTypeTestCase {
* Here no user profile is set before it is assigned in the query
*/
@Test
- public void testTypedAssignmentOfQueryProfileReferencesNonStrictThroughQuery() {
+ void testTypedAssignmentOfQueryProfileReferencesNonStrictThroughQuery() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
@@ -361,8 +357,8 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfile cprofile = cRegistry.getComponent("test");
Query query = new Query(HttpRequest.createTestRequest("?myUserQueryProfile=newUser",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cprofile);
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cprofile);
assertEquals(0, query.errors().size());
@@ -375,7 +371,7 @@ public class QueryProfileTypeTestCase {
* Here no user profile is set before it is assigned in the query
*/
@Test
- public void testTypedAssignmentOfQueryProfileReferencesStrictThroughQuery() {
+ void testTypedAssignmentOfQueryProfileReferencesStrictThroughQuery() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtypeStrict);
@@ -401,13 +397,13 @@ public class QueryProfileTypeTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'myUserQueryProfile.someKey' to 'value': 'someKey' is not declared in query profile type 'userStrict', and the type is strict",
- Exceptions.toMessageString(e));
+ Exceptions.toMessageString(e));
}
}
@Test
- public void testTensorRankFeatureInRequest() {
+ void testTensorRankFeatureInRequest() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
registry.register(profile);
@@ -415,16 +411,16 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query(HttpRequest.createTestRequest("?" + urlEncode("ranking.features.query(myTensor1)") +
- "=" + urlEncode(tensorString),
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("test"));
+ "=" + urlEncode(tensorString),
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cRegistry.getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(Tensor.from(tensorString), query.properties().get("ranking.features.query(myTensor1)"));
assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
@Test
- public void testTensorRankFeatureSetProgrammatically() {
+ void testTensorRankFeatureSetProgrammatically() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
registry.register(profile);
@@ -432,13 +428,13 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query(HttpRequest.createTestRequest("?", com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("test"));
+ cRegistry.getComponent("test"));
query.properties().set("ranking.features.query(myTensor1)", Tensor.from(tensorString));
assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
@Test
- public void testTensorRankFeatureSetProgrammaticallyWithWrongType() {
+ void testTensorRankFeatureSetProgrammaticallyWithWrongType() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtype);
registry.register(profile);
@@ -446,15 +442,15 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "tensor(x[3]):[0.1, 0.2, 0.3]";
Query query = new Query(HttpRequest.createTestRequest("?", com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("test"));
+ cRegistry.getComponent("test"));
try {
- query.getRanking().getFeatures().put("query(myTensor1)",Tensor.from(tensorString));
+ query.getRanking().getFeatures().put("query(myTensor1)", Tensor.from(tensorString));
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'ranking.features.query(myTensor1)' to 'tensor(x[3]):[0.1, 0.2, 0.3]': " +
- "Require a tensor of type tensor(a{},b{})",
- Exceptions.toMessageString(e));
+ "Require a tensor of type tensor(a{},b{})",
+ Exceptions.toMessageString(e));
}
try {
query.properties().set("ranking.features.query(myTensor1)", Tensor.from(tensorString));
@@ -462,14 +458,14 @@ public class QueryProfileTypeTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("Could not set 'ranking.features.query(myTensor1)' to 'tensor(x[3]):[0.1, 0.2, 0.3]': " +
- "Require a tensor of type tensor(a{},b{})",
- Exceptions.toMessageString(e));
+ "Require a tensor of type tensor(a{},b{})",
+ Exceptions.toMessageString(e));
}
}
// Expected to work exactly as testTensorRankFeatureInRequest
@Test
- public void testTensorRankFeatureInRequestWithInheritedQueryProfileType() {
+ void testTensorRankFeatureInRequestWithInheritedQueryProfileType() {
QueryProfile profile = new QueryProfile("test");
profile.setType(emptyInheritingTesttype);
registry.register(profile);
@@ -477,16 +473,16 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query(HttpRequest.createTestRequest("?" + urlEncode("ranking.features.query(myTensor1)") +
- "=" + urlEncode(tensorString),
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("test"));
+ "=" + urlEncode(tensorString),
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cRegistry.getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(Tensor.from(tensorString), query.properties().get("ranking.features.query(myTensor1)"));
assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
@Test
- public void testUnembeddedTensorRankFeatureInRequest() {
+ void testUnembeddedTensorRankFeatureInRequest() {
String text = "text to embed into a tensor";
Tensor embedding1 = Tensor.from("tensor<float>(x[5]):[3,7,4,0,0]]");
Tensor embedding2 = Tensor.from("tensor<float>(x[5]):[1,2,3,4,0]]");
@@ -500,7 +496,7 @@ public class QueryProfileTypeTestCase {
assertEmbedQuery("embed(emb1, '" + text + "')", embedding1, embedders);
assertEmbedQuery("embed(emb1, \"" + text + "\")", embedding1, embedders);
assertEmbedQueryFails("embed(emb2, \"" + text + "\")", embedding1, embedders,
- "Can't find embedder 'emb2'. Valid embedders are emb1");
+ "Can't find embedder 'emb2'. Valid embedders are emb1");
embedders = Map.of(
"emb1", new MockEmbedder(text, Language.UNKNOWN, embedding1),
@@ -530,7 +526,7 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testIllegalStrictAssignmentFromRequest() {
+ void testIllegalStrictAssignmentFromRequest() {
QueryProfile profile = new QueryProfile("test");
profile.setType(testtypeStrict);
@@ -541,13 +537,13 @@ public class QueryProfileTypeTestCase {
try {
new Query(HttpRequest.createTestRequest("?myUserQueryProfile.nondeclared=someValue",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- profile.compile(null));
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ profile.compile(null));
fail("Above statement should throw");
} catch (IllegalArgumentException e) {
// As expected.
assertTrue(Exceptions.toMessageString(e).contains(
- "Could not set 'myUserQueryProfile.nondeclared' to 'someValue': 'nondeclared' is not declared in query profile type 'userStrict', and the type is strict"));
+ "Could not set 'myUserQueryProfile.nondeclared' to 'someValue': 'nondeclared' is not declared in query profile type 'userStrict', and the type is strict"));
}
}
@@ -557,7 +553,7 @@ public class QueryProfileTypeTestCase {
* The whole thing is accessed through a two levels of nontyped top-level profiles
*/
@Test
- public void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
+ void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
@@ -586,8 +582,8 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myUserQueryProfile=newUser",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("topMap"));
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cRegistry.getComponent("topMap"));
assertEquals(0, query.errors().size());
@@ -599,7 +595,7 @@ public class QueryProfileTypeTestCase {
* Same as previous test but using the untyped myQueryProfile reference instead of the typed myUserQueryProfile
*/
@Test
- public void testAnonTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
+ void testAnonTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
@@ -630,15 +626,15 @@ public class QueryProfileTypeTestCase {
Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myQueryProfile=newUser", com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("topMap"));
assertEquals(0, query.errors().size());
- assertEquals("newUserValue1",query.properties().get("subMap.typeProfile.myQueryProfile.myUserString"));
- assertEquals(845,query.properties().get("subMap.typeProfile.myQueryProfile.myUserInteger"));
+ assertEquals("newUserValue1", query.properties().get("subMap.typeProfile.myQueryProfile.myUserString"));
+ assertEquals(845, query.properties().get("subMap.typeProfile.myQueryProfile.myUserInteger"));
}
/**
* Tests setting a illegal value in a strict profile nested under untyped maps
*/
@Test
- public void testSettingValueInStrictTypeNestedUnderUntypedMaps() {
+ void testSettingValueInStrictTypeNestedUnderUntypedMaps() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
@@ -656,13 +652,13 @@ public class QueryProfileTypeTestCase {
try {
new Query(
HttpRequest.createTestRequest("?subMap.typeProfile.someValue=value",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
cRegistry.getComponent("topMap"));
fail("Above statement should throw");
} catch (IllegalArgumentException e) {
// As expected.
assertTrue(Exceptions.toMessageString(e).contains(
- "Could not set 'subMap.typeProfile.someValue' to 'value': 'someValue' is not declared in query profile type 'testtypeStrict', and the type is strict"));
+ "Could not set 'subMap.typeProfile.someValue' to 'value': 'someValue' is not declared in query profile type 'testtypeStrict', and the type is strict"));
}
}
@@ -672,15 +668,15 @@ public class QueryProfileTypeTestCase {
* The whole thing is accessed through a two levels of nontyped top-level profiles
*/
@Test
- public void testTypedSettingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
+ void testTypedSettingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
- topMap.set("subMap",subMap, registry);
+ topMap.set("subMap", subMap, registry);
QueryProfile test = new QueryProfile("test");
test.setType(testtype);
- subMap.set("typeProfile",test, registry);
+ subMap.set("typeProfile", test, registry);
QueryProfile newUser = new QueryProfile("newUser");
newUser.setType(user);
@@ -694,8 +690,8 @@ public class QueryProfileTypeTestCase {
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myUserQueryProfile=newUser",
- com.yahoo.jdisc.http.HttpRequest.Method.GET),
- cRegistry.getComponent("topMap"));
+ com.yahoo.jdisc.http.HttpRequest.Method.GET),
+ cRegistry.getComponent("topMap"));
assertEquals(0, query.errors().size());
assertEquals("newUserValue1", query.properties().get("subMap.typeProfile.myUserQueryProfile.myUserString"));
@@ -703,14 +699,14 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testNestedTypeName() {
+ void testNestedTypeName() {
ComponentId.resetGlobalCountersForTests();
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType type = new QueryProfileType("testType");
registry.getTypeRegistry().register(type);
type.addField(new FieldDescription("ranking.features.query(embedding_profile)",
- "tensor<float>(model{},x[128])"),
- registry.getTypeRegistry());
+ "tensor<float>(model{},x[128])"),
+ registry.getTypeRegistry());
QueryProfile test = new QueryProfile("test");
registry.register(test);
test.setType(type);
@@ -723,15 +719,15 @@ public class QueryProfileTypeTestCase {
}
@Test
- public void testNestedTypeNameUsingBuiltInTypes() {
+ void testNestedTypeNameUsingBuiltInTypes() {
ComponentId.resetGlobalCountersForTests();
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfileType type = new QueryProfileType("testType");
type.inherited().add(Query.getArgumentType()); // Include native type checking
registry.getTypeRegistry().register(type);
type.addField(new FieldDescription("ranking.features.query(embedding_profile)",
- "tensor<float>(model{},x[128])"),
- registry.getTypeRegistry());
+ "tensor<float>(model{},x[128])"),
+ registry.getTypeRegistry());
QueryProfile test = new QueryProfile("test");
registry.register(test);
test.setType(type);
@@ -745,7 +741,7 @@ public class QueryProfileTypeTestCase {
}
catch (IllegalArgumentException e) {
assertEquals("'foo' is not a valid property in 'ranking'. See the query api for valid keys starting by 'ranking'.",
- e.getCause().getMessage());
+ e.getCause().getMessage());
}
// With a prefix we're not in the built-in type space
diff --git a/container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java b/container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java
index 5fbe8858186..46859ab1cbe 100644
--- a/container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/properties/test/PropertyMapTestCase.java
@@ -2,13 +2,12 @@
package com.yahoo.search.query.properties.test;
import com.yahoo.processing.request.properties.PropertyMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bratseth
@@ -16,24 +15,24 @@ import static org.junit.Assert.assertTrue;
public class PropertyMapTestCase {
@Test
- public void testCloning() {
+ void testCloning() {
PropertyMap map = new PropertyMap();
map.set("clonable", new ClonableObject());
map.set("nonclonable", new NonClonableObject());
- map.set("clonableArray", new ClonableObject[] {new ClonableObject()});
- map.set("nonclonableArray", new NonClonableObject[] {new NonClonableObject()});
+ map.set("clonableArray", new ClonableObject[]{new ClonableObject()});
+ map.set("nonclonableArray", new NonClonableObject[]{new NonClonableObject()});
map.set("clonableList", Collections.singletonList(new ClonableObject()));
map.set("nonclonableList", Collections.singletonList(new NonClonableObject()));
assertNotNull(map.get("clonable"));
assertNotNull(map.get("nonclonable"));
- PropertyMap mapClone=map.clone();
+ PropertyMap mapClone = map.clone();
assertTrue(map.get("clonable") != mapClone.get("clonable"));
- assertTrue(map.get("nonclonable") == mapClone.get("nonclonable"));
+ assertEquals(map.get("nonclonable"), mapClone.get("nonclonable"));
assertTrue(map.get("clonableArray") != mapClone.get("clonableArray"));
assertTrue(first(map.get("clonableArray")) != first(mapClone.get("clonableArray")));
- assertTrue(first(map.get("nonclonableArray")) == first(mapClone.get("nonclonableArray")));
+ assertEquals(first(map.get("nonclonableArray")), first(mapClone.get("nonclonableArray")));
}
private Object first(Object object) {
diff --git a/container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java
index 2a123b4bbda..23b41092660 100644
--- a/container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/properties/test/RequestContextPropertiesTestCase.java
@@ -5,9 +5,9 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.test.QueryTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests that dimension arguments in queries are transferred correctly to dimension values
@@ -17,18 +17,18 @@ import static org.junit.Assert.assertEquals;
public class RequestContextPropertiesTestCase {
@Test
- public void testIt() {
- QueryProfile p=new QueryProfile("test");
- p.setDimensions(new String[] {"x"});
- p.set("a","a-default", (QueryProfileRegistry)null);
- p.set("a","a-x1",new String[] {"x1"}, null);
- p.set("a","a-+x1",new String[] {"+x1"}, null);
+ void testIt() {
+ QueryProfile p = new QueryProfile("test");
+ p.setDimensions(new String[]{"x"});
+ p.set("a", "a-default", (QueryProfileRegistry) null);
+ p.set("a", "a-x1", new String[]{"x1"}, null);
+ p.set("a", "a-+x1", new String[]{"+x1"}, null);
Query q1 = new Query(QueryTestCase.httpEncode("?query=foo"), p.compile(null));
- assertEquals("a-default",q1.properties().get("a"));
- Query q2 = new Query(QueryTestCase.httpEncode("?query=foo&x=x1"),p.compile(null));
- assertEquals("a-x1",q2.properties().get("a"));
- Query q3 = new Query(QueryTestCase.httpEncode("?query=foo&x=+x1"),p.compile(null));
- assertEquals("a-+x1",q3.properties().get("a"));
+ assertEquals("a-default", q1.properties().get("a"));
+ Query q2 = new Query(QueryTestCase.httpEncode("?query=foo&x=x1"), p.compile(null));
+ assertEquals("a-x1", q2.properties().get("a"));
+ Query q3 = new Query(QueryTestCase.httpEncode("?query=foo&x=+x1"), p.compile(null));
+ assertEquals("a-+x1", q3.properties().get("a"));
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java
index 11c249c5cdb..0e9bf8d41ec 100644
--- a/container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/properties/test/SubPropertiesTestCase.java
@@ -1,15 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.properties.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Arrays;
import java.util.HashSet;
import com.yahoo.processing.request.properties.PropertyMap;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.search.query.properties.SubProperties;
/**
@@ -18,19 +17,21 @@ import com.yahoo.search.query.properties.SubProperties;
public class SubPropertiesTestCase {
@Test
- public void testSubProperties() {
- PropertyMap map = new PropertyMap() {{
- set("a.e","1");
- set("a.f",2);
- set("b.e","3");
- set("f",3);
- set("e","2");
- set("d","a");
- }};
+ void testSubProperties() {
+ PropertyMap map = new PropertyMap() {
+ {
+ set("a.e", "1");
+ set("a.f", 2);
+ set("b.e", "3");
+ set("f", 3);
+ set("e", "2");
+ set("d", "a");
+ }
+ };
SubProperties sub = new SubProperties("a", map);
- assertEquals("1",sub.get("e"));
- assertEquals(2,sub.get("f"));
+ assertEquals("1", sub.get("e"));
+ assertEquals(2, sub.get("f"));
assertNull(sub.get("d"));
assertEquals(new HashSet<>(Arrays.asList("e", "f")), sub.listProperties("").keySet());
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java
index 72b77377bf2..e502cf538aa 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/RewriterFeaturesTestCase.java
@@ -1,12 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.rewrite;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertSame;
import com.yahoo.prelude.query.WeakAndItem;
-import org.junit.Test;
-
+import org.junit.jupiter.api.Test;
import com.yahoo.prelude.query.AndItem;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.yahoo.prelude.query.CompositeItem;
import com.yahoo.prelude.query.Item;
import com.yahoo.language.process.SpecialTokenRegistry;
@@ -25,7 +26,7 @@ public class RewriterFeaturesTestCase {
private static final String ASCII_ELLIPSIS = "...";
@Test
- public final void testConvertStringToQTree() {
+ final void testConvertStringToQTree() {
Execution placeholder = new Execution(Context.createContextStub());
SpecialTokenRegistry tokenRegistry = new SpecialTokenRegistry(
new SpecialtokensConfig(
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java
index d9a3603bdaf..668d070b3e2 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/GenericExpansionRewriterTestCase.java
@@ -8,8 +8,8 @@ import com.yahoo.search.searchchain.*;
import com.yahoo.search.query.rewrite.*;
import com.yahoo.search.query.rewrite.rewriters.*;
import com.yahoo.search.query.rewrite.RewritesConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test Cases for GenericExpansionRewriter
@@ -29,7 +29,7 @@ public class GenericExpansionRewriterTestCase {
* Load the GenericExpansionRewriterSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
@@ -44,149 +44,149 @@ public class GenericExpansionRewriterTestCase {
* MaxRewrites=3, PartialPhraseMatch is on, type=adv case
*/
@Test
- public void testPartialPhraseMaxRewriteAdvType() {
+ void testPartialPhraseMaxRewriteAdvType() {
utils.assertRewrittenQuery("?query=(modern new york city travel phone number) OR (travel agency) OR travel&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=3",
- "query 'OR (AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 " +
- "(AND new york city travel)) (OR pn (AND phone number))) ta (AND travel agency) " +
- "tr travel'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=3",
+ "query 'OR (AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 " +
+ "(AND new york city travel)) (OR pn (AND phone number))) ta (AND travel agency) " +
+ "tr travel'");
}
/**
* PartialPhraseMatch is off, type=adv case
*/
@Test
- public void testPartialPhraseNoMaxRewriteAdvType() {
+ void testPartialPhraseNoMaxRewriteAdvType() {
utils.assertRewrittenQuery("?query=(modern new york city travel phone number) OR (travel agency) OR travel&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'OR (AND modern new york city travel phone number) " +
- "ta (AND travel agency) tr travel'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'OR (AND modern new york city travel phone number) " +
+ "ta (AND travel agency) tr travel'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, type=adv, added filter case
*/
@Test
- public void testFullPhraseNoMaxRewriteAdvTypeFilter() {
+ void testFullPhraseNoMaxRewriteAdvTypeFilter() {
utils.assertRewrittenQuery("?query=ca OR (modern new york city travel phone number) OR (travel agency) OR travel&" +
- "type=adv&filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'RANK (OR california ca (AND modern new york city travel phone number) " +
- "ta (AND travel agency) tr travel) |citystate:santa |clara |ca'");
+ "type=adv&filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'RANK (OR california ca (AND modern new york city travel phone number) " +
+ "ta (AND travel agency) tr travel) |citystate:santa |clara |ca'");
}
/**
* MaxRewrites=0 (i.e No MaxRewrites), PartialPhraseMatch is on, type=adv, added filter case
*/
@Test
- public void testPartialPhraseNoMaxRewriteAdvTypeFilter() {
+ void testPartialPhraseNoMaxRewriteAdvTypeFilter() {
utils.assertRewrittenQuery("?query=ca OR (modern new york city travel phone number) OR (travel agency) OR travel&" +
- "type=adv&filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=0",
- "query 'RANK (OR california ca (AND modern (OR \"rewrite11 rewrite12\" " +
- "rewrite2 rewrite3 rewrite4 rewrite5 (AND new york city travel)) " +
- "(OR pn (AND phone number))) ta (AND travel agency) tr travel) " +
- "|citystate:santa |clara |ca'");
+ "type=adv&filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=0",
+ "query 'RANK (OR california ca (AND modern (OR \"rewrite11 rewrite12\" " +
+ "rewrite2 rewrite3 rewrite4 rewrite5 (AND new york city travel)) " +
+ "(OR pn (AND phone number))) ta (AND travel agency) tr travel) " +
+ "|citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, single word, added filter case
*/
@Test
- public void testFullPhraseNoMaxRewriteSingleWordFilter() {
+ void testFullPhraseNoMaxRewriteSingleWordFilter() {
utils.assertRewrittenQuery("?query=ca&type=all&" +
- "filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'RANK (OR california ca) |citystate:santa |clara |ca'");
+ "filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'RANK (OR california ca) |citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is on, single word, added filter case
*/
@Test
- public void testPartialPhraseNoMaxRewriteSingleWordFilter() {
+ void testPartialPhraseNoMaxRewriteSingleWordFilter() {
utils.assertRewrittenQuery("?query=ca&type=all&" +
- "filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'RANK (OR california ca) |citystate:santa |clara |ca'");
+ "filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'RANK (OR california ca) |citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, multi word, added filter case
*/
@Test
- public void testFullPhraseNoMaxRewriteMultiWordFilter() {
+ void testFullPhraseNoMaxRewriteMultiWordFilter() {
utils.assertRewrittenQuery("?query=travel agency&type=all&" +
- "filter=citystate:santa clara ca&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'RANK (OR ta (AND travel agency)) |citystate:santa |clara |ca'");
+ "filter=citystate:santa clara ca&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'RANK (OR ta (AND travel agency)) |citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is on, multi word, added filter case
*/
@Test
- public void testPartialPhraseNoMaxRewriteMultiWordFilter() {
+ void testPartialPhraseNoMaxRewriteMultiWordFilter() {
utils.assertRewrittenQuery("?query=modern new york city travel phone number&" +
- "filter=citystate:santa clara ca&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'RANK (AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 " +
- "rewrite4 rewrite5 (AND new york city travel)) (OR pn (AND phone number))) " +
- "|citystate:santa |clara |ca'");
+ "filter=citystate:santa clara ca&type=all&" +
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'RANK (AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 " +
+ "rewrite4 rewrite5 (AND new york city travel)) (OR pn (AND phone number))) " +
+ "|citystate:santa |clara |ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, single word
*/
@Test
- public void testFullPhraseNoMaxRewriteSingleWord() {
+ void testFullPhraseNoMaxRewriteSingleWord() {
utils.assertRewrittenQuery("?query=ca&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'OR california ca'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'OR california ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is on, single word
*/
@Test
- public void testPartialPhraseNoMaxRewriteSingleWord() {
+ void testPartialPhraseNoMaxRewriteSingleWord() {
utils.assertRewrittenQuery("?query=ca&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'OR california ca'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'OR california ca'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, multi word
*/
@Test
- public void testFullPhraseNoMaxRewriteMultiWord() {
+ void testFullPhraseNoMaxRewriteMultiWord() {
utils.assertRewrittenQuery("?query=travel agency&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'OR ta (AND travel agency)'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'OR ta (AND travel agency)'");
}
/**
* No MaxRewrites, PartialPhraseMatch is off, multi word, no full match
*/
@Test
- public void testFullPhraseNoMaxRewriteMultiWordNoMatch() {
+ void testFullPhraseNoMaxRewriteMultiWordNoMatch() {
utils.assertRewrittenQuery("?query=nyc travel agency&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
- "query 'AND nyc travel agency'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=false",
+ "query 'AND nyc travel agency'");
}
/**
* No MaxRewrites, PartialPhraseMatch is on, multi word
*/
@Test
- public void testPartialPhraseNoMaxRewriteMultiWord() {
+ void testPartialPhraseNoMaxRewriteMultiWord() {
utils.assertRewrittenQuery("?query=modern new york city travel phone number&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 rewrite4 rewrite5 "+
- "(AND new york city travel)) (OR pn (AND phone number))'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'AND modern (OR (AND rewrite11 rewrite12) rewrite2 rewrite3 rewrite4 rewrite5 " +
+ "(AND new york city travel)) (OR pn (AND phone number))'");
}
/**
@@ -195,10 +195,10 @@ public class GenericExpansionRewriterTestCase {
* Should rewrite travel but not travel agency in this case
*/
@Test
- public void testPartialPhraseMultiWordRankTree() {
+ void testPartialPhraseMultiWordRankTree() {
utils.assertRewrittenQuery("?query=travel RANK agency&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'RANK (OR tr travel) agency'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'RANK (OR tr travel) agency'");
}
/**
@@ -207,10 +207,10 @@ public class GenericExpansionRewriterTestCase {
* Should rewrite travel but not travel agency in this case
*/
@Test
- public void testFullPhraseMultiWordRankTree() {
+ void testFullPhraseMultiWordRankTree() {
utils.assertRewrittenQuery("?query=travel RANK agency&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
- "query 'RANK (OR tr travel) agency'");
+ REWRITER_NAME + "." + RewriterConstants.PARTIAL_PHRASE_MATCH + "=true",
+ "query 'RANK (OR tr travel) agency'");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java
index 6c9f9c248ea..36eb06a3a92 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/MisspellRewriterTestCase.java
@@ -6,10 +6,10 @@ import com.yahoo.search.searchchain.*;
import com.yahoo.search.intent.model.*;
import com.yahoo.search.query.rewrite.*;
import com.yahoo.search.query.rewrite.rewriters.*;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test Cases for MisspellRewriter
@@ -25,7 +25,7 @@ public class MisspellRewriterTestCase {
* Load the QueryRewriteSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
MisspellRewriter searcher = new MisspellRewriter();
Execution execution = QueryRewriteSearcherTestUtils.createExecutionObj(searcher);
@@ -37,18 +37,18 @@ public class MisspellRewriterTestCase {
* QLAS returns spell correction: qss_rw=0.9 qss_sugg=1.0
*/
@Test
- public void testQSSRewriteQSSSuggestWithRewrite() {
+ void testQSSRewriteQSSSuggestWithRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("will smith rw", 0.9,
- true, false),
- utils.createInterpretation("will smith sugg", 1.0,
- false, true));
+ utils.createInterpretation("will smith rw", 0.9,
+ true, false),
+ utils.createInterpretation("will smith sugg", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
- "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith sugg)'",
- intentModel);
+ REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
+ "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith sugg)'",
+ intentModel);
}
/**
@@ -56,19 +56,19 @@ public class MisspellRewriterTestCase {
* QLAS returns spell correction: qss_rw=0.9 qss_rw=0.9 qss_sugg=1.0
*/
@Test
- public void testQSSRewriteWithRewrite() {
+ void testQSSRewriteWithRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("will smith rw1", 0.9,
- true, false),
- utils.createInterpretation("will smith rw2", 0.9,
- true, false),
- utils.createInterpretation("will smith sugg", 1.0,
- false, true));
+ utils.createInterpretation("will smith rw1", 0.9,
+ true, false),
+ utils.createInterpretation("will smith rw2", 0.9,
+ true, false),
+ utils.createInterpretation("will smith sugg", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true",
- "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith rw1)'",
- intentModel);
+ REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true",
+ "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith rw1)'",
+ intentModel);
}
/**
@@ -76,19 +76,19 @@ public class MisspellRewriterTestCase {
* QLAS returns spell correction: qss_rw=1.0 qss_sugg=0.9 qss_sugg=0.8
*/
@Test
- public void testQSSSuggWithRewrite() {
+ void testQSSSuggWithRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("will smith rw", 1.0,
- true, false),
- utils.createInterpretation("will smith sugg1", 0.9,
- false, true),
- utils.createInterpretation("will smith sugg2", 0.8,
- false, true));
+ utils.createInterpretation("will smith rw", 1.0,
+ true, false),
+ utils.createInterpretation("will smith sugg1", 0.9,
+ false, true),
+ utils.createInterpretation("will smith sugg2", 0.8,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
- "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith sugg1)'",
- intentModel);
+ REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
+ "query 'OR (WEAKAND(100) willl smith) (WEAKAND(100) will smith sugg1)'",
+ intentModel);
}
/**
@@ -96,16 +96,16 @@ public class MisspellRewriterTestCase {
* QLAS returns spell correction: qss_rw=1.0 qss_sugg=1.0
*/
@Test
- public void testFeautureOffWithRewrite() {
+ void testFeautureOffWithRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("will smith rw", 1.0,
- true, false),
- utils.createInterpretation("will smith sugg", 1.0,
- false, true));
+ utils.createInterpretation("will smith rw", 1.0,
+ true, false),
+ utils.createInterpretation("will smith sugg", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith",
- "query 'WEAKAND(100) willl smith'",
- intentModel);
+ "query 'WEAKAND(100) willl smith'",
+ intentModel);
}
/**
@@ -113,18 +113,18 @@ public class MisspellRewriterTestCase {
* QLAS returns no spell correction
*/
@Test
- public void testQSSRewriteQSSSuggWithoutRewrite() {
+ void testQSSRewriteQSSSuggWithoutRewrite() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("use diff query for testing", 1.0,
- false, false),
- utils.createInterpretation("use diff query for testing", 1.0,
- false, false));
+ utils.createInterpretation("use diff query for testing", 1.0,
+ false, false),
+ utils.createInterpretation("use diff query for testing", 1.0,
+ false, false));
utils.assertRewrittenQuery("?query=will+smith&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
- "query 'WEAKAND(100) will smith'",
- intentModel);
+ REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true",
+ "query 'WEAKAND(100) will smith'",
+ intentModel);
}
/**
@@ -132,7 +132,7 @@ public class MisspellRewriterTestCase {
* It should throw exception
*/
@Test
- public void testNullIntentModelException() {
+ void testNullIntentModelException() {
try {
RewriterUtils.getSpellCorrected(new Query("willl smith"), true, true);
fail();
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java
index c99ddcd6c62..98a93a572e9 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/NameRewriterTestCase.java
@@ -8,8 +8,8 @@ import com.yahoo.search.searchchain.*;
import com.yahoo.search.query.rewrite.*;
import com.yahoo.search.query.rewrite.rewriters.*;
import com.yahoo.search.query.rewrite.RewritesConfig;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test Cases for NameRewriter
@@ -29,7 +29,7 @@ public class NameRewriterTestCase {
* Load the NameRewriterSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
@@ -44,29 +44,29 @@ public class NameRewriterTestCase {
* RewritesAsEquiv and OriginalAsUnit are on
*/
@Test
- public void testRewritesAsEquivAndOriginalAsUnit() {
+ void testRewritesAsEquivAndOriginalAsUnit() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
- "query 'OR \"will smith\" (AND will smith movies) " +
- "(AND will smith news) (AND will smith imdb) " +
- "(AND will smith lyrics) (AND will smith dead) " +
- "(AND will smith nfl) (AND will smith new movie hancock) " +
- "(AND will smith biography)'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
+ "query 'OR \"will smith\" (AND will smith movies) " +
+ "(AND will smith news) (AND will smith imdb) " +
+ "(AND will smith lyrics) (AND will smith dead) " +
+ "(AND will smith nfl) (AND will smith new movie hancock) " +
+ "(AND will smith biography)'");
}
/**
* RewritesAsEquiv is on
*/
@Test
- public void testRewritesAsEquiv() {
+ void testRewritesAsEquiv() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&",
- "query 'OR (AND will smith) (AND will smith movies) " +
- "(AND will smith news) (AND will smith imdb) " +
- "(AND will smith lyrics) (AND will smith dead) " +
- "(AND will smith nfl) (AND will smith new movie hancock) " +
- "(AND will smith biography)'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&",
+ "query 'OR (AND will smith) (AND will smith movies) " +
+ "(AND will smith news) (AND will smith imdb) " +
+ "(AND will smith lyrics) (AND will smith dead) " +
+ "(AND will smith nfl) (AND will smith new movie hancock) " +
+ "(AND will smith biography)'");
}
/**
@@ -74,57 +74,57 @@ public class NameRewriterTestCase {
* Should not rewrite
*/
@Test
- public void testComplextQueryRewritesAsEquiv() {
+ void testComplextQueryRewritesAsEquiv() {
utils.assertRewrittenQuery("?query=((will smith) OR (willl smith)) AND (tom cruise)&type=adv&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&",
- "query 'AND (OR (AND will smith) (AND willl smith)) (AND tom cruise)'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&",
+ "query 'AND (OR (AND will smith) (AND willl smith)) (AND tom cruise)'");
}
/**
* Single word query for RewritesAsEquiv and OriginalAsUnit on case
*/
@Test
- public void testSingleWordForRewritesAsEquivAndOriginalAsUnit() {
+ void testSingleWordForRewritesAsEquivAndOriginalAsUnit() {
utils.assertRewrittenQuery("?query=obama&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
- "query 'OR obama (AND obama \"nobel peace prize\") " +
- "(AND obama wiki) (AND obama nobel prize) " +
- "(AND obama nobel peace prize) (AND obama wears mom jeans) " +
- "(AND obama sucks) (AND obama news) (AND malia obama) " +
- "(AND obama speech) (AND obama nobel) (AND obama wikipedia) " +
- "(AND barack obama biography) (AND obama snl) " +
- "(AND obama peace prize) (AND michelle obama) (AND barack obama)'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
+ "query 'OR obama (AND obama \"nobel peace prize\") " +
+ "(AND obama wiki) (AND obama nobel prize) " +
+ "(AND obama nobel peace prize) (AND obama wears mom jeans) " +
+ "(AND obama sucks) (AND obama news) (AND malia obama) " +
+ "(AND obama speech) (AND obama nobel) (AND obama wikipedia) " +
+ "(AND barack obama biography) (AND obama snl) " +
+ "(AND obama peace prize) (AND michelle obama) (AND barack obama)'");
}
/**
* RewritesAsUnitEquiv and OriginalAsUnitEquiv are on
*/
@Test
- public void testRewritesAsUnitEquivAndOriginalAsUnitEquiv() {
+ void testRewritesAsUnitEquivAndOriginalAsUnitEquiv() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV +
- "=true",
- "query 'OR (AND will smith) \"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV +
+ "=true",
+ "query 'OR (AND will smith) \"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'");
}
/**
* Single word query for RewritesAsUnitEquiv and OriginalAsUnitEquiv on case
*/
@Test
- public void testSingleWordForRewritesAsUnitEquivAndOriginalAsUnitEquiv() {
+ void testSingleWordForRewritesAsUnitEquivAndOriginalAsUnitEquiv() {
utils.assertRewrittenQuery("?query=obama&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV +
- "=true",
- "query 'OR obama \"obama nobel peace prize\" \"obama wiki\" \"obama nobel prize\" \"obama nobel peace prize\" \"obama wears mom jeans\" \"obama sucks\" \"obama news\" \"malia obama\" \"obama speech\" \"obama nobel\" \"obama wikipedia\" \"barack obama biography\" \"obama snl\" \"obama peace prize\" \"michelle obama\" \"barack obama\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV +
+ "=true",
+ "query 'OR obama \"obama nobel peace prize\" \"obama wiki\" \"obama nobel prize\" \"obama nobel peace prize\" \"obama wears mom jeans\" \"obama sucks\" \"obama news\" \"malia obama\" \"obama speech\" \"obama nobel\" \"obama wikipedia\" \"barack obama biography\" \"obama snl\" \"obama peace prize\" \"michelle obama\" \"barack obama\"'");
}
/**
@@ -132,11 +132,11 @@ public class NameRewriterTestCase {
* for RewritesAsEquiv and OriginalAsUnit on case
*/
@Test
- public void testBoostingQueryForRewritesAsEquivAndOriginalAsUnit() {
+ void testBoostingQueryForRewritesAsEquivAndOriginalAsUnit() {
utils.assertRewrittenQuery("?query=angelina jolie&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
- "query '\"angelina jolie\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
+ "query '\"angelina jolie\"'");
}
/**
@@ -144,39 +144,39 @@ public class NameRewriterTestCase {
* RewritesAsEquiv and OriginalAsUnit on case
*/
@Test
- public void testFSANoMatchForRewritesAsEquivAndOriginalAsUnit() {
+ void testFSANoMatchForRewritesAsEquivAndOriginalAsUnit() {
utils.assertRewrittenQuery("?query=tom cruise&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
- REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
- "query 'AND tom cruise'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_EQUIV + "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT + "=true",
+ "query 'AND tom cruise'");
}
/**
* RewritesAsUnitEquiv is on
*/
@Test
- public void testRewritesAsUnitEquiv() {
+ void testRewritesAsUnitEquiv() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true",
- "query 'OR (AND will smith) \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true",
+ "query 'OR (AND will smith) \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'");
}
/**
* RewritesAsUnitEquiv is on and MaxRewrites is set to 2
*/
@Test
- public void testRewritesAsUnitEquivAndMaxRewrites() {
+ void testRewritesAsUnitEquivAndMaxRewrites() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=2",
- "query 'OR (AND will smith) \"will smith movies\" " +
- "\"will smith news\"'");
+ REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ REWRITER_NAME + "." + RewriterConstants.MAX_REWRITES + "=2",
+ "query 'OR (AND will smith) \"will smith movies\" " +
+ "\"will smith news\"'");
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java
index 8906dbfa386..4848483688e 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestCase.java
@@ -10,8 +10,8 @@ import com.yahoo.search.intent.model.*;
import com.yahoo.search.query.rewrite.RewritesConfig;
import com.yahoo.search.query.rewrite.*;
import com.yahoo.search.query.rewrite.rewriters.*;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Generic Test Cases for QueryRewriteSearcher
@@ -36,7 +36,7 @@ public class QueryRewriteSearcherTestCase {
* Load the QueryRewriteSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
// Instantiate Name Rewriter
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
@@ -61,7 +61,7 @@ public class QueryRewriteSearcherTestCase {
* Query will be passed to next rewriter
*/
@Test
- public void testInvalidFSAConfigPath() {
+ void testInvalidFSAConfigPath() {
// Instantiate Name Rewriter with fake FSA path
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(FAKE_FSA_CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
@@ -80,9 +80,9 @@ public class QueryRewriteSearcherTestCase {
QueryRewriteSearcherTestUtils utilsWithFakePath = new QueryRewriteSearcherTestUtils(execution);
utilsWithFakePath.assertRewrittenQuery("?query=will smith&type=all&" +
- NAME_REWRITER_NAME + "." +
- RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true",
- "query 'AND will smith'");
+ NAME_REWRITER_NAME + "." +
+ RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true",
+ "query 'AND will smith'");
}
/**
@@ -90,19 +90,19 @@ public class QueryRewriteSearcherTestCase {
* It should skip to the next rewriter
*/
@Test
- public void testExceptionInRewriter() {
+ void testExceptionInRewriter() {
utils.assertRewrittenQuery("?query=will smith&type=all&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
- "query 'OR (AND will smith) " +
- "\"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'");
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
+ "query 'OR (AND will smith) " +
+ "\"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'");
}
/**
@@ -110,26 +110,26 @@ public class QueryRewriteSearcherTestCase {
* Query will be rewritten twice
*/
@Test
- public void testTwoRewritersInChain() {
+ void testTwoRewritersInChain() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("wills smith", 0.9,
- true, false),
- utils.createInterpretation("will smith", 1.0,
- false, true));
+ utils.createInterpretation("wills smith", 0.9,
+ true, false),
+ utils.createInterpretation("will smith", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&type=all&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
- "query 'OR (AND willl smith) (AND will smith) " +
- "\"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'",
- intentModel);
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
+ "query 'OR (AND willl smith) (AND will smith) " +
+ "\"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'",
+ intentModel);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java
index c12a3fb0e14..960eea5bba7 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/QueryRewriteSearcherTestUtils.java
@@ -13,10 +13,11 @@ import com.yahoo.text.interpretation.Interpretation;
import com.yahoo.text.interpretation.Annotations;
import com.yahoo.config.subscription.ConfigGetter;
import com.yahoo.component.chain.Chain;
-import org.junit.Assert;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test utilities for QueryRewriteSearcher
*
@@ -73,7 +74,7 @@ public class QueryRewriteSearcherTestUtils {
public void assertRewrittenQuery(String origQuery, String finalQuery) {
Query query = new Query(QueryTestCase.httpEncode(origQuery));
Result result = execution.search(query);
- Assert.assertEquals(finalQuery, result.getQuery().toString());
+ assertEquals(finalQuery, result.getQuery().toString());
}
/**
@@ -89,7 +90,7 @@ public class QueryRewriteSearcherTestUtils {
Query query = new Query(origQuery);
intentModel.setTo(query);
Result result = execution.search(query);
- Assert.assertEquals(finalQuery, result.getQuery().toString());
+ assertEquals(finalQuery, result.getQuery().toString());
}
/**
diff --git a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java
index 96626738c35..56797768f56 100644
--- a/container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/rewrite/test/SearchChainDispatcherSearcherTestCase.java
@@ -12,8 +12,8 @@ import com.yahoo.search.searchchain.SearchChainRegistry;
import com.yahoo.search.query.rewrite.RewritesConfig;
import com.yahoo.search.intent.model.*;
import com.yahoo.component.chain.Chain;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test Cases for SearchChainDispatcherSearcher
@@ -35,7 +35,7 @@ public class SearchChainDispatcherSearcherTestCase {
* Load the QueryRewriteSearcher and prepare the
* execution object
*/
- @Before
+ @BeforeEach
public void setUp() {
// Instantiate Name Rewriter
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
@@ -70,26 +70,26 @@ public class SearchChainDispatcherSearcherTestCase {
* Query will be rewritten twice
*/
@Test
- public void testMarketChain() {
+ void testMarketChain() {
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("wills smith", 0.9,
- true, false),
- utils.createInterpretation("will smith", 1.0,
- false, true));
+ utils.createInterpretation("wills smith", 0.9,
+ true, false),
+ utils.createInterpretation("will smith", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&type=all&QRWChain=" + US_MARKET_SEARCH_CHAIN + "&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
- "query 'OR (AND willl smith) (AND will smith) " +
- "\"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'",
- intentModel);
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
+ "query 'OR (AND willl smith) (AND will smith) " +
+ "\"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'",
+ intentModel);
}
/**
@@ -97,13 +97,13 @@ public class SearchChainDispatcherSearcherTestCase {
* Query will be passed to next rewriter
*/
@Test
- public void testInvalidMarketChain() {
+ void testInvalidMarketChain() {
utils.assertRewrittenQuery("?query=will smith&type=all&QRWChain=abc&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true",
- "query 'AND will smith'");
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true",
+ "query 'AND will smith'");
}
/**
@@ -111,13 +111,13 @@ public class SearchChainDispatcherSearcherTestCase {
* Query will be passed to next rewriter
*/
@Test
- public void testEmptyMarketChain() {
+ void testEmptyMarketChain() {
utils.assertRewrittenQuery("?query=will smith&type=all&QRWChain=&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true",
- "query 'AND will smith'");
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true",
+ "query 'AND will smith'");
}
/**
@@ -125,7 +125,7 @@ public class SearchChainDispatcherSearcherTestCase {
* should be executed
*/
@Test
- public void testChainContinuation() {
+ void testChainContinuation() {
// Instantiate Name Rewriter
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
@@ -156,24 +156,24 @@ public class SearchChainDispatcherSearcherTestCase {
new QueryRewriteSearcherTestUtils(execution);
IntentModel intentModel = new IntentModel(
- utils.createInterpretation("wills smith", 0.9,
- true, false),
- utils.createInterpretation("will smith", 1.0,
- false, true));
+ utils.createInterpretation("wills smith", 0.9,
+ true, false),
+ utils.createInterpretation("will smith", 1.0,
+ false, true));
utils.assertRewrittenQuery("?query=willl+smith&type=all&QRWChain=" + US_MARKET_SEARCH_CHAIN + "&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
- MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
- "=true&" +
- NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
- "query 'OR (AND willl smith) (AND will smith) " +
- "\"will smith\" \"will smith movies\" " +
- "\"will smith news\" \"will smith imdb\" " +
- "\"will smith lyrics\" \"will smith dead\" " +
- "\"will smith nfl\" \"will smith new movie hancock\" " +
- "\"will smith biography\"'",
- intentModel);
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" +
+ MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV +
+ "=true&" +
+ NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true",
+ "query 'OR (AND willl smith) (AND will smith) " +
+ "\"will smith\" \"will smith movies\" " +
+ "\"will smith news\" \"will smith imdb\" " +
+ "\"will smith lyrics\" \"will smith dead\" " +
+ "\"will smith nfl\" \"will smith new movie hancock\" " +
+ "\"will smith biography\"'",
+ intentModel);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java
index 6f856144b8a..49d43bdc4c2 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/ModelTestCase.java
@@ -4,18 +4,16 @@ package com.yahoo.search.query.test;
import com.yahoo.prelude.query.Item;
import com.yahoo.search.Query;
import com.yahoo.search.query.Model;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.LinkedHashSet;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
@@ -25,13 +23,13 @@ public class ModelTestCase {
String oldConfigId;
- @Before
+ @BeforeEach
public void setUp() {
oldConfigId = System.getProperty("config.id");
System.setProperty("config.id", "file:src/test/java/com/yahoo/prelude/test/fieldtypes/field-info.cfg");
}
- @After
+ @AfterEach
public void tearDown() {
if (oldConfigId == null)
System.getProperties().remove("config.id");
@@ -40,30 +38,30 @@ public class ModelTestCase {
}
@Test
- public void testCopyParameters() {
+ void testCopyParameters() {
Query q1 = new Query("?query=test1&filter=test2&default-index=content&default-index=lala&encoding=iso8859-1");
Query q2 = q1.clone();
Model r1 = q1.getModel();
Model r2 = q2.getModel();
assertTrue(r1 != r2);
- assertEquals(r1,r2);
- assertEquals("test1",r2.getQueryString());
+ assertEquals(r1, r2);
+ assertEquals("test1", r2.getQueryString());
}
@Test
- public void testSetQuery() {
+ void testSetQuery() {
Query q1 = new Query("?query=test1");
Item r1 = q1.getModel().getQueryTree();
- q1.properties().set("query","test2");
+ q1.properties().set("query", "test2");
q1.getModel().setQueryString(q1.getModel().getQueryString()); // Force reparse
- assertNotSame(r1,q1.getModel().getQueryTree());
- q1.properties().set("query","test1");
+ assertNotSame(r1, q1.getModel().getQueryTree());
+ q1.properties().set("query", "test1");
q1.getModel().setQueryString(q1.getModel().getQueryString()); // Force reparse
- assertEquals(r1,q1.getModel().getQueryTree());
+ assertEquals(r1, q1.getModel().getQueryTree());
}
@Test
- public void testSetofSetters() {
+ void testSetofSetters() {
Query q1 = new Query("?query=test1&encoding=iso-8859-1&language=en&default-index=subject&filter=" + enc("\u00C5"));
Model r1 = q1.getModel();
assertEquals(r1.getQueryString(), "test1");
@@ -82,23 +80,23 @@ public class ModelTestCase {
}
@Test
- public void testSearchPath() {
- assertEquals("c6/r8",new Query("?query=test1&model.searchPath=c6/r8").getModel().getSearchPath());
- assertEquals("c6/r8",new Query("?query=test1&searchpath=c6/r8").getModel().getSearchPath());
+ void testSearchPath() {
+ assertEquals("c6/r8", new Query("?query=test1&model.searchPath=c6/r8").getModel().getSearchPath());
+ assertEquals("c6/r8", new Query("?query=test1&searchpath=c6/r8").getModel().getSearchPath());
}
@Test
- public void testClone() {
- Query q= new Query();
+ void testClone() {
+ Query q = new Query();
Model sr = new Model(q);
sr.setRestrict("music, cheese,other");
sr.setSources("cluster1");
assertEquals(sr.getSources(), new LinkedHashSet<>(Arrays.asList(new String[]{"cluster1"})));
- assertEquals(sr.getRestrict(),new LinkedHashSet<>(Arrays.asList(new String[]{"cheese","music","other"})));
+ assertEquals(sr.getRestrict(), new LinkedHashSet<>(Arrays.asList(new String[]{"cheese", "music", "other"})));
}
@Test
- public void testEquals() {
+ void testEquals() {
Query q = new Query();
Model sra = new Model(q);
sra.setRestrict("music,cheese");
@@ -107,20 +105,20 @@ public class ModelTestCase {
Model srb = new Model(q);
srb.setRestrict(" cheese , music");
srb.setSources("cluster1,cluster2");
- assertEquals(sra,srb);
+ assertEquals(sra, srb);
srb.setRestrict("music,cheese");
- assertNotSame(sra,srb);
+ assertNotSame(sra, srb);
}
@Test
- public void testSearchRestrictQueryParameters() {
- Query query=new Query("?query=test&search=news,archive&restrict=fish,bird");
+ void testSearchRestrictQueryParameters() {
+ Query query = new Query("?query=test&search=news,archive&restrict=fish,bird");
assertTrue(query.getModel().getSources().contains("news"));
assertTrue(query.getModel().getSources().contains("archive"));
- assertEquals(2,query.getModel().getSources().size());
+ assertEquals(2, query.getModel().getSources().size());
assertTrue(query.getModel().getRestrict().contains("fish"));
assertTrue(query.getModel().getRestrict().contains("bird"));
- assertEquals(2,query.getModel().getRestrict().size());
+ assertEquals(2, query.getModel().getRestrict().size());
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java
index c28e64196a2..df97c03ae68 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/ParametersTestCase.java
@@ -6,10 +6,10 @@ import com.yahoo.search.Query;
import com.yahoo.search.query.profile.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.yahoo.jdisc.http.HttpRequest.Method;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author bratseth
@@ -19,49 +19,49 @@ public class ParametersTestCase {
private final double delta = 0.000001;
@Test
- public void testSettingRankProperty() {
+ void testSettingRankProperty() {
Query query = new Query("?query=test&ranking.properties.dotProduct.X=(a:1,b:2)");
assertEquals("[(a:1,b:2)]", query.getRanking().getProperties().get("dotProduct.X").toString());
}
@Test
- public void testSettingRankPropertyAsAlias() {
+ void testSettingRankPropertyAsAlias() {
Query query = new Query("?query=test&rankproperty.dotProduct.X=(a:1,b:2)");
assertEquals("[(a:1,b:2)]", query.getRanking().getProperties().get("dotProduct.X").toString());
}
@Test
- public void testSettingRankFeature() {
+ void testSettingRankFeature() {
Query query = new Query("?query=test&ranking.features.matches=3");
assertEquals(3, query.getRanking().getFeatures().getDouble("matches").getAsDouble(), delta);
}
@Test
- public void testSettingRankFeatureAsAlias() {
+ void testSettingRankFeatureAsAlias() {
Query query = new Query("?query=test&rankfeature.matches=3");
assertEquals(3, query.getRanking().getFeatures().getDouble("matches").getAsDouble(), delta);
}
@Test
- public void testSettingRankPropertyWithQueryProfile() {
+ void testSettingRankPropertyWithQueryProfile() {
Query query = new Query(HttpRequest.createTestRequest("?query=test&ranking.properties.dotProduct.X=(a:1,b:2)", Method.GET), createProfile());
assertEquals("[(a:1,b:2)]", query.getRanking().getProperties().get("dotProduct.X").toString());
}
@Test
- public void testSettingRankPropertyAsAliasWithQueryProfile() {
+ void testSettingRankPropertyAsAliasWithQueryProfile() {
Query query = new Query(HttpRequest.createTestRequest("?query=test&rankproperty.dotProduct.X=(a:1,b:2)", Method.GET), createProfile());
assertEquals("[(a:1,b:2)]", query.getRanking().getProperties().get("dotProduct.X").toString());
}
@Test
- public void testSettingRankFeatureWithQueryProfile() {
+ void testSettingRankFeatureWithQueryProfile() {
Query query = new Query(HttpRequest.createTestRequest("?query=test&ranking.features.matches=3", Method.GET), createProfile());
assertEquals(3, query.getRanking().getFeatures().getDouble("matches").getAsDouble(), delta);
}
@Test
- public void testSettingRankFeatureAsAliasWithQueryProfile() {
+ void testSettingRankFeatureAsAliasWithQueryProfile() {
Query query = new Query(HttpRequest.createTestRequest("?query=test&rankfeature.matches=3", Method.GET), createProfile());
assertEquals(3, query.getRanking().getFeatures().getDouble("matches").getAsDouble(), delta);
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java
index aafbeaf5825..4aefd3c82e0 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/PresentationTestCase.java
@@ -4,11 +4,9 @@ package com.yahoo.search.query.test;
import com.yahoo.prelude.query.Highlight;
import com.yahoo.search.Query;
import com.yahoo.search.query.Presentation;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Arne Bergene Fossaa
@@ -16,20 +14,20 @@ import static org.junit.Assert.assertTrue;
public class PresentationTestCase {
@Test
- public void testClone() {
- Query q= new Query("");
+ void testClone() {
+ Query q = new Query("");
Presentation p = new Presentation(q);
p.setBolding(true);
Highlight h = new Highlight();
- h.addHighlightTerm("date","today");
+ h.addHighlightTerm("date", "today");
p.setHighlight(h);
- Presentation pc = (Presentation)p.clone();
- h.addHighlightTerm("title","Hello");
+ Presentation pc = (Presentation) p.clone();
+ h.addHighlightTerm("title", "Hello");
assertTrue(pc.getBolding());
pc.getHighlight().getHighlightItems();
assertTrue(pc.getHighlight().getHighlightItems().containsKey("date"));
assertFalse(pc.getHighlight().getHighlightItems().containsKey("title"));
- assertEquals(p,pc);
+ assertEquals(p, pc);
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java
index 0644a2b02e8..b1e406c47d7 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/RankFeaturesTestCase.java
@@ -10,7 +10,7 @@ import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.serialization.TypedBinaryFormat;
import com.yahoo.text.Utf8;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author geirst
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertEquals;
public class RankFeaturesTestCase {
@Test
- public void requireThatRankPropertiesTakesBothStringAndObject() {
+ void requireThatRankPropertiesTakesBothStringAndObject() {
RankProperties p = new RankProperties();
p.put("string", "b");
p.put("object", 7);
@@ -37,7 +37,7 @@ public class RankFeaturesTestCase {
@Test
@SuppressWarnings("deprecation")
- public void requireThatRankFeaturesUsingDoubleAndDoubleToStringEncodeTheSameWay() {
+ void requireThatRankFeaturesUsingDoubleAndDoubleToStringEncodeTheSameWay() {
RankFeatures withDouble = new RankFeatures(new Ranking(new Query()));
withDouble.put("query(myDouble)", 3.8);
assertEquals(3.8, withDouble.getDouble("query(myDouble)").getAsDouble(), 0.000001);
@@ -56,7 +56,7 @@ public class RankFeaturesTestCase {
}
@Test
- public void requireThatSingleTensorIsBinaryEncoded() {
+ void requireThatSingleTensorIsBinaryEncoded() {
TensorType type = new TensorType.Builder().mapped("x").mapped("y").mapped("z").build();
Tensor tensor = Tensor.from(type, "{ {x:a, y:b, z:c}:2.0, {x:a, y:b, z:c2}:3.0 }");
assertTensorEncodingAndDecoding(type, "query(my_tensor)", "my_tensor", tensor);
@@ -64,7 +64,7 @@ public class RankFeaturesTestCase {
}
@Test
- public void requireThatMultipleTensorsAreBinaryEncoded() {
+ void requireThatMultipleTensorsAreBinaryEncoded() {
TensorType type = new TensorType.Builder().mapped("x").mapped("y").mapped("z").build();
Tensor tensor1 = Tensor.from(type, "{ {x:a, y:b, z:c}:2.0, {x:a, y:b, z:c2}:3.0 }");
Tensor tensor2 = Tensor.from(type, "{ {x:a, y:b, z:c}:5.0 }");
diff --git a/container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java b/container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java
index 7a9080f46db..a6bc7460f2e 100644
--- a/container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/test/RankingTestCase.java
@@ -3,10 +3,10 @@ package com.yahoo.search.query.test;
import com.yahoo.search.Query;
import com.yahoo.search.query.Sorting;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author Arne Bergene Fossaa
@@ -17,7 +17,7 @@ public class RankingTestCase {
/** Tests setting rank feature values */
@Test
- public void testRankFeatures() {
+ void testRankFeatures() {
// Check initializing from query
Query query = new Query("?query=test&ranking.features.query(name)=0.1&ranking.features.fieldMatch(foo)=0.2");
assertEquals(0.1, query.getRanking().getFeatures().getDouble("query(name)").getAsDouble(), delta);
@@ -30,8 +30,8 @@ public class RankingTestCase {
assertEquals(0.2, query.getRanking().getFeatures().getDouble("fieldMatch(foo)").getAsDouble(), delta);
// Check programmatic setting + that the clone really has a separate object
- assertFalse(clone.getRanking().getFeatures() == query.getRanking().getFeatures());
- clone.properties().set("ranking.features.query(name)","0.3");
+ assertNotNull(query.getRanking().getFeatures());
+ clone.properties().set("ranking.features.query(name)", "0.3");
assertEquals(0.3, clone.getRanking().getFeatures().getDouble("query(name)").getAsDouble(), delta);
assertEquals(0.1, query.getRanking().getFeatures().getDouble("query(name)").getAsDouble(), delta);
@@ -47,7 +47,7 @@ public class RankingTestCase {
// This test is order dependent. Fix this!!
@Test
- public void test_setting_rank_feature_values() {
+ void test_setting_rank_feature_values() {
// Check initializing from query
Query query = new Query("?query=test&ranking.properties.foo=bar1&ranking.properties.foo2=bar2&ranking.properties.other=10");
assertEquals("bar1", query.getRanking().getProperties().get("foo").get(0));
@@ -57,13 +57,13 @@ public class RankingTestCase {
// Test cloning
Query clone = query.clone();
- assertFalse(clone.getRanking().getProperties() == query.getRanking().getProperties());
+ assertNotNull(query.getRanking().getProperties());
assertEquals("bar1", clone.getRanking().getProperties().get("foo").get(0));
assertEquals("bar2", clone.getRanking().getProperties().get("foo2").get(0));
assertEquals("10", clone.getRanking().getProperties().get("other").get(0));
// Check programmatic setting mean addition
- clone.properties().set("ranking.properties.other","12");
+ clone.properties().set("ranking.properties.other", "12");
assertEquals("[10, 12]", clone.getRanking().getProperties().get("other").toString());
assertEquals("[10]", query.getRanking().getProperties().get("other").toString());
@@ -74,14 +74,14 @@ public class RankingTestCase {
/** Test setting sorting to null does not cause an exception. */
@Test
- public void testResetSorting() {
+ void testResetSorting() {
Query q = new Query();
- q.getRanking().setSorting((Sorting)null);
- q.getRanking().setSorting((String)null);
+ q.getRanking().setSorting((Sorting) null);
+ q.getRanking().setSorting((String) null);
}
@Test
- public void testStructuredRankProperty() {
+ void testStructuredRankProperty() {
Query query = new Query("?query=abc&rankproperty.distanceToPath(gps_position).path=(0,0,10,0,10,5,20,5)");
assertEquals("(0,0,10,0,10,5,20,5)", query.getRanking().getProperties().get("distanceToPath(gps_position).path").get(0));
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java b/container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java
index b351bfb927a..07beabe14f3 100644
--- a/container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/textserialize/item/test/ParseItemTestCase.java
@@ -19,13 +19,11 @@ import com.yahoo.search.query.textserialize.item.ItemContext;
import com.yahoo.search.query.textserialize.item.ItemFormHandler;
import com.yahoo.search.query.textserialize.parser.ParseException;
import com.yahoo.search.query.textserialize.parser.Parser;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.StringReader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Tony Vaagenes
@@ -40,12 +38,12 @@ public class ParseItemTestCase {
}
@Test
- public void parse_and() throws ParseException {
+ void parse_and() throws ParseException {
assertTrue(parse("(AND)") instanceof AndItem);
}
@Test
- public void parse_and_with_children() throws ParseException {
+ void parse_and_with_children() throws ParseException {
AndItem andItem = (AndItem) parse("(AND (WORD 'first') (WORD 'second'))");
assertEquals(2, andItem.getItemCount());
@@ -53,116 +51,120 @@ public class ParseItemTestCase {
}
@Test
- public void parse_or() throws ParseException {
+ void parse_or() throws ParseException {
assertTrue(parse("(OR)") instanceof OrItem);
}
@Test
- public void parse_and_not_rest() throws ParseException {
+ void parse_and_not_rest() throws ParseException {
assertTrue(parse("(AND-NOT-REST)") instanceof NotItem);
}
@Test
- public void parse_and_not_rest_with_children() throws ParseException {
+ void parse_and_not_rest_with_children() throws ParseException {
NotItem notItem = (NotItem) parse("(AND-NOT-REST (WORD 'positive') (WORD 'negative'))");
assertEquals("positive", getWord(notItem.getPositiveItem()));
assertEquals("negative", getWord(notItem.getItem(1)));
}
@Test
- public void parse_and_not_rest_with_only_negated_children() throws ParseException {
+ void parse_and_not_rest_with_only_negated_children() throws ParseException {
NotItem notItem = (NotItem) parse("(AND-NOT-REST null (WORD 'negated-item'))");
assertTrue(notItem.getPositiveItem() instanceof TrueItem);
assertTrue(notItem.getItem(1) instanceof WordItem);
}
@Test
- public void parse_rank() throws ParseException {
+ void parse_rank() throws ParseException {
assertTrue(parse("(RANK (WORD 'first'))") instanceof RankItem);
}
@Test
- public void parse_word() throws ParseException {
+ void parse_word() throws ParseException {
WordItem wordItem = (WordItem) parse("(WORD 'text')");
assertEquals("text", wordItem.getWord());
}
- @Test(expected = IllegalArgumentException.class)
- public void fail_when_word_given_multiple_strings() throws ParseException {
- parse("(WORD 'one' 'invalid')");
+ @Test
+ void fail_when_word_given_multiple_strings() throws ParseException {
+ assertThrows(IllegalArgumentException.class, () -> {
+ parse("(WORD 'one' 'invalid')");
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void fail_when_word_given_no_string() throws ParseException {
- parse("(WORD)");
+ @Test
+ void fail_when_word_given_no_string() throws ParseException {
+ assertThrows(IllegalArgumentException.class, () -> {
+ parse("(WORD)");
+ });
}
@Test
- public void parse_int() throws ParseException {
+ void parse_int() throws ParseException {
IntItem intItem = (IntItem) parse("(INT '[42;]')");
assertEquals("[42;]", intItem.getNumber());
}
@Test
- public void parse_range() throws ParseException {
+ void parse_range() throws ParseException {
IntItem intItem = (IntItem) parse("(INT '[42;73]')");
assertEquals("[42;73]", intItem.getNumber());
}
@Test
- public void parse_range_withlimit() throws ParseException {
+ void parse_range_withlimit() throws ParseException {
IntItem intItem = (IntItem) parse("(INT '[42;73;32]')");
assertEquals("[42;73;32]", intItem.getNumber());
}
@Test
- public void parse_prefix() throws ParseException {
+ void parse_prefix() throws ParseException {
PrefixItem prefixItem = (PrefixItem) parse("(PREFIX 'word')");
assertEquals("word", prefixItem.getWord());
}
@Test
- public void parse_subString() throws ParseException {
+ void parse_subString() throws ParseException {
SubstringItem subStringItem = (SubstringItem) parse("(SUBSTRING 'word')");
assertEquals("word", subStringItem.getWord());
}
@Test
- public void parse_exactString() throws ParseException {
+ void parse_exactString() throws ParseException {
ExactStringItem subStringItem = (ExactStringItem) parse("(EXACT 'word')");
assertEquals("word", subStringItem.getWord());
}
@Test
- public void parse_suffix() throws ParseException {
+ void parse_suffix() throws ParseException {
SuffixItem suffixItem = (SuffixItem) parse("(SUFFIX 'word')");
assertEquals("word", suffixItem.getWord());
}
@Test
- public void parse_phrase() throws ParseException {
+ void parse_phrase() throws ParseException {
PhraseItem phraseItem = (PhraseItem) parse("(PHRASE (WORD 'word'))");
assertTrue(phraseItem.getItem(0) instanceof WordItem);
}
@Test
- public void parse_near() throws ParseException {
+ void parse_near() throws ParseException {
assertTrue(parse("(NEAR)") instanceof NearItem);
}
@Test
- public void parse_onear() throws ParseException {
+ void parse_onear() throws ParseException {
assertTrue(parse("(ONEAR)") instanceof ONearItem);
}
@Test
- public void parse_near_with_distance() throws ParseException {
+ void parse_near_with_distance() throws ParseException {
NearItem nearItem = (NearItem) parse("(NEAR {'distance' 42} (WORD 'first'))");
assertEquals(42, nearItem.getDistance());
}
@Test
- public void parse_items_with_connectivity() throws ParseException {
+ void parse_items_with_connectivity() throws ParseException {
AndItem andItem = (AndItem) parse("(AND (WORD {'id' '1'} 'first') (WORD {'connectivity' ['1' 23.5]} 'second'))");
WordItem secondItem = (WordItem) andItem.getItem(1);
@@ -171,13 +173,13 @@ public class ParseItemTestCase {
}
@Test
- public void parse_word_with_index() throws ParseException {
+ void parse_word_with_index() throws ParseException {
WordItem wordItem = (WordItem) parse("(WORD {'index' 'someIndex'} 'text')");
assertEquals("someIndex", wordItem.getIndexName());
}
@Test
- public void parse_unicode_word() throws ParseException {
+ void parse_unicode_word() throws ParseException {
WordItem wordItem = (WordItem) parse("(WORD 'trăm')");
assertEquals("trăm", wordItem.getWord());
}
diff --git a/container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java b/container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java
index 133382cbe91..65458cfb8ee 100644
--- a/container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/textserialize/serializer/test/SerializeItemTestCase.java
@@ -11,12 +11,12 @@ import com.yahoo.prelude.query.PhraseItem;
import com.yahoo.prelude.query.WordItem;
import com.yahoo.search.query.textserialize.parser.ParseException;
import com.yahoo.search.query.textserialize.serializer.QueryTreeSerializer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static com.yahoo.search.query.textserialize.item.test.ParseItemTestCase.parse;
import static com.yahoo.search.query.textserialize.item.test.ParseItemTestCase.getWord;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Tony Vaagenes
@@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue;
public class SerializeItemTestCase {
@Test
- public void serialize_word_item() {
+ void serialize_word_item() {
WordItem item = new WordItem("test that \" and \\ works");
item.setIndexName("index\"Name");
@@ -34,7 +34,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_and_item() {
+ void serialize_and_item() {
AndItem andItem = new AndItem();
andItem.addItem(new WordItem("first"));
andItem.addItem(new WordItem("second"));
@@ -46,12 +46,12 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_or_item() {
+ void serialize_or_item() {
assertTrue(serializeThenParse(new OrItem()) instanceof OrItem);
}
@Test
- public void serialize_not_item() {
+ void serialize_not_item() {
NotItem notItem = new NotItem();
{
notItem.addItem(new WordItem("first"));
@@ -62,7 +62,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_near_item() {
+ void serialize_near_item() {
int distance = 23;
NearItem nearItem = new NearItem(distance);
{
@@ -77,8 +77,8 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_phrase_item() throws ParseException {
- PhraseItem phraseItem = new PhraseItem(new String[] {"first", "second"});
+ void serialize_phrase_item() throws ParseException {
+ PhraseItem phraseItem = new PhraseItem(new String[]{"first", "second"});
phraseItem.setIndexName("indexName");
PhraseItem deSerialized = serializeThenParse(phraseItem);
@@ -88,7 +88,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_equiv_item() {
+ void serialize_equiv_item() {
EquivItem equivItem = new EquivItem();
equivItem.addItem(new WordItem("first"));
@@ -97,7 +97,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_connectivity() {
+ void serialize_connectivity() {
OrItem orItem = new OrItem();
{
WordItem first = new WordItem("first");
@@ -117,7 +117,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_significance() {
+ void serialize_significance() {
EquivItem equivItem = new EquivItem();
equivItem.setSignificance(24.2);
@@ -126,7 +126,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_unique_id() {
+ void serialize_unique_id() {
EquivItem equivItem = new EquivItem();
equivItem.setUniqueID(42);
@@ -135,7 +135,7 @@ public class SerializeItemTestCase {
}
@Test
- public void serialize_weight() {
+ void serialize_weight() {
EquivItem equivItem = new EquivItem();
equivItem.setWeight(42);