aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-07-03 14:18:16 +0000
committerGeir Storli <geirst@yahooinc.com>2023-07-03 14:18:16 +0000
commit60819f2638b4b3d7bcb27e62d6b56431055c9ab9 (patch)
treefb29161f68835d67c53289a7dd2d35b8a9d9c568 /config-model/src/test/java
parente02a187ae0951b3ee506ea930080b7b67a857df2 (diff)
Improve validation of complex fields using struct field attributes.
With this more unsupported (and rare setups) are caught by the validator.
Diffstat (limited to 'config-model/src/test/java')
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java30
1 files changed, 29 insertions, 1 deletions
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java
index c673d5899e8..f3517f9ef48 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java
@@ -68,9 +68,37 @@ public class ComplexFieldsValidatorTestCase {
"}",
"}"));
});
- assertTrue(exception.getMessage().contains(getExpectedMessage("docTopics (docTopics.topics)")));
+ assertTrue(exception.getMessage().contains(getExpectedMessage("docTopics (docTopics.topics, docTopics.topics.id, docTopics.topics.label)")));
}
+ @Test
+ void throws_exception_when_struct_field_inside_nested_struct_array_is_specified_as_attribute() throws IOException, SAXException {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ createModelAndValidate(joinLines(
+ "schema test {",
+ "document test {",
+ "struct item {",
+ "field name type string {}",
+ "field color type string {}",
+ "field type type string {}",
+ "}",
+ "struct itembox {",
+ "field items type array<item> {}",
+ "}",
+ "field cabinet type map<string, itembox> {",
+ "struct-field key { indexing: attribute }",
+ "struct-field value.items {",
+ "struct-field name { indexing: attribute }",
+ "struct-field color { indexing: attribute }",
+ "}",
+ "}",
+ "}",
+ "}"));
+ });
+ assertTrue(exception.getMessage().contains(getExpectedMessage("cabinet (cabinet.value.items.name, cabinet.value.items.color)")));
+ }
+
+
private String getExpectedMessage(String unsupportedFields) {
return "For cluster 'mycluster', search 'test': " +
"The following complex fields do not support using struct field attributes: " +