diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-08-15 20:06:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-15 20:06:56 +0200 |
commit | c0a6a3537fceb291536bac6fbfaaf8f0de623ec7 (patch) | |
tree | 8188cb7c5a0522d95e0e1484ba875ce04d4e875a | |
parent | 3af0fc9aea8f0c7c13a81e1aa630e3939c9c90f9 (diff) | |
parent | 98592b7ca6eddc437e30b587cd40774fbb84b102 (diff) |
Merge pull request #10289 from vespa-engine/hmusum/cleanup-tests-2
Cleanup of tests, no changes
24 files changed, 164 insertions, 167 deletions
diff --git a/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java b/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java index ba27fb3f275..94602d5201a 100644 --- a/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/document/test/SDDocumentTypeTestCase.java @@ -16,84 +16,85 @@ import static org.junit.Assert.*; /** * @author Thomas Gundersen * @author bratseth -*/ + */ public class SDDocumentTypeTestCase extends SearchDefinitionTestCase { // Verify that we can register and retrieve fields. @Test public void testSetGet() { - SDDocumentType docType=new SDDocumentType("testdoc"); - docType.addField("Bongle",DataType.STRING); - docType.addField("nalle",DataType.INT); + SDDocumentType docType = new SDDocumentType("testdoc"); + docType.addField("Bongle", DataType.STRING); + docType.addField("nalle", DataType.INT); - assertNotNull(docType.getField("Bongle").getName(),"Bongle"); + assertNotNull(docType.getField("Bongle").getName()); assertNull(docType.getField("bongle")); } + @Test public void testInheritance() { - SDDocumentType child=new SDDocumentType("child"); - Iterator<SDDocumentType> inherited=child.getInheritedTypes().iterator(); + SDDocumentType child = new SDDocumentType("child"); + Iterator<SDDocumentType> inherited = child.getInheritedTypes().iterator(); assertTrue(inherited.hasNext()); assertEquals(inherited.next().getDocumentName(), VespaDocumentType.NAME); assertFalse(inherited.hasNext()); - child.addField("childfield",DataType.INT); - SDField overridden= child.addField("overridden", DataType.STRING); + child.addField("childfield", DataType.INT); + SDField overridden = child.addField("overridden", DataType.STRING); - SDDocumentType parent1=new SDDocumentType("parent1"); - SDField overridden2= parent1.addField("overridden", DataType.STRING); - parent1.addField("parent1field",DataType.STRING); + SDDocumentType parent1 = new SDDocumentType("parent1"); + SDField overridden2 = parent1.addField("overridden", DataType.STRING); + parent1.addField("parent1field", DataType.STRING); child.inherit(parent1); - SDDocumentType parent2=new SDDocumentType("parent2"); - parent2.addField("parent2field",DataType.STRING); + SDDocumentType parent2 = new SDDocumentType("parent2"); + parent2.addField("parent2field", DataType.STRING); child.inherit(parent2); - SDDocumentType root=new SDDocumentType("root"); - root.addField("rootfield",DataType.STRING); + SDDocumentType root = new SDDocumentType("root"); + root.addField("rootfield", DataType.STRING); parent1.inherit(root); parent2.inherit(root); - inherited=child.getInheritedTypes().iterator(); - assertEquals(VespaDocumentType.NAME,inherited.next().getDocumentName()); - assertEquals(new DataTypeName("parent1"),inherited.next().getDocumentName()); - assertEquals(new DataTypeName("parent2"),inherited.next().getDocumentName()); - assertTrue(!inherited.hasNext()); + inherited = child.getInheritedTypes().iterator(); + assertEquals(VespaDocumentType.NAME, inherited.next().getDocumentName()); + assertEquals(new DataTypeName("parent1"), inherited.next().getDocumentName()); + assertEquals(new DataTypeName("parent2"), inherited.next().getDocumentName()); + assertFalse(inherited.hasNext()); - inherited=parent1.getInheritedTypes().iterator(); - assertEquals(VespaDocumentType.NAME,inherited.next().getDocumentName()); - assertEquals(new DataTypeName("root"),inherited.next().getDocumentName()); - assertTrue(!inherited.hasNext()); + inherited = parent1.getInheritedTypes().iterator(); + assertEquals(VespaDocumentType.NAME, inherited.next().getDocumentName()); + assertEquals(new DataTypeName("root"), inherited.next().getDocumentName()); + assertFalse(inherited.hasNext()); - inherited=parent2.getInheritedTypes().iterator(); - assertEquals(VespaDocumentType.NAME,inherited.next().getDocumentName()); - assertEquals(new DataTypeName("root"),inherited.next().getDocumentName()); - assertTrue(!inherited.hasNext()); + inherited = parent2.getInheritedTypes().iterator(); + assertEquals(VespaDocumentType.NAME, inherited.next().getDocumentName()); + assertEquals(new DataTypeName("root"), inherited.next().getDocumentName()); + assertFalse(inherited.hasNext()); - inherited=root.getInheritedTypes().iterator(); + inherited = root.getInheritedTypes().iterator(); assertTrue(inherited.hasNext()); assertEquals(inherited.next().getDocumentName(), VespaDocumentType.NAME); assertFalse(inherited.hasNext()); - Iterator fields=child.fieldSet().iterator(); + Iterator fields = child.fieldSet().iterator(); SDField field; - field=(SDField)fields.next(); - assertEquals("rootfield",field.getName()); + field = (SDField) fields.next(); + assertEquals("rootfield", field.getName()); - field=(SDField)fields.next(); - assertEquals("overridden",field.getName()); + field = (SDField) fields.next(); + assertEquals("overridden", field.getName()); - field=(SDField)fields.next(); - assertEquals("parent1field",field.getName()); + field = (SDField) fields.next(); + assertEquals("parent1field", field.getName()); - field=(SDField)fields.next(); - assertEquals("parent2field",field.getName()); + field = (SDField) fields.next(); + assertEquals("parent2field", field.getName()); - field=(SDField)fields.next(); - assertEquals("childfield",field.getName()); + field = (SDField) fields.next(); + assertEquals("childfield", field.getName()); // TODO: Test uninheriting } diff --git a/config-model/src/test/java/com/yahoo/document/test/SDFieldTestCase.java b/config-model/src/test/java/com/yahoo/document/test/SDFieldTestCase.java index 1055842b5af..7dcbd92655b 100644 --- a/config-model/src/test/java/com/yahoo/document/test/SDFieldTestCase.java +++ b/config-model/src/test/java/com/yahoo/document/test/SDFieldTestCase.java @@ -4,35 +4,36 @@ package com.yahoo.document.test; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.SearchDefinitionTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; -import com.yahoo.searchdefinition.document.SDField; import org.junit.Test; import static org.junit.Assert.fail; /** - @author <a href="thomasg@yahoo-inc.com>Thomas Gundersen</a> -*/ + * @author Thomas Gundersen + */ public class SDFieldTestCase extends SearchDefinitionTestCase { + @Test public void testIdSettingConflict() { - SDDocumentType doc=new SDDocumentType("testdoc"); - SDField one=(SDField) doc.addField("one", DataType.STRING, false, 60); + SDDocumentType doc = new SDDocumentType("testdoc"); + doc.addField("one", DataType.STRING, false, 60); - SDField two=(SDField) doc.addField("two", DataType.STRING, false, 61); + doc.addField("two", DataType.STRING, false, 61); try { - SDField three=(SDField) doc.addField("three", DataType.STRING, false, 60); + doc.addField("three", DataType.STRING, false, 60); fail("Allowed to set duplicate id"); } catch (IllegalArgumentException e) { // Success } } + @Test public void testSettingReservedId() { - SDDocumentType doc=new SDDocumentType("testdoc"); + SDDocumentType doc = new SDDocumentType("testdoc"); try { - SDField one=(SDField) doc.addField("one", DataType.STRING, false, 127); + doc.addField("one", DataType.STRING, false, 127); fail("Allowed to set reserved id"); } catch (IllegalArgumentException e) { @@ -40,7 +41,7 @@ public class SDFieldTestCase extends SearchDefinitionTestCase { } try { - SDField one=(SDField) doc.addField("one", DataType.STRING, false, 100); + doc.addField("one", DataType.STRING, false, 100); fail("Allowed to set reserved id"); } catch (IllegalArgumentException e) { @@ -48,13 +49,13 @@ public class SDFieldTestCase extends SearchDefinitionTestCase { } try { - SDField one=(SDField) doc.addField("one", DataType.STRING, false, -1); + doc.addField("one", DataType.STRING, false, -1); fail("Allowed to set reserved id"); } catch (IllegalArgumentException e) { // Success } - SDField one= doc.addField("one", DataType.STRING); + doc.addField("one", DataType.STRING); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java index 08a9f9c1c08..cfd02c22b89 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java @@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue; /** * tests importing of document containing array type fields and weighted set type fields, new syntax. * - * @author <a href="einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class ArraysWeightedSetsTestCase extends SearchDefinitionTestCase { @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java index f45cd67522a..c5189069fca 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java @@ -12,8 +12,7 @@ import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; /** - * @author <a href="mailto:lesters@yahoo-inc.com">Lester Solbakken</a> - * @since 5.2 + * @author Lester Solbakken */ public class PredicateDataTypeTestCase { @@ -69,11 +68,11 @@ public class PredicateDataTypeTestCase { for (SDField field : sb.getSearch().allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { for (Index index : field.getIndices().values()) { - assertEquals(true, index.getBooleanIndexDefiniton().hasArity()); + assertTrue(index.getBooleanIndexDefiniton().hasArity()); assertEquals(arity, index.getBooleanIndexDefiniton().getArity()); - assertEquals(true, index.getBooleanIndexDefiniton().hasLowerBound()); + assertTrue(index.getBooleanIndexDefiniton().hasLowerBound()); assertEquals(lowerBound, index.getBooleanIndexDefiniton().getLowerBound()); - assertEquals(true, index.getBooleanIndexDefiniton().hasUpperBound()); + assertTrue(index.getBooleanIndexDefiniton().hasUpperBound()); assertEquals(upperBound, index.getBooleanIndexDefiniton().getUpperBound()); } } @@ -114,9 +113,9 @@ public class PredicateDataTypeTestCase { for (SDField field : sb.getSearch().allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { for (Index index : field.getIndices().values()) { - assertEquals(true, index.getBooleanIndexDefiniton().hasArity()); - assertEquals(false, index.getBooleanIndexDefiniton().hasLowerBound()); - assertEquals(false, index.getBooleanIndexDefiniton().hasUpperBound()); + assertTrue(index.getBooleanIndexDefiniton().hasArity()); + assertFalse(index.getBooleanIndexDefiniton().hasLowerBound()); + assertFalse(index.getBooleanIndexDefiniton().hasUpperBound()); } } } @@ -129,7 +128,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Missing arity value in predicate field."); SearchBuilder.createFromString(sd); - assertTrue(false); + fail(); } @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java index c0a90b6aaa1..58e62353e5c 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue; public class RankingExpressionInliningTestCase extends SearchDefinitionTestCase { @Test - public void testFunctionInliningPreserveArithemticOrdering() throws ParseException { + public void testFunctionInliningPreserveArithmeticOrdering() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); SearchBuilder builder = new SearchBuilder(rankProfileRegistry); builder.importString( diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SearchDefinitionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SearchDefinitionTestCase.java index a6c6939f830..ba6da8792fa 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SearchDefinitionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SearchDefinitionTestCase.java @@ -12,15 +12,11 @@ import static helpers.CompareConfigTestHelper.assertSerializedConfigFileEquals; public abstract class SearchDefinitionTestCase { - public static void assertConfigFile(String filename, String cfg) throws IOException { + protected static void assertConfigFile(String filename, String cfg) throws IOException { assertSerializedConfigFileEquals(filename, cfg); } - public static void assertConfigFiles(String expectedFile, String cfgFile) throws IOException { - assertConfigFiles(expectedFile, cfgFile, false); - } - - public static void assertConfigFiles(String expectedFile, String cfgFile, boolean updateOnAssert) throws IOException { + protected static void assertConfigFiles(String expectedFile, String cfgFile, boolean updateOnAssert) throws IOException { try { assertSerializedConfigEquals(readAndCensorIndexes(expectedFile), readAndCensorIndexes(cfgFile)); } catch (AssertionError e) { @@ -40,7 +36,7 @@ public abstract class SearchDefinitionTestCase { * This is to avoid having to keep those pesky array index numbers in the config format up to date * as new entries are added and removed. */ - public static String readAndCensorIndexes(String file) throws IOException { + private static String readAndCensorIndexes(String file) throws IOException { StringBuilder b = new StringBuilder(); try (BufferedReader r = IOUtils.createReader(file)) { int character; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SearchImporterTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SearchImporterTestCase.java index a94c8e76684..6a49f446ff6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SearchImporterTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SearchImporterTestCase.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.Iterator; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -56,7 +57,7 @@ public class SearchImporterTestCase extends SearchDefinitionTestCase { field=(SDField) document.getField("title"); assertEquals(DataType.STRING,field.getDataType()); assertEquals("{ input title | tokenize normalize stem:\"BEST\" | summary title | index title; }", field.getIndexingScript().toString()); - assertTrue(!search.getIndex("default").isPrefix()); + assertFalse(search.getIndex("default").isPrefix()); assertTrue(search.getIndex("title").isPrefix()); Iterator<String> titleAliases=search.getIndex("title").aliasIterator(); assertEquals("aliaz",titleAliases.next()); @@ -64,7 +65,7 @@ public class SearchImporterTestCase extends SearchDefinitionTestCase { assertEquals("analias.todefault", search.getIndex("default").aliasIterator().next()); assertEquals(RankType.IDENTITY, field.getRankType()); - assertTrue(field.getAttributes().size() == 0); + assertEquals(0, field.getAttributes().size()); assertNull(field.getStemming()); assertTrue(field.getNormalizing().doRemoveAccents()); assertTrue(field.isHeader()); @@ -90,7 +91,7 @@ public class SearchImporterTestCase extends SearchDefinitionTestCase { field=(SDField) document.getField("category"); assertEquals(0, field.getAttributes().size()); assertEquals(Stemming.NONE, field.getStemming()); - assertTrue(!field.getNormalizing().doRemoveAccents()); + assertFalse(field.getNormalizing().doRemoveAccents()); // Fifth field field=(SDField) document.getField("popularity"); @@ -142,8 +143,7 @@ public class SearchImporterTestCase extends SearchDefinitionTestCase { RankProfile profile=rankProfileRegistry.get(search, "default"); assertNotNull(profile); assertNull(profile.getInheritedName()); - assertEquals(null,profile.getDeclaredRankSetting("measurement", - RankProfile.RankSetting.Type.RANKTYPE)); + assertNull(profile.getDeclaredRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE)); assertEquals(RankType.EMPTY, profile.getRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE).getValue()); profile=rankProfileRegistry.get(search, "experimental"); @@ -161,7 +161,7 @@ public class SearchImporterTestCase extends SearchDefinitionTestCase { assertNotNull("Extra field was parsed",exact); assertEquals("exact",exact.getName()); assertEquals(Stemming.NONE,exact.getStemming()); - assertTrue(!exact.getNormalizing().doRemoveAccents()); + assertFalse(exact.getNormalizing().doRemoveAccents()); assertEquals("{ input title . \" \" . input category | tokenize | summary exact | index exact; }", exact.getIndexingScript().toString()); assertEquals(RankType.IDENTITY, exact.getRankType()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java index 78382ccdad6..d67df3a5239 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java @@ -11,7 +11,8 @@ import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; import com.yahoo.vespa.configmodel.producers.DocumentManager; import com.yahoo.vespa.configmodel.producers.DocumentTypes; -import java.io.*; +import java.io.File; +import java.io.IOException; /** * Superclass of tests needing file comparisons @@ -20,10 +21,10 @@ import java.io.*; */ public abstract class AbstractExportingTestCase extends SearchDefinitionTestCase { - static final String tempDir = "temp/"; - static final String searchDefRoot = "src/test/derived/"; + private static final String tempDir = "temp/"; + private static final String searchDefRoot = "src/test/derived/"; - protected DerivedConfiguration derive(String dirName, String searchDefinitionName) throws IOException, ParseException { + private DerivedConfiguration derive(String dirName, String searchDefinitionName) throws IOException, ParseException { File toDir = new File(tempDir + dirName); toDir.mkdirs(); deleteContent(toDir); @@ -40,7 +41,7 @@ public abstract class AbstractExportingTestCase extends SearchDefinitionTestCase return export(dirName, builder, config); } - protected DerivedConfiguration derive(String dirName, SearchBuilder builder, Search search) throws IOException { + DerivedConfiguration derive(String dirName, SearchBuilder builder, Search search) throws IOException { DerivedConfiguration config = new DerivedConfiguration(search, builder.getRankProfileRegistry(), builder.getQueryProfileRegistry(), @@ -103,7 +104,7 @@ public abstract class AbstractExportingTestCase extends SearchDefinitionTestCase * @param name the local name of the directory containing the files to check * @throws IOException If file access failed. */ - protected void assertCorrectConfigFiles(String name) throws IOException { + void assertCorrectConfigFiles(String name) throws IOException { File[] files = new File(searchDefRoot, name).listFiles(); if (files == null) return; for (File file : files) { @@ -112,12 +113,12 @@ public abstract class AbstractExportingTestCase extends SearchDefinitionTestCase } } - public static void assertEqualFiles(String correctFileName, String checkFileName) throws IOException { + static void assertEqualFiles(String correctFileName, String checkFileName) throws IOException { // Set updateOnAssert to true if you want update the files with correct answer. assertConfigFiles(correctFileName, checkFileName, false); } - protected void deleteContent(File dir) { + void deleteContent(File dir) { File[] files = dir.listFiles(); if (files == null) return; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AnnotationsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AnnotationsTestCase.java index 19cd1d9368a..0c9676a593e 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AnnotationsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AnnotationsTestCase.java @@ -7,7 +7,7 @@ import org.junit.Test; import java.io.IOException; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class AnnotationsTestCase extends AbstractExportingTestCase { @@ -58,8 +58,6 @@ public class AnnotationsTestCase extends AbstractExportingTestCase { /** * An annotation declared before document {} won't work, no doc type to add it to. - * @throws IOException - * @throws ParseException */ @Test(expected = IllegalArgumentException.class) public void testAnnotationOutsideOfDocumment() throws IOException, ParseException { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java index da28dd56694..79ec3027c20 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java @@ -13,7 +13,7 @@ import java.util.Iterator; import static com.yahoo.config.model.test.TestUtil.joinLines; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; /** * Tests attribute deriving @@ -66,7 +66,7 @@ public class AttributeListTestCase extends SearchDefinitionTestCase { assertEquals(Attribute.Type.INTEGER, attribute.getType()); assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType()); - assertTrue(!attributes.hasNext()); + assertFalse(attributes.hasNext()); } @Test @@ -76,7 +76,7 @@ public class AttributeListTestCase extends SearchDefinitionTestCase { assertAttribute("elem_array.name", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); assertAttribute("elem_array.weight", Attribute.Type.INTEGER, Attribute.CollectionType.ARRAY, false, attributes.next()); - assertTrue(!attributes.hasNext()); + assertFalse(attributes.hasNext()); } @Test @@ -89,7 +89,7 @@ public class AttributeListTestCase extends SearchDefinitionTestCase { assertAttribute("str_elem_map.value.weight", Attribute.Type.INTEGER, Attribute.CollectionType.ARRAY, false, attributes.next()); assertAttribute("int_elem_map.key", Attribute.Type.INTEGER, Attribute.CollectionType.ARRAY, false, attributes.next()); assertAttribute("int_elem_map.value.name", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); - assertTrue(!attributes.hasNext()); + assertFalse(attributes.hasNext()); } private static void assertAttribute(String name, Attribute.Type type, Attribute.CollectionType collection, boolean isFastSearch, Attribute attr) { @@ -112,7 +112,7 @@ public class AttributeListTestCase extends SearchDefinitionTestCase { Iterator<Attribute> attributes = new AttributeFields(search).attributeIterator(); assertAttribute("pos_array_zcurve", Attribute.Type.LONG, Attribute.CollectionType.ARRAY, true, attributes.next()); - assertTrue(!attributes.hasNext()); + assertFalse(attributes.hasNext()); } @Test @@ -123,7 +123,7 @@ public class AttributeListTestCase extends SearchDefinitionTestCase { assertAttribute("str_map.key", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); assertAttribute("str_map.value", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, false, attributes.next()); assertAttribute("int_map.key", Attribute.Type.INTEGER, Attribute.CollectionType.ARRAY, false, attributes.next()); - assertTrue(!attributes.hasNext()); + assertFalse(attributes.hasNext()); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/DeriverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/DeriverTestCase.java index cc27a0d6067..1209da6d64b 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/DeriverTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/DeriverTestCase.java @@ -7,7 +7,7 @@ import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.searchdefinition.SearchDefinitionTestCase; import org.junit.Test; -import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; @@ -21,10 +21,10 @@ public class DeriverTestCase extends SearchDefinitionTestCase { @Test public void testDeriveDocManager() { DocumentTypeManager dtm = new DocumentTypeManager(new DocumentmanagerConfig( - Deriver.getDocumentManagerConfig(new ArrayList<String>() - {{ add("src/test/derived/deriver/child.sd"); - add("src/test/derived/deriver/parent.sd"); - add("src/test/derived/deriver/grandparent.sd");}}))); + Deriver.getDocumentManagerConfig(List.of( + "src/test/derived/deriver/child.sd", + "src/test/derived/deriver/parent.sd", + "src/test/derived/deriver/grandparent.sd")))); assertEquals(dtm.getDocumentType("child").getField("a").getDataType(), DataType.STRING); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/IdTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/IdTestCase.java index f87a26c6f79..130450e483d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/IdTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/IdTestCase.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertNull; public class IdTestCase extends AbstractExportingTestCase { @Test - @SuppressWarnings({ "deprecation" }) public void testExplicitUpperCaseIdField() { Search search = new Search("test", null); SDDocumentType document = new SDDocumentType("test"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/IndexSchemaTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/IndexSchemaTestCase.java index ec96d1f82d8..bff9945e4ad 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/IndexSchemaTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/IndexSchemaTestCase.java @@ -17,7 +17,6 @@ import static org.junit.Assert.fail; /** * @author Simon Thoresen Hult */ -@SuppressWarnings({ "deprecation" }) public class IndexSchemaTestCase { @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java index 9b363bc5734..02233608eea 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java @@ -20,7 +20,8 @@ import java.util.List; import org.junit.rules.TemporaryFolder; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** * Tests inheritance diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/IntegerAttributeToStringIndexTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/IntegerAttributeToStringIndexTestCase.java index 67f0e5f0eab..07902430f00 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/IntegerAttributeToStringIndexTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/IntegerAttributeToStringIndexTestCase.java @@ -7,7 +7,7 @@ import org.junit.Test; import java.io.IOException; /** - * @author <a href="mailto:jon@zenior.no">Jon Bratseth</a> + * @author bratseth */ public class IntegerAttributeToStringIndexTestCase extends AbstractExportingTestCase { @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/NativeRankTypeDefinitionsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/NativeRankTypeDefinitionsTestCase.java index ed0b9598e4d..c8ba5168e1c 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/NativeRankTypeDefinitionsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/NativeRankTypeDefinitionsTestCase.java @@ -8,6 +8,7 @@ import org.junit.Test; import java.util.Iterator; import static org.junit.Assert.*; + /** * Testing stuff related to native rank type definitions * diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/RankPropertiesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/RankPropertiesTestCase.java index 4d3839d9082..63f94f50d12 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/RankPropertiesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/RankPropertiesTestCase.java @@ -7,7 +7,7 @@ import org.junit.Test; import java.io.IOException; /** - * @author <a href="mailto:jon@zenior.no">Jon Bratseth</a> + * @author bratseth */ public class RankPropertiesTestCase extends AbstractExportingTestCase { @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/StreamingStructTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/StreamingStructTestCase.java index 592fd6c45ed..a689b3121b5 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/StreamingStructTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/StreamingStructTestCase.java @@ -7,7 +7,7 @@ import org.junit.Test; import java.io.IOException; /** - * Tests VSM configuration deriving for structs + * Tests streaming search configuration deriving for structs * * @author bratseth */ diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructAnyOrderTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructAnyOrderTestCase.java index 12cdb934286..2dffedac0e7 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructAnyOrderTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/StructAnyOrderTestCase.java @@ -7,7 +7,7 @@ import org.junit.Test; import java.io.IOException; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class StructAnyOrderTestCase extends AbstractExportingTestCase { @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java index 81422cfc89c..b82620b1cf5 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java @@ -18,73 +18,73 @@ import static org.junit.Assert.assertNull; /** * Tests summary extraction * - * @author bratseth + * @author bratseth */ public class SummaryTestCase extends SearchDefinitionTestCase { @Test public void testDeriving() throws IOException, ParseException { Search search = SearchBuilder.buildFromFile("src/test/examples/simple.sd"); - SummaryClass summary=new SummaryClass(search,search.getSummary("default"), new BaseDeployLogger()); - assertEquals("default",summary.getName()); + SummaryClass summary = new SummaryClass(search, search.getSummary("default"), new BaseDeployLogger()); + assertEquals("default", summary.getName()); - Iterator<SummaryClassField> fields=summary.fieldIterator(); + Iterator<SummaryClassField> fields = summary.fieldIterator(); SummaryClassField field; assertEquals(13, summary.getFieldCount()); - field=(SummaryClassField)fields.next(); - assertEquals("exactemento",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("exactemento", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("exact",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("exact", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("title",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("title", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("description",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("description", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("dyndesc",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("dyndesc", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("longdesc",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("longdesc", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("longstat",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("longstat", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("dynlong",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("dynlong", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("dyndesc2",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("dyndesc2", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("measurement",field.getName()); - assertEquals(SummaryClassField.Type.INTEGER,field.getType()); + field = fields.next(); + assertEquals("measurement", field.getName()); + assertEquals(SummaryClassField.Type.INTEGER, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("rankfeatures",field.getName()); + field = fields.next(); + assertEquals("rankfeatures", field.getName()); assertEquals(SummaryClassField.Type.FEATUREDATA, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("summaryfeatures",field.getName()); + field = fields.next(); + assertEquals("summaryfeatures", field.getName()); assertEquals(SummaryClassField.Type.FEATUREDATA, field.getType()); - field=(SummaryClassField)fields.next(); - assertEquals("documentid",field.getName()); - assertEquals(SummaryClassField.Type.LONGSTRING,field.getType()); + field = fields.next(); + assertEquals("documentid", field.getName()); + assertEquals(SummaryClassField.Type.LONGSTRING, field.getType()); } @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java index 3f45b28b994..a9f04aa980f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java @@ -13,11 +13,11 @@ import static org.junit.Assert.assertTrue; public class ComplexAttributeFieldUtilsTestCase { private static class FixtureBase { - private final Search search; + private final ImmutableSDField field; - public FixtureBase(String fieldName, String sdContent) throws ParseException { - search = SearchBuilder.createFromString(sdContent).getSearch(); + FixtureBase(String fieldName, String sdContent) throws ParseException { + Search search = SearchBuilder.createFromString(sdContent).getSearch(); field = search.getConcreteField(fieldName); } @@ -25,30 +25,30 @@ public class ComplexAttributeFieldUtilsTestCase { return field; } - public boolean isSupportedComplexField() { + boolean isSupportedComplexField() { return ComplexAttributeFieldUtils.isSupportedComplexField(field()); } - public boolean isArrayOfSimpleStruct() { + boolean isArrayOfSimpleStruct() { return ComplexAttributeFieldUtils.isArrayOfSimpleStruct(field()); } - public boolean isMapOfSimpleStruct() { + boolean isMapOfSimpleStruct() { return ComplexAttributeFieldUtils.isMapOfSimpleStruct(field()); } - public boolean isMapOfPrimitiveType() { + boolean isMapOfPrimitiveType() { return ComplexAttributeFieldUtils.isMapOfPrimitiveType(field()); } - public boolean isComplexFieldWithOnlyStructFieldAttributes() { + boolean isComplexFieldWithOnlyStructFieldAttributes() { return ComplexAttributeFieldUtils.isComplexFieldWithOnlyStructFieldAttributes(field()); } } private static class Fixture extends FixtureBase { - public Fixture(String fieldName, String sdFieldContent) throws ParseException { + Fixture(String fieldName, String sdFieldContent) throws ParseException { super(fieldName, joinLines("search test {", " document test {", " struct elem {", @@ -63,7 +63,7 @@ public class ComplexAttributeFieldUtilsTestCase { private static class ComplexFixture extends FixtureBase { - public ComplexFixture(String fieldName, String sdFieldContent) throws ParseException { + ComplexFixture(String fieldName, String sdFieldContent) throws ParseException { super(fieldName, joinLines("search test {", " document test {", " struct elem {", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java index e230840bcaa..49fa63313ca 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java @@ -164,15 +164,15 @@ public class AdjustPositionSummaryFieldsTestCase { static class SearchModel extends ParentChildSearchModel { - public SearchModel() { + SearchModel() { this(true); } - public SearchModel(boolean importedPos) { + SearchModel(boolean importedPos) { this(importedPos, true, false); } - public SearchModel(boolean importedPos, boolean setupPosAttr, boolean setupBadAttr) { + SearchModel(boolean importedPos, boolean setupPosAttr, boolean setupBadAttr) { super(); if (importedPos) { createPositionField(parentSearch, setupPosAttr, setupBadAttr); @@ -193,7 +193,7 @@ public class AdjustPositionSummaryFieldsTestCase { } } - public void addSummaryField(String fieldName, DataType dataType, SummaryTransform transform, String source) { + void addSummaryField(String fieldName, DataType dataType, SummaryTransform transform, String source) { addSummaryField("my_summary", fieldName, dataType, transform, source); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java index a8ba762b32b..cac50354dc2 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java @@ -14,6 +14,7 @@ import org.junit.Test; import java.io.IOException; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -43,18 +44,18 @@ public class IntegerIndex2AttributeTestCase extends SearchDefinitionTestCase { f = search.getConcreteField("i1"); assertEquals(f.getAttributes().size(), 1); - assertTrue( ! f.existsIndex("i1")); + assertFalse(f.existsIndex("i1")); f = search.getConcreteField("i2"); assertEquals(f.getAttributes().size(), 1); - assertTrue( ! f.existsIndex("i2")); + assertFalse(f.existsIndex("i2")); f = search.getConcreteField("ai1"); assertEquals(search.getConcreteField("ai1").getAttributes().size(), 1); - assertTrue( ! search.getConcreteField("ai1").existsIndex("ai1")); + assertFalse(search.getConcreteField("ai1").existsIndex("ai1")); f = search.getConcreteField("ai2"); assertEquals(f.getAttributes().size(), 1); - assertTrue( ! f.existsIndex("ai2")); + assertFalse(f.existsIndex("ai2")); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java index e5fadea6dd8..8e221a6210b 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java @@ -102,8 +102,8 @@ public class PositionTestCase { Attribute attribute = search.getAttribute(PositionDataType.getZCurveFieldName(fieldName)); assertNotNull(attribute); assertTrue(attribute.isPosition()); - assertTrue(attribute.getCollectionType().equals(type)); - assertTrue(attribute.getType().equals(Attribute.Type.LONG)); + assertEquals(attribute.getCollectionType(), type); + assertEquals(attribute.getType(), Attribute.Type.LONG); } private static void assertPositionSummary(Search search, String fieldName, boolean isArray) { |