diff options
author | Geir Storli <geirstorli@yahoo.no> | 2018-08-30 17:54:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 17:54:07 +0200 |
commit | 2b80c840e6b34ac21ba114861a76597a12d68a07 (patch) | |
tree | 9344ad35ee8891b27c98721c6c9346913f88071f /config-model/src/test | |
parent | 34136011499a03f8bd9bbc13e56b83dba5bf14f3 (diff) | |
parent | ba2abc66b62c9e31e91baeee98f2efb1b7fc2fe1 (diff) |
Merge pull request #6739 from vespa-engine/balder/update-config-too
Generate and test config produced.
Diffstat (limited to 'config-model/src/test')
-rw-r--r-- | config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java index 204be96555f..d7f26cd9851 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java @@ -2,10 +2,12 @@ package com.yahoo.searchdefinition; import com.yahoo.document.StructDataType; +import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.tensor.TensorType; +import com.yahoo.vespa.config.search.AttributesConfig; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -96,11 +98,15 @@ public class AttributeSettingsTestCase extends SearchDefinitionTestCase { assertTrue(attr.isFastAccess()); } - private Attribute getAttributeF(String sd) throws ParseException { + private Search getSearch(String sd) throws ParseException { SearchBuilder builder = new SearchBuilder(); builder.importString(sd); builder.build(); - Search search = builder.getSearch(); + return builder.getSearch(); + } + + private Attribute getAttributeF(String sd) throws ParseException { + Search search = getSearch(sd); SDField field = (SDField) search.getDocument().getField("f"); return field.getAttributes().get(field.getName()); } @@ -121,8 +127,7 @@ public class AttributeSettingsTestCase extends SearchDefinitionTestCase { public void requireThatMutableCanNotbeSetInDocument() throws ParseException { exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage("Field 'f' in 'test' can not be marked mutable as it is inside the document clause."); - Attribute attr = getAttributeF( - "search test {\n" + + getSearch("search test {\n" + " document test {\n" + " field f type int {\n" + " indexing: attribute\n" + @@ -133,7 +138,7 @@ public class AttributeSettingsTestCase extends SearchDefinitionTestCase { } @Test - public void requireThatMutableExtraFieldCanBeSet() throws IOException, ParseException { + public void requireThatMutableExtraFieldCanBeSet() throws ParseException { Attribute attr = getAttributeF( "search test {\n" + " document test { \n" + @@ -150,6 +155,38 @@ public class AttributeSettingsTestCase extends SearchDefinitionTestCase { } @Test + public void requireThatMutableConfigIsProperlyPropagated() throws ParseException{ + + AttributeFields attributes = new AttributeFields(getSearch( + "search test {\n" + + " document test { \n" + + " field a type int { \n" + + " indexing: attribute \n" + + " }\n" + + " }\n" + + " field m type long {\n" + + " indexing: 0 | to_long | attribute\n" + + " attribute: mutable\n" + + " }\n" + + " field f type long {\n" + + " indexing: 0 | to_long | attribute\n" + + " }\n" + + "}\n")); + AttributesConfig.Builder builder = new AttributesConfig.Builder(); + attributes.getConfig(builder); + AttributesConfig cfg = new AttributesConfig(builder); + assertEquals("a", cfg.attribute().get(0).name()); + assertFalse(cfg.attribute().get(0).ismutable()); + + assertEquals("f", cfg.attribute().get(1).name()); + assertFalse(cfg.attribute().get(1).ismutable()); + + assertEquals("m", cfg.attribute().get(2).name()); + assertTrue(cfg.attribute().get(2).ismutable()); + + } + + @Test public void attribute_convert_to_array_copies_internal_state() { StructDataType refType = new StructDataType("my_struct"); Attribute single = new Attribute("foo", Attribute.Type.STRING, Attribute.CollectionType.SINGLE, |