aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/query
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-29 12:25:00 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2023-03-29 12:34:00 +0200
commit656e755c584897d298fcf95bea5376f1fb1c13f5 (patch)
treea7f7423e01ae62a46c33abbcb6f658d8ef16014c /container-search/src/test/java/com/yahoo/search/query
parent7ac642eefd2be2b52aa0878ad8d926521fe00a20 (diff)
Use CompoundName.from in tests and construction of static objects.
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/query')
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/config/test/XmlReadingTestCase.java32
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetInComplexStructureMicroBenchmark.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetMicroBenchmark.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java13
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/QueryProfileTypeTestCase.java2
7 files changed, 32 insertions, 33 deletions
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 dcb41dc5e31..326c7985a5f 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
@@ -3,10 +3,8 @@ package com.yahoo.search.query.profile.config.test;
import com.yahoo.jdisc.http.HttpRequest.Method;
import com.yahoo.container.jdisc.HttpRequest;
-import com.yahoo.language.Language;
import com.yahoo.language.process.Embedder;
import com.yahoo.processing.request.CompoundName;
-import com.yahoo.search.query.profile.types.test.QueryProfileTypeTestCase;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.yolean.Exceptions;
@@ -25,7 +23,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author bratseth
@@ -77,8 +79,8 @@ public class XmlReadingTestCase {
CompiledQueryProfile defaultProfile = cRegistry.getComponent("default");
assertNull(defaultProfile.getType());
assertEquals("20", defaultProfile.get("hits"));
- assertFalse(defaultProfile.isOverridable(new CompoundName("hits"), null));
- assertFalse(defaultProfile.isOverridable(new CompoundName("user.trusted"), null));
+ assertFalse(defaultProfile.isOverridable(CompoundName.from("hits"), null));
+ assertFalse(defaultProfile.isOverridable(CompoundName.from("user.trusted"), null));
assertEquals("false", defaultProfile.get("user.trusted"));
CompiledQueryProfile referencingProfile = cRegistry.getComponent("referencingModelSettings");
@@ -97,7 +99,7 @@ public class XmlReadingTestCase {
assertEquals("rootType", rootProfile.getType().getId().getName());
assertEquals(30, rootProfile.get("hits"));
//assertEquals(3, rootProfile.get("traceLevel"));
- assertTrue(rootProfile.isOverridable(new CompoundName("hits"), null));
+ assertTrue(rootProfile.isOverridable(CompoundName.from("hits"), null));
query = new Query(request, rootProfile);
assertEquals(3, query.getTrace().getLevel());
@@ -231,8 +233,8 @@ public class XmlReadingTestCase {
assertEquals("a.b.c-value", new Query("?d1=d1v", profile).properties().get("a.b.c"));
assertEquals("a.b.c-variant-value", new Query("?d1=d1v&d2=d2v", profile).properties().get("a.b.c"));
- assertTrue(profile.isOverridable(new CompoundName("a.b.c"), Map.of("d1", "d1v")));
- assertFalse(profile.isOverridable(new CompoundName("a.b.c"), Map.of("d1", "d1v", "d2", "d2v")));
+ assertTrue(profile.isOverridable(CompoundName.from("a.b.c"), Map.of("d1", "d1v")));
+ assertFalse(profile.isOverridable(CompoundName.from("a.b.c"), Map.of("d1", "d1v", "d2", "d2v")));
}
@Test
@@ -479,18 +481,18 @@ public class XmlReadingTestCase {
QueryProfileType type1 = registry.getTypeRegistry().getComponent("type1");
assertEquals(TensorType.fromSpec("tensor<float>(x[1])"),
- 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)")));
+ type1.getFieldType(CompoundName.from("ranking.features.query(tensor_1)")).asTensorType());
+ assertNull(type1.getFieldType(CompoundName.from("ranking.features.query(tensor_2)")));
+ assertNull(type1.getFieldType(CompoundName.from("ranking.features.query(tensor_3)")));
assertEquals(TensorType.fromSpec("tensor(key{})"),
- type1.getFieldType(new CompoundName("ranking.features.query(tensor_4)")).asTensorType());
+ type1.getFieldType(CompoundName.from("ranking.features.query(tensor_4)")).asTensorType());
QueryProfileType type2 = registry.getTypeRegistry().getComponent("type2");
- assertNull(type2.getFieldType(new CompoundName("ranking.features.query(tensor_1)")));
+ assertNull(type2.getFieldType(CompoundName.from("ranking.features.query(tensor_1)")));
assertEquals(TensorType.fromSpec("tensor<float>(x[2])"),
- type2.getFieldType(new CompoundName("ranking.features.query(tensor_2)")).asTensorType());
+ type2.getFieldType(CompoundName.from("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(CompoundName.from("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]")
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetInComplexStructureMicroBenchmark.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetInComplexStructureMicroBenchmark.java
index cd5a8e08aa9..080aef25c5f 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetInComplexStructureMicroBenchmark.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetInComplexStructureMicroBenchmark.java
@@ -65,8 +65,8 @@ public class QueryProfileGetInComplexStructureMicroBenchmark {
Map<String,String> dimensionValues=createDimensionValueMap();
String prefix=generatePrefix();
final int dotInterval=1000000;
- final CompoundName found = new CompoundName(prefix + "a");
- final CompoundName notFound = new CompoundName(prefix + "nonexisting");
+ final CompoundName found = CompoundName.from(prefix + "a");
+ final CompoundName notFound = CompoundName.from(prefix + "nonexisting");
for (int i=0; i<count; i++) {
if (count>dotInterval && i%(dotInterval)==0)
System.out.print(".");
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetMicroBenchmark.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetMicroBenchmark.java
index d38a1d64910..1123feb1b01 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetMicroBenchmark.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileGetMicroBenchmark.java
@@ -57,8 +57,8 @@ public class QueryProfileGetMicroBenchmark {
private void getValues(int count,Query query) {
final int dotInterval=10000000;
- CompoundName found = new CompoundName(propertyPrefix + "property1");
- CompoundName notFound = new CompoundName(propertyPrefix + "nonExisting");
+ CompoundName found = CompoundName.from(propertyPrefix + "property1");
+ CompoundName notFound = CompoundName.from(propertyPrefix + "nonExisting");
for (int i=0; i<count; i++) {
if (count>dotInterval && i%(count/dotInterval)==0)
System.out.print(".");
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 cd4cb32df2e..7d5a2137770 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
@@ -534,7 +534,7 @@ public class QueryProfileTestCase {
p.set("a.b", "a.b-value", null);
{
- Map<String, ValueWithSource> values = p.compile(null).listValuesWithSources(new CompoundName(""), new HashMap<>(), null);
+ Map<String, ValueWithSource> values = p.compile(null).listValuesWithSources(CompoundName.empty, new HashMap<>(), null);
assertEquals(2, values.size());
assertEquals("a-value", values.get("a").value());
assertEquals("test", values.get("a").source());
@@ -543,7 +543,7 @@ public class QueryProfileTestCase {
}
{
- Map<String, ValueWithSource> values = p.compile(null).listValuesWithSources(new CompoundName("a"), new HashMap<>(), null);
+ Map<String, ValueWithSource> values = p.compile(null).listValuesWithSources(CompoundName.from("a"), new HashMap<>(), null);
assertEquals(1, values.size());
assertEquals("a.b-value", values.get("b").value());
assertEquals("test", values.get("b").source());
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 1a6cfee75a5..36ff33ffd97 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
@@ -5,7 +5,6 @@ import ai.vespa.cloud.ApplicationId;
import ai.vespa.cloud.Environment;
import ai.vespa.cloud.Zone;
import ai.vespa.cloud.ZoneInfo;
-import com.yahoo.jdisc.application.Application;
import com.yahoo.jdisc.http.HttpRequest.Method;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.processing.request.CompoundName;
@@ -28,7 +27,9 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author bratseth
@@ -133,7 +134,7 @@ public class QueryProfileVariantsTestCase {
base.set("a.b", 1, new String[]{null, null, "d3-val"}, registry);
QueryProfileVariant aVariants = base.getVariants().getVariants().get(0);
assertEquals("[d1, d2, d3]",
- ((QueryProfile) base.getVariants().getVariants().get(0).values().get("a")).getDimensions().toString(),
+ ((QueryProfile) aVariants.values().get("a")).getDimensions().toString(),
"Variant dimensions are not overridden by the referenced dimensions");
}
@@ -184,7 +185,7 @@ public class QueryProfileVariantsTestCase {
{
Map<String, ValueWithSource> values = cRegistry.findQueryProfile("test")
- .listValuesWithSources(new CompoundName(""),
+ .listValuesWithSources(CompoundName.empty,
new HashMap<>(),
null);
assertEquals(1, values.size());
@@ -195,7 +196,7 @@ public class QueryProfileVariantsTestCase {
{
Map<String, ValueWithSource> values = cRegistry.findQueryProfile("test")
- .listValuesWithSources(new CompoundName(""),
+ .listValuesWithSources(CompoundName.empty,
toMap("x=x1", "y=y1", "z=z1"),
null);
assertEquals(2, values.size());
@@ -1456,7 +1457,7 @@ public class QueryProfileVariantsTestCase {
return context;
}
- public static final Map<String, String> toMap(String... bindings) {
+ public static Map<String, String> toMap(String... bindings) {
Map<String, String> context = new HashMap<>();
for (String binding : bindings) {
String[] entry = binding.split("=");
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 37991f7f14f..982ebd80fbd 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
@@ -55,7 +55,7 @@ public class NameTestCase {
@Test
void testComponentIdAsCompoundName() {
String name = "a/b";
- assertEquals(new CompoundName(name), new QueryProfileType(name).getComponentIdAsCompoundName());
+ assertEquals(CompoundName.from(name), new QueryProfileType(name).getComponentIdAsCompoundName());
}
private void assertLegalName(String name) {
@@ -89,10 +89,6 @@ public class NameTestCase {
}
}
- private void assertIllegalFieldName(String name) {
- assertIllegalFieldName(name,"Could not set '" + name + "' to 'anyValue'","Illegal name '" + name + "'");
- }
-
/** Checks that this is illegal both for profiles and types */
private void assertIllegalFieldName(String name, String expectedHighError, String expectedLowError) {
try {
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 21a9b2fe399..4000c48bfed 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
@@ -761,7 +761,7 @@ public class QueryProfileTypeTestCase {
}
private void assertNotPermitted(QueryProfile profile,String name,Object value) {
- String localName = new CompoundName(name).last();
+ String localName = CompoundName.from(name).last();
try {
profile.set(name, value, registry);
fail("Should fail setting " + name + " to " + value);