summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2020-08-25 19:10:49 +0200
committerGitHub <noreply@github.com>2020-08-25 19:10:49 +0200
commit0c7fecf57e821f2b7fc587a16966b84fc2b919fe (patch)
treec02bad23d32f04a57fb90a1d82cbb383fa520852
parentd448cee8e76c5e9820f71523f5617993e58f6ace (diff)
parent94a0d89df738fb0372569fc2a2330712e299b56f (diff)
Merge pull request #14156 from vespa-engine/bratseth/bolding-test
Bratseth/bolding test
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java55
-rw-r--r--config-model/src/test/processing/boldnonstring.sd14
2 files changed, 42 insertions, 27 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java
index 9a4357c5d65..911f8e797e1 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java
@@ -1,33 +1,62 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.config.model.application.provider.BaseDeployLogger;
-import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.SchemaTestCase;
import com.yahoo.searchdefinition.parser.ParseException;
-import com.yahoo.vespa.model.container.search.QueryProfiles;
import org.junit.Test;
-import java.io.IOException;
-
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
- * @author Mathias Mølster Lidal
+ * @author bratseth
*/
public class BoldingTestCase extends SchemaTestCase {
+ private final String boldonnonstring =
+ "search boldnonstring {\n" +
+ " document boldnonstring {\n" +
+ " field title type string {\n" +
+ " indexing: summary | index\n" +
+ " }\n" +
+ "\n" +
+ " field year4 type int {\n" +
+ " indexing: summary | attribute\n" +
+ " bolding: on\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+
+ @Test
+ public void testBoldOnNonString() throws ParseException {
+ try {
+ SearchBuilder.createFromString(boldonnonstring);
+ fail("Expected exception");
+ } catch (IllegalArgumentException e) {
+ assertEquals("'bolding: on' for non-text field 'year4' (datatype int (code: 0)) is not allowed",
+ e.getMessage());
+ }
+ }
+
+ private final String boldonarray =
+ "search boldonarray {\n" +
+ " document boldonarray {\n" +
+ " field myarray type array<string> {\n" +
+ " indexing: summary | index\n" +
+ " bolding: on\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+
@Test
- public void testBoldingNonString() throws IOException, ParseException {
+ public void testBoldOnArray() throws ParseException {
try {
- Search search = SearchBuilder.buildFromFile("src/test/processing/boldnonstring.sd");
- new Bolding(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true, false);
- fail();
+ SearchBuilder.createFromString(boldonarray);
+ fail("Expected exception");
} catch (IllegalArgumentException e) {
- assertTrue(e.getMessage().contains("'bolding: on' for non-text field"));
+ assertEquals("'bolding: on' for non-text field 'myarray' (datatype Array<string> (code: -1486737430)) is not allowed",
+ e.getMessage());
}
}
diff --git a/config-model/src/test/processing/boldnonstring.sd b/config-model/src/test/processing/boldnonstring.sd
deleted file mode 100644
index a5b515cad8e..00000000000
--- a/config-model/src/test/processing/boldnonstring.sd
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-search boldnonstring {
- document boldnonstring {
- field title type string {
- indexing: summary | index
- # index-to: title, default
- }
-
- field year4 type int {
- indexing: summary | attribute
- bolding: on
- }
- }
-}