blob: a7f4125a5371f1db120c1751813ea3a95c7a2dc8 (
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
66
67
68
69
70
71
72
73
|
// 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.parser.ParseException;
import org.junit.jupiter.api.Test;
import static com.yahoo.schema.ApplicationBuilder.createFromString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static com.yahoo.config.model.test.TestUtil.joinLines;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author geirst
*/
public class SingleValueOnlyAttributeValidatorTestCase {
private static void array_attribute_is_not_supported(String type) throws ParseException {
try {
createFromString(getSd("field b type array<" + type + "> { indexing: attribute }"));
fail("Expected exception");
}
catch (IllegalArgumentException e) {
assertEquals("For schema 'test', field 'b': Only single value " + type + " attribute fields are supported",
e.getMessage());
}
}
private static void weightedset_attribute_is_not_supported(String type) throws ParseException {
try {
createFromString(getSd("field b type weightedset<" + type + "> { indexing: attribute }"));
fail("Expected exception");
}
catch (IllegalArgumentException e) {
if (type.equals("raw")) {
assertEquals("weightedset of complex type '[type BUILTIN] {raw}' is not supported",
e.getMessage());
} else {
assertEquals("For schema 'test', field 'b': Only single value " + type + " attribute fields are supported",
e.getMessage());
}
}
}
@Test
void array_of_bool_attribute_is_not_supported() throws ParseException {
array_attribute_is_not_supported("bool");
}
@Test
void weightedset_of_bool_attribute_is_not_supported() throws ParseException {
weightedset_attribute_is_not_supported("bool");
}
@Test
void array_of_raw_attribute_is_not_supported() throws ParseException {
array_attribute_is_not_supported("raw");
}
@Test
void weightedset_of_raw_attribute_is_not_supported() throws ParseException {
weightedset_attribute_is_not_supported("raw");
}
private static String getSd(String field) {
return joinLines(
"schema test {",
" document test {",
" " + field,
" }",
"}");
}
}
|