aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@oath.com>2018-11-22 16:20:27 +0100
committerTor Brede Vekterli <vekterli@oath.com>2018-11-22 16:33:24 +0100
commitcb4ffb997d22a1128b33fe3ea0b07f1a2b9862b9 (patch)
tree38de3229e1e0b6a26fd2db8d8daa453410600c56 /config-model/src/test
parent439f4d13240ee420a9270625406035ffa28a5ba7 (diff)
Add unit test for position zcurve field not being part of [document] fieldset
Should work as expected when the field is defined in a parent document type.
Diffstat (limited to 'config-model/src/test')
-rw-r--r--config-model/src/test/examples/position_base.sd8
-rw-r--r--config-model/src/test/examples/position_inherited.sd4
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java13
3 files changed, 25 insertions, 0 deletions
diff --git a/config-model/src/test/examples/position_base.sd b/config-model/src/test/examples/position_base.sd
new file mode 100644
index 00000000000..8f8ff85cff2
--- /dev/null
+++ b/config-model/src/test/examples/position_base.sd
@@ -0,0 +1,8 @@
+# Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+search position_base {
+ document position_base {
+ field pos type position {
+ indexing: attribute
+ }
+ }
+}
diff --git a/config-model/src/test/examples/position_inherited.sd b/config-model/src/test/examples/position_inherited.sd
new file mode 100644
index 00000000000..b3341e01f80
--- /dev/null
+++ b/config-model/src/test/examples/position_inherited.sd
@@ -0,0 +1,4 @@
+# Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+search position_inherited {
+ document position_inherited inherits position_base {}
+}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java
index d8749d8eb32..9cf555e2c9a 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java
@@ -6,6 +6,7 @@ import com.yahoo.document.PositionDataType;
import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.document.Attribute;
+import com.yahoo.searchdefinition.document.FieldSet;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.documentmodel.SummaryField;
import com.yahoo.vespa.documentmodel.SummaryTransform;
@@ -14,6 +15,7 @@ import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Iterator;
import static org.junit.Assert.*;
@@ -26,6 +28,17 @@ import static org.junit.Assert.*;
public class PositionTestCase {
@Test
+ public void inherited_position_zcurve_field_is_not_added_to_document_fieldset() throws Exception {
+ SearchBuilder sb = SearchBuilder.createFromFiles(Arrays.asList(
+ "src/test/examples/position_base.sd",
+ "src/test/examples/position_inherited.sd"));
+
+ Search search = sb.getSearch("position_inherited");
+ FieldSet fieldSet = search.getDocument().getFieldSets().builtInFieldSets().get("[document]"); // TODO why is this not public in BuiltInFieldSets?
+ assertFalse(fieldSet.getFieldNames().contains(PositionDataType.getZCurveFieldName("pos")));
+ }
+
+ @Test
public void requireThatPositionCanBeAttribute() throws Exception {
Search search = SearchBuilder.buildFromFile("src/test/examples/position_attribute.sd");
assertNull(search.getAttribute("pos"));