diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java |
Publish
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java')
-rw-r--r-- | config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java new file mode 100644 index 00000000000..ed29d086bb1 --- /dev/null +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java @@ -0,0 +1,50 @@ +// Copyright 2016 Yahoo Inc. 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.SearchBuilder; +import com.yahoo.searchdefinition.parser.ParseException; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * @author <a href="geirst@yahoo-inc.com">Geir Storli</a> + */ +public class TensorFieldTestCase { + + @Rule + public ExpectedException exception = ExpectedException.none(); + + @Test + public void requireThatTensorFieldCannotBeOfCollectionType() throws ParseException { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("For search 'test', field 'f1': A field with collection type of tensor is not supported. Use simple type 'tensor' instead."); + SearchBuilder.createFromString(getSd("field f1 type array<tensor> {}")); + } + + @Test + public void requireThatTensorFieldCannotBeIndexField() throws ParseException { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("For search 'test', field 'f1': A field of type 'tensor' cannot be specified as an 'index' field."); + SearchBuilder.createFromString(getSd("field f1 type tensor { indexing: index }")); + } + + @Test + public void requireThatTensorAttributeCannotBeFastSearch() throws ParseException { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("For search 'test', field 'f1': An attribute of type 'tensor' cannot be 'fast-search'."); + SearchBuilder.createFromString(getSd("field f1 type tensor { indexing: attribute \n attribute: fast-search }")); + } + + @Test + public void requireThatIllegalTensorTypeSpecThrowsException() throws ParseException { + exception.expect(IllegalArgumentException.class); + exception.expectMessage("For attribute field 'f1': Illegal tensor type spec: Failed parsing element 'invalid' in type spec 'tensor(invalid)'"); + SearchBuilder.createFromString(getSd("field f1 type tensor { indexing: attribute \n attribute: tensor(invalid) }")); + } + + private static String getSd(String field) { + return "search test {\n document test {\n" + field + "}\n}\n"; + } + +} |