blob: 5fce16f381af9059109ec30285db1e72a38ef1c2 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
import static com.yahoo.config.model.test.TestUtil.joinLines;
import static com.yahoo.searchdefinition.SchemaBuilder.createFromString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class PagedAttributeValidatorTestCase {
@Test
public void dense_tensor_attribute_does_support_paged_setting() throws ParseException {
createFromString(getSd("tensor(x[2],y[2])"));
}
@Test
public void non_dense_tensor_attribute_does_not_support_paged_setting() throws ParseException {
assertPagedSettingNotSupported("tensor(x{},y[2])");
}
@Test
public void non_tensor_attribute_does_not_support_paged_setting() throws ParseException {
assertPagedSettingNotSupported("string");
}
private void assertPagedSettingNotSupported(String fieldType) throws ParseException {
try {
createFromString(getSd(fieldType));
fail("Expected exception");
} catch (IllegalArgumentException e) {
assertEquals("For schema 'test', field 'foo': The 'paged' attribute setting is only supported for dense tensor types",
e.getMessage());
}
}
private String getSd(String type) {
return joinLines(
"schema test {",
" document test {",
" field foo type " + type + "{",
" indexing: attribute",
" attribute: paged",
" }",
" }",
"}");
}
}
|