summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@yahoo-inc.com>2017-04-04 14:08:30 +0200
committerBjørn Christian Seime <bjorncs@yahoo-inc.com>2017-04-04 14:15:15 +0200
commit3b06e35228ec7960b541af594ab1a2fa2cf982ab (patch)
treec1e3521c63b05d551aa1b1199ed2bc74559a65e6 /config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
parentf0cecac64ed5d99bfce888c658166ccd48f252e1 (diff)
Forbid fast-access for predicate, tensor and reference attributes
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
new file mode 100644
index 00000000000..2e2633a6c84
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
@@ -0,0 +1,46 @@
+package com.yahoo.searchdefinition.processing;
+
+import com.yahoo.searchdefinition.RankProfileRegistry;
+import com.yahoo.searchdefinition.SearchBuilder;
+import com.yahoo.searchdefinition.parser.ParseException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * @author bjorncs
+ */
+public class FastAccessValidatorTest {
+
+ @Rule
+ public final ExpectedException exceptionRule = ExpectedException.none();
+
+ @Test
+ public void throws_exception_on_incompatible_use_of_fastaccess() throws ParseException {
+ SearchBuilder builder = new SearchBuilder(new RankProfileRegistry());
+ builder.importString(
+ "search test {\n" +
+ " document test { \n" +
+ " field int_attribute type int { \n" +
+ " indexing: attribute \n" +
+ " attribute: fast-access\n" +
+ " }\n" +
+ " field predicate_attribute type predicate {\n" +
+ " indexing: attribute \n" +
+ " attribute: fast-access\n" +
+ " }\n" +
+ " field tensor_attribute type tensor(x[]) {\n" +
+ " indexing: attribute \n" +
+ " attribute: fast-access\n" +
+ " }\n" +
+ " }\n" +
+ "}\n");
+ exceptionRule.expect(IllegalArgumentException.class);
+ exceptionRule.expectMessage(
+ "For search 'test': The following attributes have a type that is incompatible " +
+ "with fast-access: predicate_attribute, tensor_attribute. " +
+ "Predicate, tensor and reference attributes are incompatible with fast-access.");
+ builder.build();
+ }
+
+}