blob: c37bc8085c71c56b1864e644265b8c947a37c2f4 (
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
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.processing;
import com.yahoo.schema.ApplicationBuilder;
import com.yahoo.schema.AbstractSchemaTestCase;
import com.yahoo.schema.parser.ParseException;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author bratseth
*/
public class BoldingTestCase extends AbstractSchemaTestCase {
private final String boldonnonstring =
"search boldnonstring {\n" +
" document boldnonstring {\n" +
" field title type string {\n" +
" indexing: summary | index\n" +
" }\n" +
"\n" +
" field year4 type int {\n" +
" indexing: summary | attribute\n" +
" bolding: on\n" +
" }\n" +
" }\n" +
"}\n";
@Test
public void testBoldOnNonString() throws ParseException {
try {
ApplicationBuilder.createFromString(boldonnonstring);
fail("Expected exception");
} catch (IllegalArgumentException e) {
assertEquals("'bolding: on' for non-text field 'year4' (datatype int (code: 0)) is not allowed",
e.getMessage());
}
}
private final String boldonarray =
"search boldonarray {\n" +
" document boldonarray {\n" +
" field myarray type array<string> {\n" +
" indexing: summary | index\n" +
" bolding: on\n" +
" }\n" +
" }\n" +
"}\n";
@Test
public void testBoldOnArray() throws ParseException {
try {
ApplicationBuilder.createFromString(boldonarray);
fail("Expected exception");
} catch (IllegalArgumentException e) {
assertEquals("'bolding: on' for non-text field 'myarray' (datatype Array<string> (code: -1486737430)) is not allowed",
e.getMessage());
}
}
}
|