summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-06-11 09:14:24 +0200
committerJon Bratseth <bratseth@verizonmedia.com>2019-06-11 09:14:24 +0200
commit2014e93de206861200950343c5330ed5997d8770 (patch)
treed3c05754412c7449da7f0ffcb7763526e7573925 /config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java
parentc93826132f9256ce5597659a521494e6a3370a6c (diff)
Don't check error messages from another module
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.java54
1 files changed, 37 insertions, 17 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
index f53ca15635f..b6569357495 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java
@@ -3,48 +3,68 @@ 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* @author geirst
*/
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(x{})> {}"));
+ try {
+ SearchBuilder.createFromString(getSd("field f1 type array<tensor(x{})> {}"));
+ fail("Expected exception");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("For search 'test', field 'f1': A field with collection type of tensor is not supported. Use simple type 'tensor' instead.",
+ e.getMessage());
+ }
}
@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(x{}) { indexing: index }"));
+ try {
+ SearchBuilder.createFromString(getSd("field f1 type tensor(x{}) { indexing: index }"));
+ fail("Expected exception");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("For search 'test', field 'f1': A field of type 'tensor' cannot be specified as an 'index' field.",
+ e.getMessage());
+ }
}
@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(x{}) { indexing: attribute \n attribute: fast-search }"));
+ try {
+ SearchBuilder.createFromString(getSd("field f1 type tensor(x{}) { indexing: attribute \n attribute: fast-search }"));
+ fail("Expected exception");
+ }
+ catch (IllegalArgumentException e) {
+ assertEquals("For search 'test', field 'f1': An attribute of type 'tensor' cannot be 'fast-search'.", e.getMessage());
+ }
}
@Test
public void requireThatIllegalTensorTypeSpecThrowsException() throws ParseException {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Field type: Illegal tensor type spec: A tensor type spec must be on the form tensor[<valuetype>]?(dimensionidentifier[{}|[length?]*), but was 'tensor(invalid)'. Dimension 'invalid' is on the wrong format. Examples: tensor(x[]), tensor<float>(name{}, x[10])");
- SearchBuilder.createFromString(getSd("field f1 type tensor(invalid) { indexing: attribute }"));
+ try {
+ SearchBuilder.createFromString(getSd("field f1 type tensor(invalid) { indexing: attribute }"));
+ fail("Expected exception");
+ }
+ catch (IllegalArgumentException e) {
+ assertStartsWith("Field type: Illegal tensor type spec:", e.getMessage());
+ }
}
private static String getSd(String field) {
return "search test {\n document test {\n" + field + "}\n}\n";
}
+ private void assertStartsWith(String prefix, String string) {
+ assertEquals(prefix, string.substring(0, Math.min(prefix.length(), string.length())));
+ }
+
}