diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-02-07 14:36:41 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-02-07 14:36:41 +0100 |
commit | 70227078bed8a4eed2a297af84b10783456e84a7 (patch) | |
tree | 68efb6a7614775d8d1a56806e50080952059762c /container-search/src/test | |
parent | 54e4df56234906450f2d6bf82a0527e924e987f7 (diff) |
Wire in property presentation.format.tensors with alias format.tensors
- Move presentation.format.tensors from JsonRenderer to Presentation
- Add aliases recursively
- Allow compound aliases
- Allow a query profile type to describe its own value
Diffstat (limited to 'container-search/src/test')
3 files changed, 26 insertions, 9 deletions
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 60b6c6dbe84..3ed044601f0 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 @@ -11,7 +11,7 @@ import static org.junit.Assert.assertTrue; */ public class DumpToolTestCase { - private String profileDir = "src/test/java/com/yahoo/search/query/profile/config/test/multiprofile"; + private final String profileDir = "src/test/java/com/yahoo/search/query/profile/config/test/multiprofile"; @Test public void testNoParameters() { @@ -25,12 +25,13 @@ public class DumpToolTestCase { @Test public void testNoDimensionValues() { - assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir).startsWith("a=general-a\n")); + System.out.println(new DumpTool().resolveAndDump("multiprofile1", profileDir)); + assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir).contains("a=general-a\n")); } @Test public void testAllParametersSet() { - assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir, "").startsWith("a=general-a\n")); + assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir, "").contains("a=general-a\n")); } @Test 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 4b8edfdde73..fa7508ea5ac 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 @@ -47,7 +47,6 @@ public class NameTestCase { assertLegalFieldName("a/b"); assertLegalFieldName("/a/b"); assertLegalFieldName("/a/b/"); - assertIllegalFieldName(""); assertIllegalFieldName("aBc.dooEee.ce_d.-some-other.moreHere", "Could not set 'aBc.dooEee.ce_d.-some-other.moreHere' to 'anyValue'", "Illegal name '-some-other'"); diff --git a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java index f3a71af0b9e..95ef4ec3051 100644 --- a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java @@ -54,6 +54,7 @@ import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; import com.yahoo.tensor.serialization.TypedBinaryFormat; import com.yahoo.text.Utf8; +import com.yahoo.yolean.Exceptions; import com.yahoo.yolean.trace.TraceNode; import org.junit.Before; import org.junit.Test; @@ -69,6 +70,7 @@ import java.util.concurrent.ExecutionException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Functional testing of {@link JsonRenderer}. @@ -165,11 +167,26 @@ public class JsonRendererTestCase { h.setField("tensor_mixed", new TensorFieldValue(Tensor.from("tensor(x{},y[2]):{a:[1,2], b:[3,4]}"))); h.setField("summaryfeatures", summaryFeatures); - Result r = new Result(new Query("/?format.tensors=short")); - r.hits().add(h); - r.setTotalHitCount(1L); - String summary = render(r); - assertEqualJson(expected, summary); + Result result1 = new Result(new Query("/?presentation.format.tensors=short")); + result1.hits().add(h); + result1.setTotalHitCount(1L); + String summary1 = render(result1); + assertEqualJson(expected, summary1); + + Result result2 = new Result(new Query("/?format.tensors=short")); + result2.hits().add(h); + result2.setTotalHitCount(1L); + String summary2 = render(result2); + assertEqualJson(expected, summary2); + + try { + render(new Result(new Query("/?presentation.format.tensors=unknown"))); + fail("Expected exception"); + } + catch (IllegalArgumentException e) { + assertEquals("Could not set 'presentation.format.tensors' to 'unknown': Value must be 'long' or 'short', not 'unknown'", + Exceptions.toMessageString(e)); + } } @Test |