summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-08-25 12:43:15 +0200
committerJon Bratseth <bratseth@gmail.com>2020-08-25 12:43:15 +0200
commitf2a8359b0ea589611a917f6a736ed2e0b6039243 (patch)
tree8c15a759d8010f9a97aabb5a2b7a6a8ba3f8ecd0 /config-model
parent1d5ffb9f0996c44f1b1fa29fd9773a14b477973c (diff)
Test bolding on array
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java55
1 files changed, 42 insertions, 13 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());
}
}