summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/schema/parser/ParsedDocumentTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/schema/parser/ParsedDocumentTestCase.java')
-rw-r--r--config-model/src/test/java/com/yahoo/schema/parser/ParsedDocumentTestCase.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/schema/parser/ParsedDocumentTestCase.java b/config-model/src/test/java/com/yahoo/schema/parser/ParsedDocumentTestCase.java
new file mode 100644
index 00000000000..9245b64b09e
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/schema/parser/ParsedDocumentTestCase.java
@@ -0,0 +1,30 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.schema.parser;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+
+/**
+ * @author arnej
+ */
+public class ParsedDocumentTestCase {
+
+ @Test
+ public void fields_can_be_added_once() throws Exception {
+ var doc = new ParsedDocument("foo");
+ var stringType = ParsedType.fromName("string");
+ doc.addField(new ParsedField("bar1", stringType));
+ doc.addField(new ParsedField("zap", stringType));
+ doc.addField(new ParsedField("bar2", stringType));
+ doc.addField(new ParsedField("bar3", stringType));
+ var e = assertThrows(IllegalArgumentException.class, () ->
+ doc.addField(new ParsedField("zap", stringType)));
+ System.err.println("As expected: "+e);
+ assertEquals("document 'foo' error: Duplicate (case insensitively) field 'zap' in document type 'foo'", e.getMessage());
+ e = assertThrows(IllegalArgumentException.class, () ->
+ doc.addField(new ParsedField("ZAP", stringType)));
+ assertEquals("document 'foo' error: Duplicate (case insensitively) field 'ZAP' in document type 'foo'", e.getMessage());
+ }
+
+}