blob: 9942b5632973070b78b9c1c5efdc8942bb904da8 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
import com.yahoo.document.*;
import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.searchdefinition.derived.Deriver;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
/**
* @author Einar M R Rosenvinge
*/
public class FieldOfTypeDocumentTestCase extends SearchDefinitionTestCase {
@Test
public void testDocument() throws IOException, ParseException {
List<String> sds = new ArrayList<>();
sds.add("src/test/examples/music.sd");
sds.add("src/test/examples/fieldoftypedocument.sd");
DocumentmanagerConfig.Builder value = Deriver.getDocumentManagerConfig(sds);
assertConfigFile("src/test/examples/fieldoftypedocument.cfg",
new DocumentmanagerConfig(value).toString() + "\n");
DocumentTypeManager manager = new DocumentTypeManager();
DocumentTypeManagerConfigurer.configure(manager, "raw:" + new DocumentmanagerConfig(value).toString());
DocumentType musicType = manager.getDocumentType("music");
assertEquals(3, musicType.getFieldCount());
Field intField = musicType.getField("intfield");
assertEquals(DataType.INT, intField.getDataType());
Field stringField = musicType.getField("stringfield");
assertEquals(DataType.STRING, stringField.getDataType());
Field longField = musicType.getField("longfield");
assertEquals(DataType.LONG, longField.getDataType());
DocumentType bookType = manager.getDocumentType("book");
assertEquals(1, bookType.getFieldCount());
Field musicField = bookType.getField("soundtrack");
assertSame(musicType, musicField.getDataType());
}
}
|