aboutsummaryrefslogtreecommitdiffstats
path: root/documentgen-test/src
diff options
context:
space:
mode:
Diffstat (limited to 'documentgen-test/src')
-rw-r--r--documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java2
-rw-r--r--documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java2
-rw-r--r--documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java26
3 files changed, 27 insertions, 3 deletions
diff --git a/documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java b/documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java
index 4782a3d6875..626d19d5ef2 100644
--- a/documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java
+++ b/documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.document;
import com.yahoo.document.annotation.Annotation;
diff --git a/documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java b/documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java
index 5bc4f9af884..f03134025ad 100644
--- a/documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java
+++ b/documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.document.dom;
import com.yahoo.document.annotation.Annotation;
diff --git a/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java b/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java
index bd2b057835c..cae11d66d13 100644
--- a/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java
+++ b/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java
@@ -1,4 +1,4 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config;
import com.yahoo.docproc.DocumentProcessor;
@@ -79,6 +79,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
/**
@@ -500,6 +501,29 @@ public class DocumentGenPluginTest {
assertEquals(book.getFieldValue("isbn"), new StringFieldValue("ISBN YEP"));
}
+ @Test
+ public void testSetterValidation() {
+ Book book = new Book(new DocumentId("id:book:book::0"));
+
+ book.setAuthor("Herman Melville");
+ assertEquals("The string field value contains illegal code point 0x16",
+ assertThrows(IllegalArgumentException.class,
+ () -> book.setAuthor("He\u0016rman Malville")).getMessage());
+
+ book.setRef(new DocumentId("id:ns:parent::foo"));
+ assertEquals("Can't assign document ID 'id:ns:common::bar' (of type 'common') to reference of document type 'parent'",
+ assertThrows(IllegalArgumentException.class,
+ () -> book.setRef(new DocumentId("id:ns:common::bar"))).getMessage());
+
+ book.setStringmap(Map.of("foo", "bar"));
+ assertEquals("The string field value contains illegal code point 0x16",
+ assertThrows(IllegalArgumentException.class,
+ () -> book.setStringmap(Map.of("foo", "bar\u0016"))).getMessage());
+ assertEquals("The string field value contains illegal code point 0x16",
+ assertThrows(IllegalArgumentException.class,
+ () -> book.setStringmap(Map.of("bar\u0016", "foo"))).getMessage());
+ }
+
public static class BookProcessor extends DocumentProcessor {
public Progress process(Processing processing) {