diff options
author | Geir Storli <geirst@oath.com> | 2018-05-31 15:23:26 +0000 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2018-05-31 15:23:26 +0000 |
commit | a94c73bc75e89f041056c8fc347fe23d652db505 (patch) | |
tree | 8d32ea089c7371627866046c9db63d11b6b695cf /config-model/src/test/java/com/yahoo/searchdefinition | |
parent | edc2ad6efe8fb8072e8860dc9a4849cfeb3d0680 (diff) |
Support that map of simple struct field is derived into array attributes.
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition')
3 files changed, 21 insertions, 5 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java index 990ebe7f993..c3cfcae66e6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java @@ -79,6 +79,17 @@ public class AttributeListTestCase extends SearchDefinitionTestCase { assertTrue(!attributes.hasNext()); } + @Test + public void map_of_struct_field_is_derived_into_array_attributes() throws IOException, ParseException { + Search search = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); + Iterator<Attribute> attributes = new AttributeFields(search).attributeIterator(); + + assertAttribute("elem_map.key", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, attributes.next()); + assertAttribute("elem_map.value.name", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, attributes.next()); + assertAttribute("elem_map.value.weight", Attribute.Type.INTEGER, Attribute.CollectionType.ARRAY, attributes.next()); + assertTrue(!attributes.hasNext()); + } + private static void assertAttribute(String name, Attribute.Type type, Attribute.CollectionType collection, Attribute attr) { assertEquals(name, attr.getName()); assertEquals(type, attr.getType()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributesTestCase.java index 9e73edf9b35..72c7aab4a39 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributesTestCase.java @@ -18,4 +18,14 @@ public class AttributesTestCase extends AbstractExportingTestCase { assertCorrectDeriving("attributes"); } + @Test + public void testArrayOfStructAttribute() throws IOException, ParseException { + assertCorrectDeriving("array_of_struct_attribute"); + } + + @Test + public void testMapOfStructAttribute() throws IOException, ParseException { + assertCorrectDeriving("map_of_struct_attribute"); + } + } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java index dc2d3b7cea1..4600f6ae4c6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java @@ -139,9 +139,4 @@ public class ExportingTestCase extends AbstractExportingTestCase { assertCorrectDeriving("tensor"); } - @Test - public void testArrayOfStructAttribute() throws IOException, ParseException { - assertCorrectDeriving("array_of_struct_attribute"); - } - } |