blob: 79d26fab40450708138b3a726e85341c5290dbdf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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' error: already has field zap", e.getMessage());
}
}
|