diff options
author | Jon Bratseth <jonbratseth@yahoo.com> | 2017-01-12 21:49:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-12 21:49:40 +0100 |
commit | b72c29c29a2c8dd8ecac8aeffdaff688b21ee41c (patch) | |
tree | fd8ea0f55ec4a17feff93139238a435ddf7715ac /config-model/src/test/java | |
parent | 08fbcebedf2c2bd78c13727fb91cc25b9b196c2f (diff) | |
parent | c10677061733478b8e4028fafc68f05972877643 (diff) |
Merge pull request #1502 from yahoo/revert-1495-bratseth/tensor-type-info-in-documents
Revert "Bratseth/tensor type info in documents"
Diffstat (limited to 'config-model/src/test/java')
7 files changed, 29 insertions, 46 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/FieldOfTypeDocumentTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/FieldOfTypeDocumentTestCase.java index 83d5c422fdf..4a3119e55b7 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/FieldOfTypeDocumentTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/FieldOfTypeDocumentTestCase.java @@ -14,10 +14,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; /** - * @author Einar M R Rosenvinge + * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> */ public class FieldOfTypeDocumentTestCase extends SearchDefinitionTestCase { - @Test public void testDocument() throws IOException, ParseException { @@ -26,7 +25,7 @@ public class FieldOfTypeDocumentTestCase extends SearchDefinitionTestCase { sds.add("src/test/examples/fieldoftypedocument.sd"); DocumentmanagerConfig.Builder value = Deriver.getDocumentManagerConfig(sds); assertConfigFile("src/test/examples/fieldoftypedocument.cfg", - new DocumentmanagerConfig(value).toString() + "\n"); + new DocumentmanagerConfig(value).toString() + "\n"); DocumentTypeManager manager = new DocumentTypeManager(); DocumentTypeManagerConfigurer.configure(manager, "raw:" + new DocumentmanagerConfig(value).toString()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java index 5542c1ce5e9..f8fe979c866 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java @@ -6,16 +6,14 @@ import org.junit.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - /** * Tests that "name" is not allowed as name for a field. * * And that duplicate names are not allowed. * - * @author Lars Christian Jensen + * @author <a href="mailto:larschr@yahoo-inc.com">Lars Christian Jensen</a> */ public class NameFieldCheckTestCase extends SearchDefinitionTestCase { @@ -24,8 +22,8 @@ public class NameFieldCheckTestCase extends SearchDefinitionTestCase { try { SearchBuilder.buildFromFile("src/test/examples/name-check.sd"); fail("Should throw exception."); - } catch (Exception expected) { - // Success + } catch (Exception e) { + e.printStackTrace(); } } @@ -35,7 +33,8 @@ public class NameFieldCheckTestCase extends SearchDefinitionTestCase { SearchBuilder.buildFromFile("src/test/examples/duplicatenamesinsearchdifferenttype.sd"); fail("Should throw exception."); } catch (Exception e) { - assertEquals("For search 'duplicatenamesinsearch', field 'grpphotoids64': Incompatible types. Expected Array<long> for index field 'grpphotoids64', got string.", e.getMessage()); + e.printStackTrace(); + assertTrue(e.getMessage().matches(".*Duplicate.*different type.*")); } } @@ -45,6 +44,7 @@ public class NameFieldCheckTestCase extends SearchDefinitionTestCase { SearchBuilder.buildFromFile("src/test/examples/duplicatenamesindoc.sd"); fail("Should throw exception."); } catch (Exception e) { + e.printStackTrace(); assertTrue(e.getMessage().matches(".*Duplicate.*")); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java index b2968eb4a85..ae3b775f13d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java @@ -102,9 +102,9 @@ public class RankProfileTestCase extends SearchDefinitionTestCase { SearchBuilder builder = new SearchBuilder(registry); builder.importString("search test {\n" + " document test { \n" + - " field a type tensor(x[]) { indexing: attribute \n attribute: tensor(x[10]) }\n" + - " field b type tensor(y{}) { indexing: attribute \n attribute: tensor(y{}) }\n" + - " field c type tensor(x[]) { indexing: attribute }\n" + + " field a type tensor { indexing: attribute \n attribute: tensor(x[10]) }\n" + + " field b type tensor { indexing: attribute \n attribute: tensor(y{}) }\n" + + " field c type tensor { indexing: attribute }\n" + " }\n" + " rank-profile p1 {}\n" + " rank-profile p2 {}\n" + @@ -123,7 +123,7 @@ public class RankProfileTestCase extends SearchDefinitionTestCase { RawRankProfile rawProfile = new RawRankProfile(profile, new AttributeFields(search)); assertEquals("tensor(x[10])", findProperty(rawProfile.configProperties(), "vespa.type.attribute.a").get()); assertEquals("tensor(y{})", findProperty(rawProfile.configProperties(), "vespa.type.attribute.b").get()); - assertEquals("tensor(x[])", findProperty(rawProfile.configProperties(), "vespa.type.attribute.c").get()); + assertFalse(findProperty(rawProfile.configProperties(), "vespa.type.attribute.c").isPresent()); } @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java index 3236be983d8..c33ebc95bd2 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java @@ -10,28 +10,26 @@ import java.io.IOException; import static org.junit.Assert.fail; /** - * Tests importing of document containing array type fields + * tests importing of document containing array type fields * * @author bratseth */ public class StructTestCase extends SearchDefinitionTestCase { - @Test public void testStruct() throws IOException, ParseException { assertConfigFile("src/test/examples/structresult.cfg", - new DocumentmanagerConfig(Deriver.getDocumentManagerConfig("src/test/examples/struct.sd")).toString() + "\n"); + new DocumentmanagerConfig(Deriver.getDocumentManagerConfig("src/test/examples/struct.sd")).toString() + "\n"); } - @Test public void testBadStruct() throws IOException { try { SearchBuilder.buildFromFile("src/test/examples/badstruct.sd"); fail("Should throw exception."); - } catch (ParseException expected) { - // success + } catch (ParseException e) { + //ok! + //e.printStackTrace(); } } - @Test public void testStructAndDocumentWithSameNames() throws IOException, ParseException { try { @@ -43,6 +41,8 @@ public class StructTestCase extends SearchDefinitionTestCase { /** * Declaring a struct before a document will fail, no doc type to add it to. + * @throws IOException + * @throws ParseException */ @Test(expected = IllegalArgumentException.class) public void testStructOutsideDocumentIllegal() throws IOException, ParseException { 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 0007019e6b4..ecadf8e1b71 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 @@ -19,28 +19,28 @@ public class TensorFieldTestCase { 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{})> {}")); + 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(x{}) { indexing: index }")); + 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(x{}) { indexing: attribute \n attribute: 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(x{}) { indexing: attribute \n attribute: tensor(invalid) }")); + SearchBuilder.createFromString(getSd("field f1 type tensor { indexing: attribute \n attribute: tensor(invalid) }")); } private static String getSd(String field) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidatorTestCase.java index a8b4065ef38..8c1a288c46d 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidatorTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidatorTestCase.java @@ -8,7 +8,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; /** - * @author Simon Thoresen + * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> */ public class SearchDataTypeValidatorTestCase { @@ -37,5 +37,4 @@ public class SearchDataTypeValidatorTestCase { "'simple' for cluster 'content').", e.getMessage()); } } - } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java index e43827d7693..b3ef8c6d7f2 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java @@ -9,7 +9,6 @@ import java.util.List; import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.newRefeedAction; import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.newRestartAction; -import static org.junit.Assert.assertEquals; public class AttributeChangeValidatorTest { @@ -111,8 +110,8 @@ public class AttributeChangeValidatorTest { @Test public void requireThatChangingTensorTypeOfTensorFieldRequiresRefeed() throws Exception { new Fixture( - "field f1 type tensor(x[]) { indexing: attribute \n attribute: tensor(x[100]) }", - "field f1 type tensor(y[]) { indexing: attribute \n attribute: tensor(y[]) }") + "field f1 type tensor { indexing: attribute \n attribute: tensor(x[100]) }", + "field f1 type tensor { indexing: attribute \n attribute: tensor(y[]) }") .assertValidation(newRefeedAction( "tensor-type-change", ValidationOverrides.empty(), @@ -120,24 +119,10 @@ public class AttributeChangeValidatorTest { } @Test - public void requireThatCompatibleTensorTypeChangeIsOk() throws Exception { + public void requireThatNotChangingTensorTypeOfTensorFieldIsOk() throws Exception { new Fixture( - "field f1 type tensor(x[],y[]) { indexing: attribute \n attribute: tensor(x[104], y[52]) }", - "field f1 type tensor(x[200],y[]) { indexing: attribute \n attribute: tensor(x[104], y[52]) }") + "field f1 type tensor { indexing: attribute \n attribute: tensor(x[104], y[52]) }", + "field f1 type tensor { indexing: attribute \n attribute: tensor(x[104], y[52]) }") .assertValidation(); } - - @Test - public void requireIncompatibleTensorTypeChangeIsNotOk() throws Exception { - try { - new Fixture( - "field f1 type tensor(x[],y[]) { indexing: attribute \n attribute: tensor(x[104], y[52]) }", - "field f1 type tensor(x[100],y[]) { indexing: attribute \n attribute: tensor(x[104], y[52]) }") - .assertValidation(); - } - catch (IllegalArgumentException e) { - assertEquals("For search 'test', field 'f1': Incompatible types. Expected tensor(x[100],y[]) for attribute 'f1', got tensor(x[104],y[52]).", e.getMessage()); - } - } - } |