summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-02-24 07:45:11 +0000
committerArne H Juul <arnej@yahooinc.com>2022-02-24 07:45:39 +0000
commit471bbac68751bca98fa097f0f7c4a43c40b0c05f (patch)
treeaec8162bd713167c694adf9131e1efbcf06c0eda
parent25522c23874c34679729ea46ce2a3ad8e8612a45 (diff)
start writing unit test
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/parser/ParsedDocumentTestCase.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/parser/ParsedDocumentTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/parser/ParsedDocumentTestCase.java
new file mode 100644
index 00000000000..62a1f421278
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/parser/ParsedDocumentTestCase.java
@@ -0,0 +1,27 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.searchdefinition.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: already has field zap", e.getMessage());
+ }
+
+}