diff options
Diffstat (limited to 'config-model/src/test')
61 files changed, 260 insertions, 233 deletions
diff --git a/config-model/src/test/cfg/application/embed/services.xml b/config-model/src/test/cfg/application/embed/services.xml index e92679e3c96..089adbd7517 100644 --- a/config-model/src/test/cfg/application/embed/services.xml +++ b/config-model/src/test/cfg/application/embed/services.xml @@ -40,7 +40,7 @@ <component id="bert-embedder" type="bert-embedder"> <!-- model specifics --> - <transformer-model model-id="minilm-l6-v2" url="application-url"/> + <transformer-model model-id="minilm-l6-v2" url="https://my/url/model.onnx"/> <tokenizer-vocab path="files/vocab.txt"/> <max-tokens>512</max-tokens> <transformer-input-ids>my_input_ids</transformer-input-ids> diff --git a/config-model/src/test/java/com/yahoo/config/model/MapConfigModelRegistryTest.java b/config-model/src/test/java/com/yahoo/config/model/MapConfigModelRegistryTest.java index cb232c4f812..900799b86a1 100644 --- a/config-model/src/test/java/com/yahoo/config/model/MapConfigModelRegistryTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/MapConfigModelRegistryTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.Test; import org.w3c.dom.Element; import java.util.Collection; -import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -47,7 +46,7 @@ public class MapConfigModelRegistryTest { } @Override - public List<ConfigModelId> handlesElements() { return Collections.singletonList(ConfigModelId.fromName("modelB")); } + public List<ConfigModelId> handlesElements() { return List.of(ConfigModelId.fromName("modelB")); } @Override public void doBuild(ModelB model, Element spec, ConfigModelContext modelContext) { } } @@ -57,7 +56,7 @@ public class MapConfigModelRegistryTest { super(ModelB.class); } @Override - public List<ConfigModelId> handlesElements() { return Collections.singletonList(ConfigModelId.fromName("modelB")); } + public List<ConfigModelId> handlesElements() { return List.of(ConfigModelId.fromName("modelB")); } @Override public void doBuild(ModelB model, Element spec, ConfigModelContext modelContext) { } } @@ -73,7 +72,7 @@ public class MapConfigModelRegistryTest { super(ModelA.class); } @Override - public List<ConfigModelId> handlesElements() { return Collections.singletonList(ConfigModelId.fromName("modelA")); } + public List<ConfigModelId> handlesElements() { return List.of(ConfigModelId.fromName("modelA")); } @Override public void doBuild(ModelA model, Element spec, ConfigModelContext modelContext) { } diff --git a/config-model/src/test/java/com/yahoo/config/model/graph/GraphMock.java b/config-model/src/test/java/com/yahoo/config/model/graph/GraphMock.java index 327d48f9276..4c6a5d0e74b 100644 --- a/config-model/src/test/java/com/yahoo/config/model/graph/GraphMock.java +++ b/config-model/src/test/java/com/yahoo/config/model/graph/GraphMock.java @@ -8,7 +8,6 @@ import com.yahoo.config.model.builder.xml.ConfigModelBuilder; import com.yahoo.config.model.builder.xml.ConfigModelId; import org.w3c.dom.Element; -import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -20,7 +19,7 @@ public class GraphMock { public static class BA extends ConfigModelBuilder<A> { public BA() { super(A.class); } - @Override public List<ConfigModelId> handlesElements() { return Arrays.asList(); } + @Override public List<ConfigModelId> handlesElements() { return List.of(); } @Override public void doBuild(A model, Element spec, ConfigModelContext modelContext) { } } public static class A extends ConfigModel { @@ -29,7 +28,7 @@ public class GraphMock { public static class BB extends ConfigModelBuilder<B> { public BB() { super(B.class); } - @Override public List<ConfigModelId> handlesElements() { return Arrays.asList(); } + @Override public List<ConfigModelId> handlesElements() { return List.of(); } @Override public void doBuild(B model, Element spec, ConfigModelContext modelContext) { } } public static class B extends ConfigModel { @@ -40,7 +39,7 @@ public class GraphMock { public static class BC extends ConfigModelBuilder<C> { public BC() { super(C.class); } - @Override public List<ConfigModelId> handlesElements() { return Arrays.asList(); } + @Override public List<ConfigModelId> handlesElements() { return List.of(); } @Override public void doBuild(C model, Element spec, ConfigModelContext modelContext) { } } public static class C extends ConfigModel { @@ -51,7 +50,7 @@ public class GraphMock { public static class BD extends ConfigModelBuilder<D> { public BD() { super(D.class); } - @Override public List<ConfigModelId> handlesElements() { return Arrays.asList(); } + @Override public List<ConfigModelId> handlesElements() { return List.of(); } @Override public void doBuild(D model, Element spec, ConfigModelContext modelContext) { } } public static class D extends ConfigModel { @@ -60,7 +59,7 @@ public class GraphMock { public static class BE extends ConfigModelBuilder<E> { public BE() { super(E.class); } - @Override public List<ConfigModelId> handlesElements() { return Arrays.asList(); } + @Override public List<ConfigModelId> handlesElements() { return List.of(); } @Override public void doBuild(E model, Element spec, ConfigModelContext modelContext) { } } public static class E extends ConfigModel { diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/HostsXmlProvisionerTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/HostsXmlProvisionerTest.java index 51574432e6d..02ca9effffb 100644 --- a/config-model/src/test/java/com/yahoo/config/model/provision/HostsXmlProvisionerTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/provision/HostsXmlProvisionerTest.java @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test; import java.io.StringReader; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -22,27 +21,29 @@ import static org.junit.jupiter.api.Assertions.*; */ public class HostsXmlProvisionerTest { - private static final String oneHost = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + - "<hosts>\n" + - " <host name=\"test1.yahoo.com\">\n" + - " <alias>node1</alias>\n" + - " <alias>node2</alias>\n" + - " </host>\n" + - "</hosts>"; - - private static final String threeHosts = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + - "<hosts>\n" + - " <host name=\"test1.yahoo.com\">\n" + - " <alias>node1</alias>\n" + - " </host>\n" + - " <host name=\"test2.yahoo.com\">\n" + - " <alias>node2</alias>\n" + - " <alias>node3</alias>\n" + - " </host>\n" + - " <host name=\"test3.yahoo.com\">\n" + - " <alias>node4</alias>\n" + - " </host>\n" + - "</hosts>"; + private static final String oneHost = """ + <?xml version="1.0" encoding="utf-8"?> + <hosts> + <host name="test1.yahoo.com"> + <alias>node1</alias> + <alias>node2</alias> + </host> + </hosts>"""; + + private static final String threeHosts = """ + <?xml version="1.0" encoding="utf-8"?> + <hosts> + <host name="test1.yahoo.com"> + <alias>node1</alias> + </host> + <host name="test2.yahoo.com"> + <alias>node2</alias> + <alias>node3</alias> + </host> + <host name="test3.yahoo.com"> + <alias>node4</alias> + </host> + </hosts>"""; @Test void require_basic_works() { @@ -57,7 +58,7 @@ public class HostsXmlProvisionerTest { assertTrue(map.keySet().containsAll(aliases)); // 5 services, 3 host aliases, mapping to 2 host. - aliases = createAliases(Collections.singletonList("node3")); + aliases = createAliases(List.of("node3")); map = allocate(hostProvisioner, aliases); assertCorrectNumberOfHosts(map, 2); @@ -65,7 +66,7 @@ public class HostsXmlProvisionerTest { assertTrue(map.keySet().containsAll(aliases)); // 5 services, 3 host aliases, mapping to 3 host. - aliases = createAliases(Collections.singletonList("node4")); + aliases = createAliases(List.of("node4")); map = allocate(hostProvisioner, aliases); assertEquals(3, map.size()); assertCorrectNumberOfHosts(map, 3); diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/SingleNodeProvisionerTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/SingleNodeProvisionerTest.java index e5dca4e5adf..b4f586e3f2f 100644 --- a/config-model/src/test/java/com/yahoo/config/model/provision/SingleNodeProvisionerTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/provision/SingleNodeProvisionerTest.java @@ -12,7 +12,6 @@ import org.xml.sax.SAXException; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -40,7 +39,7 @@ public class SingleNodeProvisionerTest { assertTrue(map.keySet().containsAll(aliases)); // 5 services, 3 host aliases, mapping to 2 host. - aliases = createAliases(Collections.singletonList("node3")); + aliases = createAliases(List.of("node3")); map = allocate(hostProvisioner, aliases); assertCorrectNumberOfHost(map, 1); @@ -48,7 +47,7 @@ public class SingleNodeProvisionerTest { assertTrue(map.keySet().containsAll(aliases)); // 5 services, 3 host aliases, mapping to 3 host. - aliases = createAliases(Collections.singletonList("node4")); + aliases = createAliases(List.of("node4")); map = allocate(hostProvisioner, aliases); assertThat(map.size(), is(3)); assertCorrectNumberOfHost(map, 1); diff --git a/config-model/src/test/java/com/yahoo/schema/AttributeUtils.java b/config-model/src/test/java/com/yahoo/schema/AttributeUtils.java index 69e7e14b3be..9ae24d6bfd4 100644 --- a/config-model/src/test/java/com/yahoo/schema/AttributeUtils.java +++ b/config-model/src/test/java/com/yahoo/schema/AttributeUtils.java @@ -8,8 +8,8 @@ import com.yahoo.schema.document.SDField; */ public class AttributeUtils { - public static void addAttributeAspect(SDField field) { - field.parseIndexingScript("{ attribute }"); + public static void addAttributeAspect(String schemaName, SDField field) { + field.parseIndexingScript(schemaName, "{ attribute }"); } } diff --git a/config-model/src/test/java/com/yahoo/schema/DocumentGraphValidatorTest.java b/config-model/src/test/java/com/yahoo/schema/DocumentGraphValidatorTest.java index defc7e59080..88761fc5d3f 100644 --- a/config-model/src/test/java/com/yahoo/schema/DocumentGraphValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/schema/DocumentGraphValidatorTest.java @@ -9,7 +9,6 @@ import com.yahoo.schema.document.TemporarySDField; import org.junit.jupiter.api.Test; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -142,14 +141,13 @@ public class DocumentGraphValidatorTest { Schema campaignSchema = new Schema(name, MockApplicationPackage.createEmpty()); SDDocumentType document = new SDDocumentType(name); campaignSchema.addDocument(document); - document.setDocumentReferences(new DocumentReferences(Collections.emptyMap())); + document.setDocumentReferences(new DocumentReferences(Map.of())); Arrays.stream(parents) .map(Schema::getDocument) .forEach(document::inherit); return campaignSchema; } - @SuppressWarnings("deprecation") private static void createDocumentReference(Schema from, Schema to, String refFieldName) { SDDocumentType fromDocument = from.getDocument(); SDField refField = new TemporarySDField(fromDocument, refFieldName, NewDocumentReferenceDataType.forDocumentName(to.getName())); diff --git a/config-model/src/test/java/com/yahoo/schema/DocumentReferenceResolverTest.java b/config-model/src/test/java/com/yahoo/schema/DocumentReferenceResolverTest.java index 76006ad28d7..99946406344 100644 --- a/config-model/src/test/java/com/yahoo/schema/DocumentReferenceResolverTest.java +++ b/config-model/src/test/java/com/yahoo/schema/DocumentReferenceResolverTest.java @@ -8,10 +8,9 @@ import com.yahoo.schema.document.SDDocumentType; import com.yahoo.schema.document.SDField; import org.junit.jupiter.api.Test; +import java.util.List; import java.util.Map; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.*; /** @@ -34,13 +33,13 @@ public class DocumentReferenceResolverTest { SDDocumentType fooDocument = new SDDocumentType("foo", fooSchema); SDField fooRefToBarField = new SDField (fooDocument, "bar_ref", new NewDocumentReferenceDataType(barDocument.getDocumentType())); - AttributeUtils.addAttributeAspect(fooRefToBarField); + AttributeUtils.addAttributeAspect(fooSchema.getName(), fooRefToBarField); SDField irrelevantField = new SDField(fooDocument, "irrelevant_stuff", DataType.INT); fooDocument.addField(fooRefToBarField); fooDocument.addField(irrelevantField); fooSchema.addDocument(fooDocument); - DocumentReferenceResolver resolver = new DocumentReferenceResolver(asList(fooSchema, barSchema)); + DocumentReferenceResolver resolver = new DocumentReferenceResolver(List.of(fooSchema, barSchema)); resolver.resolveReferences(fooDocument); assertTrue(fooDocument.getDocumentReferences().isPresent()); @@ -50,7 +49,6 @@ public class DocumentReferenceResolverTest { assertSame(fooRefToBarField, fooReferenceMap.get("bar_ref").referenceField()); } - @SuppressWarnings("deprecation") @Test void throws_user_friendly_exception_if_referenced_document_does_not_exist() { Throwable exception = assertThrows(IllegalArgumentException.class, () -> { @@ -60,11 +58,11 @@ public class DocumentReferenceResolverTest { SDField fooRefToBarField = new SDField( fooDocument, "bar_ref", NewDocumentReferenceDataType.forDocumentName("bar")); - AttributeUtils.addAttributeAspect(fooRefToBarField); + AttributeUtils.addAttributeAspect(fooSchema.getName(), fooRefToBarField); fooDocument.addField(fooRefToBarField); fooSchema.addDocument(fooDocument); - DocumentReferenceResolver resolver = new DocumentReferenceResolver(singletonList(fooSchema)); + DocumentReferenceResolver resolver = new DocumentReferenceResolver(List.of(fooSchema)); resolver.resolveReferences(fooDocument); }); assertTrue(exception.getMessage().contains("Invalid document reference 'bar_ref': Could not find document type 'bar'")); @@ -86,7 +84,7 @@ public class DocumentReferenceResolverTest { fooDocument.addField(fooRefToBarField); fooSchema.addDocument(fooDocument); - DocumentReferenceResolver resolver = new DocumentReferenceResolver(asList(fooSchema, barSchema)); + DocumentReferenceResolver resolver = new DocumentReferenceResolver(List.of(fooSchema, barSchema)); resolver.resolveReferences(fooDocument); }); assertTrue(exception.getMessage().contains("The field 'bar_ref' is an invalid document reference. The field must be an attribute.")); diff --git a/config-model/src/test/java/com/yahoo/schema/ImportedFieldsEnumeratorTest.java b/config-model/src/test/java/com/yahoo/schema/ImportedFieldsEnumeratorTest.java index 8c0b8c32d81..b96a43e9b53 100644 --- a/config-model/src/test/java/com/yahoo/schema/ImportedFieldsEnumeratorTest.java +++ b/config-model/src/test/java/com/yahoo/schema/ImportedFieldsEnumeratorTest.java @@ -22,7 +22,7 @@ public class ImportedFieldsEnumeratorTest { Schema parentSchema = new Schema(PARENT, MockApplicationPackage.createEmpty()); SDDocumentType parentDocument = new SDDocumentType(PARENT, parentSchema); var parentField = new SDField(parentDocument, "their_field", DataType.INT); - AttributeUtils.addAttributeAspect(parentField); + AttributeUtils.addAttributeAspect(parentSchema.getName(), parentField); parentDocument.addField(parentField); parentSchema.addDocument(parentDocument); diff --git a/config-model/src/test/java/com/yahoo/schema/derived/AttributeListTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/AttributeListTestCase.java index 0cfb9474365..f21999df94c 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/AttributeListTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/AttributeListTestCase.java @@ -14,6 +14,7 @@ import java.util.Iterator; import static com.yahoo.config.model.test.TestUtil.joinLines; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Tests attribute deriving @@ -126,4 +127,38 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { assertFalse(attributes.hasNext()); } + @Test + void bad_map_attribute() throws ParseException { + run_bad_struct_or_map_attribute("map<string,string>"); + } + + @Test + void bad_array_of_struct_attribute() throws ParseException { + run_bad_struct_or_map_attribute("array<s>"); + } + + private void run_bad_struct_or_map_attribute(String type) throws ParseException { + run_bad_struct_or_map_attribute(type, false, true); + run_bad_struct_or_map_attribute(type, true, false); + run_bad_struct_or_map_attribute(type, true, true); + } + + private void run_bad_struct_or_map_attribute(String type, boolean fs, boolean ilscript) throws ParseException { + var exception = assertThrows(IllegalArgumentException.class, () -> ApplicationBuilder.createFromString( + joinLines("search test {", + " document test {", + " struct s {", + " field a type string { }", + " }", + " field metadata type " + type + " {", + " indexing: summary" + (ilscript ? "| attribute" : ""), + " " + (fs ? "attribute: fast-search" : ""), + " }", + " }", + "}")).getSchema()); + assertEquals("For schema 'test': Field 'metadata' of type '" + type + "' cannot be an attribute." + + " Instead specify the struct fields to be searchable as attribute", + exception.getMessage()); + } + } diff --git a/config-model/src/test/java/com/yahoo/schema/derived/IdTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/IdTestCase.java index 188017e0af1..60adf7cbaf0 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/IdTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/IdTestCase.java @@ -30,7 +30,7 @@ public class IdTestCase extends AbstractExportingTestCase { SDDocumentType document = new SDDocumentType("test"); schema.addDocument(document); SDField uri = new SDField(document, "URI", DataType.URI); - uri.parseIndexingScript("{ summary | index }"); + uri.parseIndexingScript(schema.getName(), "{ summary | index }"); document.addField(uri); new Processing().process(schema, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), diff --git a/config-model/src/test/java/com/yahoo/schema/derived/IndexSchemaTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/IndexSchemaTestCase.java index 766c19bd01c..596ea99c36d 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/IndexSchemaTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/IndexSchemaTestCase.java @@ -6,7 +6,6 @@ import com.yahoo.document.Field; import com.yahoo.document.StructDataType; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -194,7 +193,7 @@ public class IndexSchemaTestCase { private static void assertFlat(Field fieldToFlatten, Field... expectedFields) { List<Field> actual = new LinkedList<>(IndexSchema.flattenField(fieldToFlatten)); - List<Field> expected = new LinkedList<>(Arrays.asList(expectedFields)); + List<Field> expected = new LinkedList<>(List.of(expectedFields)); Collections.sort(actual); Collections.sort(expected); for (Field field : actual) { diff --git a/config-model/src/test/java/com/yahoo/schema/derived/InheritanceTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/InheritanceTestCase.java index 472fa58230e..b1dc2e66bee 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/InheritanceTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/InheritanceTestCase.java @@ -65,7 +65,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { derive("inheritdiamond", builder, builder.getSchema("child")); assertCorrectConfigFiles("inheritdiamond"); } - List<String> files = Arrays.asList("grandparent.sd", "mother.sd", "father.sd", "child.sd"); + List<String> files = List.of("grandparent.sd", "mother.sd", "father.sd", "child.sd"); File outDir = newFolder(tmpDir, "out"); for (int startIdx = 0; startIdx < files.size(); ++startIdx) { var builder = new ApplicationBuilder(new TestProperties()); @@ -159,7 +159,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { Schema parentSchema = new Schema("parent", MockApplicationPackage.createEmpty()); parentSchema.addDocument(parent); SDField prefixed = parent.addField("prefixed", DataType.STRING); - prefixed.parseIndexingScript("{ index }"); + prefixed.parseIndexingScript(parentSchema.getName(), "{ index }"); prefixed.addIndex(new Index("prefixed", true)); SDDocumentType child = new SDDocumentType("child"); @@ -175,7 +175,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test void testInheritStructDiamondNew() throws IOException, ParseException { String dir = "src/test/derived/declstruct/"; - List<String> files = Arrays.asList("common.sd", "foo.sd", "bar.sd", "foobar.sd"); + List<String> files = List.of("common.sd", "foo.sd", "bar.sd", "foobar.sd"); var builder = new ApplicationBuilder(new TestProperties()); for (String fileName : files) { builder.addSchemaFile(dir + fileName); diff --git a/config-model/src/test/java/com/yahoo/schema/derived/LiteralBoostTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/LiteralBoostTestCase.java index 97a3f06ac64..505960256b8 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/LiteralBoostTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/LiteralBoostTestCase.java @@ -15,7 +15,7 @@ import com.yahoo.schema.processing.Processing; import com.yahoo.vespa.model.container.search.QueryProfiles; import org.junit.jupiter.api.Test; -import java.util.Arrays; +import java.util.List; import java.util.Set; import static com.yahoo.schema.processing.AssertIndexingScript.assertIndexing; @@ -36,7 +36,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { SDDocumentType document = new SDDocumentType("literalboost"); schema.addDocument(document); SDField field1 = document.addField("a", DataType.STRING); - field1.parseIndexingScript("{ index }"); + field1.parseIndexingScript(schema.getName(), "{ index }"); field1.setLiteralBoost(20); RankProfile other = new RankProfile("other", schema, rankProfileRegistry); rankProfileRegistry.add(other); @@ -50,7 +50,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { derived.getAttributeFields(); // TODO: assert content // Check il script addition - assertIndexing(Arrays.asList("clear_state | guard { input a | tokenize normalize stem:\"BEST\" | index a; }", + assertIndexing(List.of("clear_state | guard { input a | tokenize normalize stem:\"BEST\" | index a; }", "clear_state | guard { input a | tokenize | index a_literal; }"), schema); @@ -69,7 +69,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { SDDocumentType document = new SDDocumentType("literalboost"); schema.addDocument(document); SDField field1 = document.addField("a", DataType.STRING); - field1.parseIndexingScript("{ index }"); + field1.parseIndexingScript(schema.getName(), "{ index }"); RankProfile other = new RankProfile("other", schema, rankProfileRegistry); rankProfileRegistry.add(other); other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333)); @@ -78,7 +78,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { DerivedConfiguration derived = new DerivedConfiguration(schema, rankProfileRegistry); // Check il script addition - assertIndexing(Arrays.asList("clear_state | guard { input a | tokenize normalize stem:\"BEST\" | index a; }", + assertIndexing(List.of("clear_state | guard { input a | tokenize normalize stem:\"BEST\" | index a; }", "clear_state | guard { input a | tokenize | index a_literal; }"), schema); @@ -95,15 +95,15 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { SDDocumentType document = new SDDocumentType("msb"); schema.addDocument(document); SDField field1 = document.addField("title", DataType.STRING); - field1.parseIndexingScript("{ summary | index }"); + field1.parseIndexingScript(schema.getName(), "{ summary | index }"); field1.setLiteralBoost(20); SDField field2 = document.addField("body", DataType.STRING); - field2.parseIndexingScript("{ summary | index }"); + field2.parseIndexingScript(schema.getName(), "{ summary | index }"); field2.setLiteralBoost(20); schema = ApplicationBuilder.buildFromRawSchema(schema, rankProfileRegistry, new QueryProfileRegistry()); new DerivedConfiguration(schema, rankProfileRegistry); - assertIndexing(Arrays.asList("clear_state | guard { input title | tokenize normalize stem:\"BEST\" | summary title | index title; }", + assertIndexing(List.of("clear_state | guard { input title | tokenize normalize stem:\"BEST\" | summary title | index title; }", "clear_state | guard { input body | tokenize normalize stem:\"BEST\" | summary body | index body; }", "clear_state | guard { input title | tokenize | index title_literal; }", "clear_state | guard { input body | tokenize | index body_literal; }"), diff --git a/config-model/src/test/java/com/yahoo/schema/derived/SchemaOrdererTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/SchemaOrdererTestCase.java index 593f26eb074..8ae6ada7a63 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/SchemaOrdererTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/SchemaOrdererTestCase.java @@ -12,13 +12,11 @@ import com.yahoo.schema.document.SDField; import com.yahoo.schema.document.TemporarySDField; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import static java.util.Collections.emptyMap; import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -63,7 +61,7 @@ public class SchemaOrdererTestCase extends AbstractSchemaTestCase { private static Schema createSchema(String name, Map<String, Schema> schemas) { Schema schema = new Schema(name, MockApplicationPackage.createEmpty()); SDDocumentType document = new SDDocumentType(name); - document.setDocumentReferences(new DocumentReferences(emptyMap())); + document.setDocumentReferences(new DocumentReferences(Map.of())); schema.addDocument(document); schemas.put(schema.getName(), schema); return schema; @@ -74,9 +72,8 @@ public class SchemaOrdererTestCase extends AbstractSchemaTestCase { } private static void assertOrder(List<String> expectedSearchOrder, List<String> inputNames) { - inputNames.sort((a, b) -> a.compareTo(b)); Map<String, Schema> schemas = createSchemas(); - List<Schema> inputSchemas = inputNames.stream() + List<Schema> inputSchemas = inputNames.stream().sorted() .map(schemas::get) .map(Objects::requireNonNull) .toList(); @@ -88,7 +85,6 @@ public class SchemaOrdererTestCase extends AbstractSchemaTestCase { assertEquals(expectedSearchOrder, actualSearchOrder); } - @SuppressWarnings("deprecation") private static void createDocumentReference(Schema from, Schema to, String refFieldName) { SDDocumentType fromDocument = from.getDocument(); SDField refField = new TemporarySDField(fromDocument, refFieldName, NewDocumentReferenceDataType.forDocumentName(to.getName())); @@ -102,44 +98,44 @@ public class SchemaOrdererTestCase extends AbstractSchemaTestCase { @Test void testPerfectOrderingIsKept() { - assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), - Arrays.asList("grandParent", "mother", "father", "daughter", "son", "product", "pc", "alone")); + assertOrder(List.of("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), + List.of("grandParent", "mother", "father", "daughter", "son", "product", "pc", "alone")); } @Test void testOneLevelReordering() { - assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), - Arrays.asList("grandParent", "daughter", "son", "mother", "father", "pc", "product", "alone")); + assertOrder(List.of("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), + List.of("grandParent", "daughter", "son", "mother", "father", "pc", "product", "alone")); } @Test void testMultiLevelReordering() { - assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), - Arrays.asList("daughter", "son", "mother", "father", "grandParent", "pc", "product", "alone")); + assertOrder(List.of("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), + List.of("daughter", "son", "mother", "father", "grandParent", "pc", "product", "alone")); } @Test void testAloneIsKeptInPlaceWithMultiLevelReordering() { - assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), - Arrays.asList("alone", "daughter", "son", "mother", "father", "grandParent", "pc", "product")); + assertOrder(List.of("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), + List.of("alone", "daughter", "son", "mother", "father", "grandParent", "pc", "product")); } @Test void testPartialMultiLevelReordering() { - assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), - Arrays.asList("daughter", "grandParent", "mother", "son", "father", "product", "pc", "alone")); + assertOrder(List.of("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), + List.of("daughter", "grandParent", "mother", "son", "father", "product", "pc", "alone")); } @Test void testMultilevelReorderingAccrossHierarchies() { - assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), - Arrays.asList("daughter", "pc", "son", "mother", "grandParent", "father", "product", "alone")); + assertOrder(List.of("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "son"), + List.of("daughter", "pc", "son", "mother", "grandParent", "father", "product", "alone")); } @Test void referees_are_ordered_before_referrer() { - assertOrder(Arrays.asList("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "accessory-pc", "son"), - Arrays.asList("accessory-pc", "daughter", "pc", "son", "mother", "grandParent", "father", "product", "alone")); + assertOrder(List.of("alone", "grandParent", "mother", "father", "daughter", "product", "pc", "accessory-pc", "son"), + List.of("accessory-pc", "daughter", "pc", "son", "mother", "grandParent", "father", "product", "alone")); } diff --git a/config-model/src/test/java/com/yahoo/schema/derived/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/SummaryTestCase.java index a27bc824b45..63510785ca5 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/SummaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/SummaryTestCase.java @@ -172,7 +172,7 @@ public class SummaryTestCase extends AbstractSchemaTestCase { schema.addDocument(document); String fieldName = "location"; SDField field = document.addField(fieldName, PositionDataType.INSTANCE); - field.parseIndexingScript("{ attribute | summary }"); + field.parseIndexingScript(schema.getName(), "{ attribute | summary }"); new Processing().process(schema, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true, false, Set.of()); diff --git a/config-model/src/test/java/com/yahoo/schema/derived/TypeConversionTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/TypeConversionTestCase.java index d2b3acc9a1e..cdfe376416b 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/TypeConversionTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/TypeConversionTestCase.java @@ -32,7 +32,7 @@ public class TypeConversionTestCase extends AbstractSchemaTestCase { SDDocumentType document = new SDDocumentType("test"); schema.addDocument(document); SDField a = new SDField(document, "a", DataType.STRING); - a.parseIndexingScript("{ index }"); + a.parseIndexingScript(schema.getName(), "{ index }"); document.addField(a); new Processing().process(schema, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), diff --git a/config-model/src/test/java/com/yahoo/schema/derived/VsmFieldsTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/VsmFieldsTestCase.java index 852f567ccfa..a90b4fa8d9f 100644 --- a/config-model/src/test/java/com/yahoo/schema/derived/VsmFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/derived/VsmFieldsTestCase.java @@ -46,7 +46,7 @@ public class VsmFieldsTestCase { void reference_type_field_is_unsearchable() { Schema schema = createSchema(); SDField field = new TemporarySDField(schema.getDocument(), "ref_field", NewDocumentReferenceDataType.forDocumentName("parent_type")); - field.parseIndexingScript("{ summary }"); + field.parseIndexingScript(schema.getName(), "{ summary }"); schema.getDocument().addField(field); VsmfieldsConfig cfg = vsmfieldsConfig(schema); @@ -59,7 +59,7 @@ public class VsmFieldsTestCase { private void testIndexMatching(Matching matching, VsmfieldsConfig.Fieldspec.Normalize.Enum normalize, String arg1) { Schema schema = createSchema(); SDField field = new TemporarySDField(schema.getDocument(), "f", DataType.STRING); - field.parseIndexingScript("{ index }"); + field.parseIndexingScript(schema.getName(), "{ index }"); field.setMatching(matching); schema.getDocument().addField(field); VsmfieldsConfig cfg = vsmfieldsConfig(schema); diff --git a/config-model/src/test/java/com/yahoo/schema/processing/AddDataTypeAndTransformToSummaryOfImportedFieldsTest.java b/config-model/src/test/java/com/yahoo/schema/processing/AddDataTypeAndTransformToSummaryOfImportedFieldsTest.java index f09a95b89a0..3da6f250853 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/AddDataTypeAndTransformToSummaryOfImportedFieldsTest.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/AddDataTypeAndTransformToSummaryOfImportedFieldsTest.java @@ -19,7 +19,7 @@ import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; import org.junit.jupiter.api.Test; -import java.util.Collections; +import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -63,7 +63,7 @@ public class AddDataTypeAndTransformToSummaryOfImportedFieldsTest { SDField targetField = new SDField(doc, "target_field", DataType.INT); DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSchema); ImportedField importedField = new ImportedSimpleField(fieldName, documentReference, targetField); - return new ImportedFields(Collections.singletonMap(fieldName, importedField)); + return new ImportedFields(Map.of(fieldName, importedField)); } private static DocumentSummary createDocumentSummary(String fieldName, Schema schema) { diff --git a/config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java index c2cc28ea6b3..310706cb0d1 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java @@ -18,7 +18,7 @@ import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression; import com.yahoo.vespa.model.container.search.QueryProfiles; import org.junit.jupiter.api.Test; -import java.util.Arrays; +import java.util.List; import java.util.OptionalDouble; import java.util.OptionalInt; import java.util.OptionalLong; @@ -105,7 +105,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { @Test void testDerivingFromSimple() throws Exception { - assertIndexing(Arrays.asList("clear_state | guard { input access | attribute access; }", + assertIndexing(List.of("clear_state | guard { input access | attribute access; }", "clear_state | guard { input category | split \";\" | attribute category_arr; }", "clear_state | guard { input category | tokenize | index category; }", "clear_state | guard { input categories_src | lowercase | normalize | tokenize normalize stem:\"BEST\" | index categories; }", @@ -127,8 +127,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { @Test void testIndexRewrite() throws Exception { assertIndexing( - Arrays.asList("clear_state | guard { input title_src | lowercase | normalize | " + - " tokenize | index title; }", + List.of("clear_state | guard { input title_src | lowercase | normalize | tokenize | index title; }", "clear_state | guard { input title_src | summary title_s; }"), ApplicationBuilder.buildFromFile("src/test/examples/indexrewrite.sd")); } @@ -151,7 +150,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { void requireThatMaxTermOccurrencesIsPropagated() { var field = new SDField("test", DataType.STRING); field.getMatching().maxTermOccurrences(10); - field.parseIndexingScript("{ summary | index }"); + field.parseIndexingScript("test", "{ summary | index }"); assertIndexingScript("{ input test | tokenize normalize stem:\"BEST\" max-occurrences:10 | summary test | index test; }", field); } @@ -173,14 +172,14 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { private static SDField createField(String name, DataType type, String script) { SDField field = new SDField(null, name, type); - field.parseIndexingScript(script); + field.parseIndexingScript("test", script); return field; } private static SDField createPredicateField( String name, DataType type, String script, int arity, OptionalLong lower_bound, OptionalLong upper_bound) { SDField field = new SDField(null, name, type); - field.parseIndexingScript(script); + field.parseIndexingScript("test", script); Index index = new Index("foo"); index.setBooleanIndexDefiniton(new BooleanIndexDefinition( OptionalInt.of(arity), lower_bound, upper_bound, OptionalDouble.empty())); diff --git a/config-model/src/test/java/com/yahoo/schema/processing/IndexingValidationTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/IndexingValidationTestCase.java index 71c91533f54..4053834784f 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/IndexingValidationTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/IndexingValidationTestCase.java @@ -8,7 +8,7 @@ import com.yahoo.yolean.Exceptions; import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.Arrays; +import java.util.List; import static com.yahoo.schema.processing.AssertIndexingScript.assertIndexing; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -154,7 +154,7 @@ public class IndexingValidationTestCase extends AbstractExportingTestCase { @Test void testExtraField() throws IOException, ParseException { assertIndexing( - Arrays.asList("clear_state | guard { input my_index | tokenize normalize stem:\"BEST\" | index my_index | summary my_index }", + List.of("clear_state | guard { input my_index | tokenize normalize stem:\"BEST\" | index my_index | summary my_index }", "clear_state | guard { input my_input | tokenize normalize stem:\"BEST\" | index my_extra | summary my_extra }"), ApplicationBuilder.buildFromFile("src/test/examples/indexing_extra.sd")); } diff --git a/config-model/src/test/java/com/yahoo/schema/processing/ParentChildSearchModel.java b/config-model/src/test/java/com/yahoo/schema/processing/ParentChildSearchModel.java index af275feffed..129d65584ba 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/ParentChildSearchModel.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/ParentChildSearchModel.java @@ -36,8 +36,11 @@ public class ParentChildSearchModel { } protected static TemporarySDField createField(SDDocumentType repo, String name, DataType dataType, String indexingScript) { + return createField(repo, repo.getName(), name, dataType, indexingScript); + } + protected static TemporarySDField createField(SDDocumentType repo, String schemaName, String name, DataType dataType, String indexingScript) { TemporarySDField result = new TemporarySDField(repo, name, dataType); - result.parseIndexingScript(indexingScript); + result.parseIndexingScript(schemaName, indexingScript); return result; } diff --git a/config-model/src/test/java/com/yahoo/schema/processing/PositionTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/PositionTestCase.java index 007006bf6d3..87a66046fe5 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/PositionTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/PositionTestCase.java @@ -13,8 +13,8 @@ import com.yahoo.vespa.documentmodel.SummaryTransform; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.Iterator; +import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -27,7 +27,7 @@ public class PositionTestCase { @Test void inherited_position_zcurve_field_is_not_added_to_document_fieldset() throws Exception { - ApplicationBuilder sb = ApplicationBuilder.createFromFiles(Arrays.asList( + ApplicationBuilder sb = ApplicationBuilder.createFromFiles(List.of( "src/test/examples/position_base.sd", "src/test/examples/position_inherited.sd")); diff --git a/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithTransformerTokensTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithTransformerTokensTestCase.java index 9213f97fd9f..6cbd8faf3b0 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithTransformerTokensTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithTransformerTokensTestCase.java @@ -19,7 +19,7 @@ import com.yahoo.searchlib.rankingexpression.evaluation.TensorValue; import com.yahoo.tensor.Tensor; import org.junit.jupiter.api.Test; -import java.util.Collections; +import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -94,16 +94,17 @@ public class RankingExpressionWithTransformerTokensTestCase { MockApplicationPackage application = (MockApplicationPackage) MockApplicationPackage.createEmpty(); RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); QueryProfileRegistry queryProfileRegistry = application.getQueryProfiles(); - String sdContent = "search test {\n" + - " document test {}\n" + - " rank-profile my_profile inherits default {}\n" + - "}"; + String sdContent = """ + search test { + document test {} + rank-profile my_profile inherits default {} + }"""; ApplicationBuilder schemaBuilder = new ApplicationBuilder(application, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); schemaBuilder.addSchema(sdContent); schemaBuilder.build(true); Schema schema = schemaBuilder.getSchema(); RankProfile rp = rankProfileRegistry.get(schema, "my_profile"); - return new RankProfileTransformContext(rp, queryProfileRegistry, Collections.emptyMap(), null, Collections.emptyMap(), Collections.emptyMap()); + return new RankProfileTransformContext(rp, queryProfileRegistry, Map.of(), null, Map.of(), Map.of()); } } diff --git a/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionsTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionsTestCase.java index 0f16330ce11..a602503a71c 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionsTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionsTestCase.java @@ -21,7 +21,6 @@ import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -102,12 +101,12 @@ public class RankingExpressionsTestCase extends AbstractSchemaTestCase { { AttributeFields attributes = new AttributeFields(schema); - verifyProfile(rankProfileRegistry.get(schema, "base"), Arrays.asList("large_f", "large_m"), - Arrays.asList(new Pair<>("rankingExpression(large_f).expressionName", "base.large_f"), new Pair<>("rankingExpression(large_m).expressionName", "base.large_m")), + verifyProfile(rankProfileRegistry.get(schema, "base"), List.of("large_f", "large_m"), + List.of(new Pair<>("rankingExpression(large_f).expressionName", "base.large_f"), new Pair<>("rankingExpression(large_m).expressionName", "base.large_m")), largeExpressions, queryProfiles, models, attributes, properties); - for (String child : Arrays.asList("child_a", "child_b")) { - verifyProfile(rankProfileRegistry.get(schema, child), Arrays.asList("large_f", "large_m", "large_local_f", "large_local_m"), - Arrays.asList(new Pair<>("rankingExpression(large_f).expressionName", child + ".large_f"), new Pair<>("rankingExpression(large_m).expressionName", child + ".large_m"), + for (String child : List.of("child_a", "child_b")) { + verifyProfile(rankProfileRegistry.get(schema, child), List.of("large_f", "large_m", "large_local_f", "large_local_m"), + List.of(new Pair<>("rankingExpression(large_f).expressionName", child + ".large_f"), new Pair<>("rankingExpression(large_m).expressionName", child + ".large_m"), new Pair<>("rankingExpression(large_local_f).expressionName", child + ".large_local_f"), new Pair<>("rankingExpression(large_local_m).expressionName", child + ".large_local_m"), new Pair<>("vespa.rank.firstphase", "rankingExpression(firstphase)"), new Pair<>("rankingExpression(firstphase).expressionName", child + ".firstphase")), largeExpressions, queryProfiles, models, attributes, properties); diff --git a/config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java b/config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java index be72d2b12fa..8585a206d77 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java @@ -18,7 +18,7 @@ import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; import org.junit.jupiter.api.Test; -import java.util.Collections; +import java.util.Map; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -65,7 +65,7 @@ public class ValidateFieldTypesTest { SDField targetField = new SDField(targetSchema.getDocument(), "target_field", dataType); DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSchema); ImportedField importedField = new ImportedSimpleField(fieldName, documentReference, targetField); - return new ImportedFields(Collections.singletonMap(fieldName, importedField)); + return new ImportedFields(Map.of(fieldName, importedField)); } private static DocumentSummary createDocumentSummary(String fieldName, DataType dataType, Schema schema) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java index 88e1ba7a1a6..94dd0f367a3 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/metricsproxy/MetricsConsumersTest.java @@ -8,6 +8,8 @@ import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.admin.monitoring.MetricsConsumer; import org.junit.jupiter.api.Test; +import java.util.List; + import static ai.vespa.metrics.set.DefaultMetrics.defaultMetricSet; import static ai.vespa.metrics.set.DefaultVespaMetrics.defaultVespaMetricSet; import static ai.vespa.metrics.set.NetworkMetrics.networkMetricSet; @@ -21,7 +23,6 @@ import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.c import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getCustomConsumer; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.getModel; import static com.yahoo.vespa.model.admin.metricsproxy.MetricsProxyModelTester.servicesWithAdminOnly; -import static java.util.Collections.singleton; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -72,7 +73,7 @@ public class MetricsConsumersTest { void vespa_consumer_can_be_amended_via_admin_object() { VespaModel model = getModel(servicesWithAdminOnly(), hosted); var additionalMetric = new Metric("additional-metric"); - model.getAdmin().setAdditionalDefaultMetrics(new MetricSet("amender-metrics", singleton(additionalMetric))); + model.getAdmin().setAdditionalDefaultMetrics(new MetricSet("amender-metrics", List.of(additionalMetric))); ConsumersConfig config = consumersConfigFromModel(model); assertEquals(numMetricsForVespaConsumer + 1, config.consumer(0).metric().size()); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java index b2291099b44..ae1db366c9f 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ComplexFieldsValidatorTestCase.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.logging.Level; import static com.yahoo.config.model.test.TestUtil.joinLines; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -67,7 +68,9 @@ public class ComplexFieldsValidatorTestCase { "}", "}")); }); - assertTrue(exception.getMessage().contains(getExpectedMessage("docTopics (docTopics.topics, docTopics.topics.id, docTopics.topics.label)"))); + assertEquals("For schema 'test': Field 'docTopics.topics' of type 'array<topic>' cannot be an attribute." + + " Instead specify the struct fields to be searchable as attribute", + exception.getMessage()); } @Test diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/PublicApiBundleValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/PublicApiBundleValidatorTest.java index 19be886d3e5..c5ef2238f9b 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/PublicApiBundleValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/PublicApiBundleValidatorTest.java @@ -8,7 +8,6 @@ import org.junit.jupiter.api.io.TempDir; import java.io.File; import java.io.IOException; -import java.util.Arrays; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; @@ -42,7 +41,7 @@ public class PublicApiBundleValidatorTest { assertThat(output, containsString("uses non-public Vespa APIs: [")); // List of packages should be sorted - List<String> packages = Arrays.asList(output.substring(output.indexOf("[") + 1, output.indexOf("]")).split(", ")); + List<String> packages = List.of(output.substring(output.indexOf("[") + 1, output.indexOf("]")).split(", ")); assertThat(packages, hasSize(2)); assertThat(packages, contains("ai.vespa.lib.non_public", "com.yahoo.lib.non_public")); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java index e4b9b45489d..829bd6148a6 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StartupCommandChangeValidatorTest.java @@ -54,7 +54,7 @@ public class StartupCommandChangeValidatorTest { private static MockRoot createRootWithChildren(TreeConfigProducer<?>... children) { MockRoot root = new MockRoot(); - Arrays.asList(children).forEach(root::addChild); + List.of(children).forEach(root::addChild); root.freezeModelTopology(); return root; } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java index 91ba97817d6..8778f0c26c0 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/ContentClusterFixture.java @@ -9,7 +9,6 @@ import com.yahoo.vespa.model.content.utils.ContentClusterUtils; import com.yahoo.vespa.model.content.utils.SchemaBuilder; import com.yahoo.vespa.model.search.DocumentDatabase; -import java.util.Arrays; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -32,15 +31,15 @@ public abstract class ContentClusterFixture { public ContentClusterFixture(String entireSd) throws Exception { currentCluster = new ContentClusterBuilder().build( - ContentClusterUtils.createMockRoot(Arrays.asList(entireSd))); + ContentClusterUtils.createMockRoot(List.of(entireSd))); nextCluster = new ContentClusterBuilder().build( - ContentClusterUtils.createMockRoot(Arrays.asList(entireSd))); + ContentClusterUtils.createMockRoot(List.of(entireSd))); } private static ContentCluster createCluster(String sdContent) throws Exception { return new ContentClusterBuilder().build( ContentClusterUtils.createMockRoot( - Arrays.asList(new SchemaBuilder().content(sdContent).build()))); + List.of(new SchemaBuilder().content(sdContent).build()))); } protected DocumentDatabase currentDb() { @@ -65,7 +64,7 @@ public abstract class ContentClusterFixture { } public void assertValidation(VespaConfigChangeAction exp) { - assertValidation(Arrays.asList(exp)); + assertValidation(List.of(exp)); } public void assertValidation(List<VespaConfigChangeAction> exp) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java index 684bd619ba1..129649ae1fb 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java @@ -8,7 +8,6 @@ import com.yahoo.vespa.model.application.validation.change.VespaConfigChangeActi import org.junit.jupiter.api.Test; import java.time.Instant; -import java.util.Arrays; import java.util.List; import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.newRefeedAction; @@ -50,7 +49,7 @@ public class DocumentDatabaseChangeValidatorTest { "field f3 type string { indexing: summary } " + "field f4 type array<s> { struct-field s1 { indexing: attribute } }"); Instant.now(); - f.assertValidation(Arrays.asList( + f.assertValidation(List.of( newRestartAction(ClusterSpec.Id.from("test"), "Field 'f1' changed: add attribute aspect"), newRestartAction(ClusterSpec.Id.from("test"), diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java index 44743c4fa3e..26a4f532362 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java @@ -14,10 +14,9 @@ import com.yahoo.vespa.model.application.validation.change.VespaRefeedAction; import org.junit.jupiter.api.Test; import java.time.Instant; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.Set; import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.newRefeedAction; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -108,7 +107,7 @@ public class DocumentTypeChangeValidatorTest { "field f2 type string { indexing: summary } field f1 type int { indexing: summary }"); Instant.now(); Instant.now(); - f.assertValidation(Arrays.asList(newRefeedAction(ClusterSpec.Id.from("test"), ValidationId.fieldTypeChange, "Field 'f1' changed: data type: 'string' -> 'int'"), + f.assertValidation(List.of(newRefeedAction(ClusterSpec.Id.from("test"), ValidationId.fieldTypeChange, "Field 'f1' changed: data type: 'string' -> 'int'"), newRefeedAction(ClusterSpec.Id.from("test"), ValidationId.fieldTypeChange, "Field 'f2' changed: data type: 'int' -> 'string'"))); } @@ -210,8 +209,8 @@ public class DocumentTypeChangeValidatorTest { new NewDocumentType.Name("mydoc"), headerfields, new FieldSets(Optional.empty()), - Collections.emptySet(), - Collections.emptySet()); + Set.of(), + Set.of()); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java index 6b58cac3f6c..cd54a20523f 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java @@ -12,7 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.List; public class IndexingScriptChangeValidatorTest { @@ -126,7 +125,7 @@ public class IndexingScriptChangeValidatorTest { void requireThatMultipleChangesRequireReindexing() throws Exception { new Fixture(FIELD + " { indexing: index } " + FIELD_F2 + " { indexing: index }", FIELD + " { indexing: index \n stemming: none } " + FIELD_F2 + " { indexing: index \n normalizing: none }"). - assertValidation(Arrays.asList(expectedReindexingAction("f1", "stemming: 'best' -> 'none'", + assertValidation(List.of(expectedReindexingAction("f1", "stemming: 'best' -> 'none'", "{ input f1 | tokenize normalize stem:\"BEST\" | index f1; }", "{ input f1 | tokenize normalize | index f1; }"), expectedReindexingAction("f2", "normalizing: 'ACCENT' -> 'NONE'", diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java index fac82f3e675..924419daeae 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java @@ -26,7 +26,6 @@ import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.List; import java.util.Set; @@ -876,8 +875,8 @@ public class ContentBuilderTest extends DomBuilderTest { VespaModel m = new VespaModelCreatorWithMockPkg(new MockApplicationPackage.Builder() .withHosts(getHosts()) .withServices(combined) - .withSchemas(Arrays.asList(MockApplicationPackage.MUSIC_SCHEMA, - MockApplicationPackage.BOOK_SCHEMA)) + .withSchemas(List.of(MockApplicationPackage.MUSIC_SCHEMA, + MockApplicationPackage.BOOK_SCHEMA)) .build()) .create(); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java index 853cfdd9429..0e616661191 100755 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomAdminV2BuilderTest.java @@ -18,7 +18,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.w3c.dom.Element; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -112,7 +111,7 @@ public class DomAdminV2BuilderTest extends DomBuilderTest { @Test void multitenant() { - List<ConfigServerSpec> configServerSpecs = Arrays.asList( + List<ConfigServerSpec> configServerSpecs = List.of( new TestProperties.Spec("test1", 19070, 2181), new TestProperties.Spec("test2", 19070, 2181), new TestProperties.Spec("test3", 19070, 2181)); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSchemaTuningBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSchemaTuningBuilderTest.java index 764e31fe13a..c7525dec6a3 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSchemaTuningBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSchemaTuningBuilderTest.java @@ -8,7 +8,7 @@ import com.yahoo.vespa.model.search.Tuning; import org.junit.jupiter.api.Test; import org.w3c.dom.Element; -import java.util.Arrays; +import java.util.List; import static org.junit.jupiter.api.Assertions.*; @@ -22,7 +22,7 @@ public class DomSchemaTuningBuilderTest extends DomBuilderTest { private static Element parseXml(String... xmlLines) { return parse("<tuning>", "<searchnode>", - CollectionUtil.mkString(Arrays.asList(xmlLines), "\n"), + CollectionUtil.mkString(List.of(xmlLines), "\n"), "</searchnode>", "</tuning>"); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java index 6b384269910..56f492f3fca 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/DomSchemaChainsBuilderTest.java @@ -20,7 +20,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.w3c.dom.Element; -import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -98,7 +97,7 @@ public class DomSchemaChainsBuilderTest extends DomBuilderTest { @Test void ensureSearchChainsExists() { - for (String id : Arrays.asList("provider:1", "source:1@provider:1", "default")) { + for (String id : List.of("provider:1", "source:1@provider:1", "default")) { assertNotNull(getSearchChain(id), "Missing search chain " + id); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/component/ModelTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/component/ModelTest.java new file mode 100644 index 00000000000..7660ae45c3a --- /dev/null +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/component/ModelTest.java @@ -0,0 +1,33 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.model.container.component; + +import com.yahoo.config.model.deploy.DeployState; +import com.yahoo.text.XML; +import org.junit.jupiter.api.Test; + +import java.util.Set; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @author hmusum + */ +public class ModelTest { + + @Test + void invalid_url(){ + var xml = """ + <component id="bert-embedder" type="bert-embedder"> + <transformer-model url="models/e5-base-v2.onnx" /> + <tokenizer-vocab path="models/vocab.txt"/> + </component> + """; + + var state = new DeployState.Builder().build(); + var element = XML.getDocument(xml).getDocumentElement(); +var exception = assertThrows(IllegalArgumentException.class, + () -> Model.fromXml(state, element, "transformer-model", Set.of())); +org.junit.jupiter.api.Assertions.assertEquals("Invalid url 'models/e5-base-v2.onnx': url has no 'scheme' component", exception.getMessage()); + } + +} diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java index b933d86655e..4e14fbcd671 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/configserver/ConfigserverClusterTest.java @@ -21,12 +21,9 @@ import com.yahoo.vespa.model.container.configserver.option.CloudConfigOptions; import com.yahoo.vespa.model.container.xml.ConfigServerContainerModelBuilder; import org.junit.jupiter.api.Test; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.Function; -import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.*; @@ -46,7 +43,7 @@ public class ConfigserverClusterTest { @Test void zookeeperConfig_only_config_servers_set_hosted() { - TestOptions testOptions = createTestOptions(Arrays.asList("cfg1", "localhost", "cfg3"), Collections.emptyList()); + TestOptions testOptions = createTestOptions(List.of("cfg1", "localhost", "cfg3"), List.of()); ZookeeperServerConfig config = getConfig(ZookeeperServerConfig.class, testOptions); assertZookeeperServerProperty(config.server(), ZookeeperServerConfig.Server::hostname, "cfg1", "localhost", "cfg3"); assertZookeeperServerProperty(config.server(), ZookeeperServerConfig.Server::id, 0, 1, 2); @@ -57,7 +54,7 @@ public class ConfigserverClusterTest { @Test void zookeeperConfig_with_config_servers_and_zk_ids_hosted() { - TestOptions testOptions = createTestOptions(Arrays.asList("cfg1", "localhost", "cfg3"), Arrays.asList(4, 2, 3)); + TestOptions testOptions = createTestOptions(List.of("cfg1", "localhost", "cfg3"), List.of(4, 2, 3)); ZookeeperServerConfig config = getConfig(ZookeeperServerConfig.class, testOptions); assertZookeeperServerProperty(config.server(), ZookeeperServerConfig.Server::hostname, "cfg1", "localhost", "cfg3"); assertZookeeperServerProperty(config.server(), ZookeeperServerConfig.Server::id, 4, 2, 3); @@ -68,7 +65,7 @@ public class ConfigserverClusterTest { @Test void zookeeperConfig_self_hosted() { final boolean hostedVespa = false; - TestOptions testOptions = createTestOptions(Arrays.asList("cfg1", "localhost", "cfg3"), Arrays.asList(4, 2, 3), hostedVespa); + TestOptions testOptions = createTestOptions(List.of("cfg1", "localhost", "cfg3"), List.of(4, 2, 3), hostedVespa); ZookeeperServerConfig config = getConfig(ZookeeperServerConfig.class, testOptions); assertZookeeperServerProperty(config.server(), ZookeeperServerConfig.Server::hostname, "cfg1", "localhost", "cfg3"); assertZookeeperServerProperty(config.server(), ZookeeperServerConfig.Server::id, 4, 2, 3); @@ -80,7 +77,7 @@ public class ConfigserverClusterTest { @Test void zookeeperConfig_uneven_number_of_config_servers_and_zk_ids() { assertThrows(IllegalArgumentException.class, () -> { - TestOptions testOptions = createTestOptions(Arrays.asList("cfg1", "localhost", "cfg3"), Collections.singletonList(1)); + TestOptions testOptions = createTestOptions(List.of("cfg1", "localhost", "cfg3"), List.of(1)); getConfig(ZookeeperServerConfig.class, testOptions); }); } @@ -88,7 +85,7 @@ public class ConfigserverClusterTest { @Test void zookeeperConfig_negative_zk_id() { assertThrows(IllegalArgumentException.class, () -> { - TestOptions testOptions = createTestOptions(Arrays.asList("cfg1", "localhost", "cfg3"), Arrays.asList(1, 2, -1)); + TestOptions testOptions = createTestOptions(List.of("cfg1", "localhost", "cfg3"), List.of(1, 2, -1)); getConfig(ZookeeperServerConfig.class, testOptions); }); } @@ -137,7 +134,7 @@ public class ConfigserverClusterTest { private static <T> void assertZookeeperServerProperty( List<ZookeeperServerConfig.Server> zkServers, Function<ZookeeperServerConfig.Server, T> propertyMapper, T... expectedProperties) { List<T> actualPropertyValues = zkServers.stream().map(propertyMapper).toList(); - List<T> expectedPropertyValues = Arrays.asList(expectedProperties); + List<T> expectedPropertyValues = List.of(expectedProperties); assertEquals(expectedPropertyValues, actualPropertyValues); } @@ -169,7 +166,7 @@ public class ConfigserverClusterTest { } private static <CONFIGTYPE extends ConfigInstance> CONFIGTYPE getConfig(Class<CONFIGTYPE> clazz) { - return getConfig(clazz, createTestOptions(Collections.emptyList(), Collections.emptyList())); + return getConfig(clazz, createTestOptions(List.of(), List.of())); } private static <CONFIGTYPE extends ConfigInstance> CONFIGTYPE getConfig(Class<CONFIGTYPE> clazz, TestOptions testOptions) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java index 73c4075a182..3345f935e1d 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/http/BlockFeedGlobalEndpointsFilterTest.java @@ -7,7 +7,6 @@ import com.yahoo.config.model.api.ContainerEndpoint; import com.yahoo.vespa.config.jdisc.http.filter.RuleBasedFilterConfig; import org.junit.jupiter.api.Test; -import java.util.Collections; import java.util.List; import java.util.Set; @@ -29,7 +28,7 @@ public class BlockFeedGlobalEndpointsFilterTest { @Test void does_not_setup_blocking_rule_when_endpoints_empty() { - var filter = new BlockFeedGlobalEndpointsFilter(Collections.emptySet(), true); + var filter = new BlockFeedGlobalEndpointsFilter(Set.of(), true); var config = getConfig(filter); assertEquals(0, config.rule().size()); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTestBase.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTestBase.java index a066308b426..a832c54021f 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTestBase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTestBase.java @@ -19,8 +19,8 @@ import org.junit.jupiter.api.BeforeEach; import org.w3c.dom.Element; import java.util.ArrayList; -import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.logging.Level; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -88,7 +88,7 @@ public abstract class ContainerModelBuilderTestBase { private static void generateDefaultSearchChains(ContainerCluster<?> cluster) { ContainerSearch search = cluster.getSearch(); if (search != null) - search.initializeSearchChains(Collections.emptyMap()); + search.initializeSearchChains(Map.of()); } protected ComponentsConfig componentsConfig() { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/EmbedderTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/EmbedderTestCase.java index 4efffc8310a..fb1e176f707 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/EmbedderTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/EmbedderTestCase.java @@ -158,7 +158,7 @@ public class EmbedderTestCase { var model = loadModel(Path.fromString("src/test/cfg/application/embed/"), false); var cluster = model.getContainerClusters().get("container"); var embedderCfg = assertBertEmbedderComponentPresent(cluster); - assertEquals("application-url", modelReference(embedderCfg, "transformerModel").url().orElseThrow().value()); + assertEquals("https://my/url/model.onnx", modelReference(embedderCfg, "transformerModel").url().orElseThrow().value()); assertEquals("files/vocab.txt", modelReference(embedderCfg, "tokenizerVocab").path().orElseThrow().value()); assertEquals("", embedderCfg.transformerTokenTypeIds()); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java index 10adca12f91..46097da434e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/JvmOptionsTest.java @@ -19,13 +19,12 @@ import org.w3c.dom.Element; import org.xml.sax.SAXException; import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Set; import java.util.logging.Level; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -218,18 +217,17 @@ public class JvmOptionsTest extends ContainerModelBuilderTestBase { } private String verifyLogMessage(TestLogger logger, String... invalidOptions) { - List<String> strings = Arrays.asList(invalidOptions.clone()); + List<String> strings = List.of(invalidOptions); // Verify that nothing is logged if there are no invalid options if (strings.isEmpty()) { - assertEquals(0, logger.msgs.size(), logger.msgs.size() > 0 ? logger.msgs.get(0).getSecond() : ""); + assertEquals(0, logger.msgs.size(), !logger.msgs.isEmpty() ? logger.msgs.get(0).getSecond() : ""); return null; } - assertTrue(logger.msgs.size() > 0, "Expected 1 or more log messages for invalid JM options, got none"); + assertFalse(logger.msgs.isEmpty(), "Expected 1 or more log messages for invalid JM options, got none"); Pair<Level, String> firstOption = logger.msgs.get(0); assertEquals(Level.WARNING, firstOption.getFirst()); - Collections.sort(strings); return firstOption.getSecond(); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java index 1ba5bebea7e..96e1f2edf76 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java @@ -22,7 +22,6 @@ import com.yahoo.vespa.config.content.AllClustersBucketSpacesConfig; import com.yahoo.vespa.config.content.DistributionConfig; import com.yahoo.vespa.config.content.FleetcontrollerConfig; import com.yahoo.vespa.config.content.StorDistributionConfig; -import com.yahoo.vespa.config.content.StorFilestorConfig; import com.yahoo.vespa.config.content.core.StorDistributormanagerConfig; import com.yahoo.vespa.config.content.core.StorServerConfig; import com.yahoo.vespa.config.search.DispatchConfig; @@ -43,8 +42,6 @@ import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg; import com.yahoo.yolean.Exceptions; import org.junit.jupiter.api.Test; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Map; @@ -72,7 +69,7 @@ public class ContentClusterTest extends ContentBaseTest { @Test void testHierarchicRedundancy() { - ContentCluster cc = parse("" + + ContentCluster cc = parse( "<content version=\"1.0\" id=\"storage\">\n" + " <documents/>" + " <engine>" + @@ -947,8 +944,8 @@ public class ContentClusterTest extends ContentBaseTest { .properties(props); MockRoot root = flavor.isPresent() ? ContentClusterUtils.createMockRoot(new SingleNodeProvisioner(flavor.get()), - Collections.emptyList(), deployStateBuilder) : - ContentClusterUtils.createMockRoot(Collections.emptyList(), deployStateBuilder); + List.of(), deployStateBuilder) : + ContentClusterUtils.createMockRoot(List.of(), deployStateBuilder); ContentCluster cluster = ContentClusterUtils.createCluster(clusterXml, root); root.freezeModelTopology(); cluster.validate(); @@ -1104,8 +1101,8 @@ public class ContentClusterTest extends ContentBaseTest { assertEquals(2, config.cluster().size()); - assertClusterHasBucketSpaceMappings(config, "foo_c", Arrays.asList("bunnies", "hares"), Collections.emptyList()); - assertClusterHasBucketSpaceMappings(config, "bar_c", Collections.emptyList(), Collections.singletonList("rabbits")); + assertClusterHasBucketSpaceMappings(config, "foo_c", List.of("bunnies", "hares"), List.of()); + assertClusterHasBucketSpaceMappings(config, "bar_c", List.of(), List.of("rabbits")); } @Test diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSchemaClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSchemaClusterTest.java index 55ec9f4efe2..8c08b9054a4 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSchemaClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSchemaClusterTest.java @@ -12,7 +12,6 @@ import com.yahoo.vespa.model.content.utils.DocType; import com.yahoo.vespa.model.content.utils.SchemaBuilder; import org.junit.jupiter.api.Test; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import static com.yahoo.config.model.test.TestUtil.joinLines; @@ -60,12 +59,12 @@ public class ContentSchemaClusterTest { private static ContentClusterBuilder createClusterBuilderWithGlobalType() { return new ContentClusterBuilder() - .docTypes(Arrays.asList(DocType.indexGlobal("global"), DocType.index("regular"))); + .docTypes(List.of(DocType.indexGlobal("global"), DocType.index("regular"))); } private static ContentClusterBuilder createClusterBuilderWithOnlyDefaultTypes() { return new ContentClusterBuilder() - .docTypes(Arrays.asList(DocType.index("marve"), DocType.index("fleksnes"))); + .docTypes(List.of(DocType.index("marve"), DocType.index("fleksnes"))); } private static ProtonConfig getProtonConfig(ContentCluster cluster) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java index 6066a27cff5..e671a47b36c 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/GlobalDistributionValidatorTest.java @@ -11,8 +11,6 @@ import java.util.Map; import java.util.Set; import java.util.stream.Stream; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; import static java.util.stream.Collectors.toSet; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -25,7 +23,7 @@ public class GlobalDistributionValidatorTest { @Test void validation_succeeds_on_no_documents() { new GlobalDistributionValidator() - .validate(emptyMap(), emptySet()); + .validate(Map.of(), Set.of()); } @Test diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java index b41d92bd63f..901c307723e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexingAndDocprocRoutingTest.java @@ -21,7 +21,6 @@ import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg; import org.junit.jupiter.api.Test; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -489,7 +488,7 @@ public class IndexingAndDocprocRoutingTest extends ContentBaseTest { private DocprocClusterSpec(String name, DocprocChainSpec ... chains) { this.name = name; - this.chains.addAll(Arrays.asList(chains)); + this.chains.addAll(List.of(chains)); } } @@ -500,7 +499,7 @@ public class IndexingAndDocprocRoutingTest extends ContentBaseTest { private DocprocChainSpec(String name, String ... inherits) { this.name = name; - this.inherits.addAll(Arrays.asList(inherits)); + this.inherits.addAll(List.of(inherits)); } } @@ -542,7 +541,7 @@ public class IndexingAndDocprocRoutingTest extends ContentBaseTest { } public static List<String> generateSchemas(String ... sdNames) { - return generateSchemas(Arrays.asList(sdNames)); + return generateSchemas(List.of(sdNames)); } public static List<String> generateSchemas(List<String> sdNames) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java index a6fa0334668..2fb9a67a9ae 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ReservedDocumentTypeNameValidatorTest.java @@ -4,8 +4,6 @@ package com.yahoo.vespa.model.content; import com.yahoo.documentmodel.NewDocumentType; import org.junit.jupiter.api.Test; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -40,13 +38,13 @@ public class ReservedDocumentTypeNameValidatorTest { @Test void exception_is_not_thrown_on_unreserved_name() { ReservedDocumentTypeNameValidator validator = new ReservedDocumentTypeNameValidator(); - validator.validate(asDocTypeMapping(Collections.singletonList("foo"))); + validator.validate(asDocTypeMapping(List.of("foo"))); } @Test void validation_is_case_insensitive() { ReservedDocumentTypeNameValidator validator = new ReservedDocumentTypeNameValidator(); - Map<String, NewDocumentType> orderedDocTypes = new TreeMap<>(asDocTypeMapping(Arrays.asList("NULL", "True", "anD"))); + Map<String, NewDocumentType> orderedDocTypes = new TreeMap<>(asDocTypeMapping(List.of("NULL", "True", "anD"))); try { validator.validate(orderedDocTypes); fail(); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/TopologicalDocumentTypeSorterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/TopologicalDocumentTypeSorterTest.java index c5a645bd863..06794a3c1f3 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/TopologicalDocumentTypeSorterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/TopologicalDocumentTypeSorterTest.java @@ -5,8 +5,6 @@ import com.yahoo.documentmodel.NewDocumentType; import org.junit.jupiter.api.Test; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -20,24 +18,24 @@ public class TopologicalDocumentTypeSorterTest { @Test void require_that_types_without_references_are_returned_in_input_order() { - assertOrder(Arrays.asList("a"), new DocumentTypesBuilder().add("a")); - assertOrder(Arrays.asList("a", "c", "b"), + assertOrder(List.of("a"), new DocumentTypesBuilder().add("a")); + assertOrder(List.of("a", "c", "b"), new DocumentTypesBuilder().add("a").add("c").add("b")); } @Test void require_that_types_with_references_are_sorted_in_topological_order() { - assertOrder(Arrays.asList("b", "a"), new DocumentTypesBuilder() - .add("a", Arrays.asList("b")) + assertOrder(List.of("b", "a"), new DocumentTypesBuilder() + .add("a", List.of("b")) .add("b")); - assertOrder(Arrays.asList("c", "b", "a"), new DocumentTypesBuilder() - .add("a", Arrays.asList("b", "c")) - .add("b", Arrays.asList("c")) + assertOrder(List.of("c", "b", "a"), new DocumentTypesBuilder() + .add("a", List.of("b", "c")) + .add("b", List.of("c")) .add("c")); - assertOrder(Arrays.asList("b", "a", "d", "c"), new DocumentTypesBuilder() - .add("a", Arrays.asList("b")) + assertOrder(List.of("b", "a", "d", "c"), new DocumentTypesBuilder() + .add("a", List.of("b")) .add("b") - .add("c", Arrays.asList("d")) + .add("c", List.of("d")) .add("d")); } @@ -52,7 +50,7 @@ public class TopologicalDocumentTypeSorterTest { private final List<NewDocumentType> result = new ArrayList<>(); public DocumentTypesBuilder add(String docTypeName) { - return add(docTypeName, Collections.emptyList()); + return add(docTypeName, List.of()); } public DocumentTypesBuilder add(String docTypeName, List<String> docTypeNameReferences) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilderTest.java index 3bd7b7a4c1a..1043ddd2c0b 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/GlobalDistributionBuilderTest.java @@ -6,9 +6,7 @@ import com.yahoo.text.XML; import com.yahoo.vespa.model.builder.xml.dom.ModelElement; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -35,7 +33,7 @@ public class GlobalDistributionBuilderTest { " <document type=\"" + GLOBAL_2.getName() + "\" global=\"true\"/>" + "</documents>"; - Set<NewDocumentType> expectedResult = new HashSet<>(Arrays.asList(GLOBAL_1, GLOBAL_2)); + Set<NewDocumentType> expectedResult = Set.of(GLOBAL_1, GLOBAL_2); Set<NewDocumentType> actualResult = builder.build(new ModelElement(XML.getDocument(documentsElement).getDocumentElement())); assertEquals(expectedResult, actualResult); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterBuilder.java b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterBuilder.java index 61ce5172ceb..277b07023e6 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterBuilder.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterBuilder.java @@ -7,7 +7,6 @@ import com.yahoo.vespa.model.content.cluster.ContentCluster; import java.util.Arrays; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static com.yahoo.config.model.test.TestUtil.joinLines; @@ -21,7 +20,7 @@ public class ContentClusterBuilder { private String name = "mycluster"; private int redundancy = 1; private int searchableCopies = 1; - private List<DocType> docTypes = Arrays.asList(DocType.index("test")); + private List<DocType> docTypes = List.of(DocType.index("test")); private String groupXml = getSimpleGroupXml(); private Optional<String> dispatchXml = Optional.empty(); private Optional<Double> protonDiskLimit = Optional.empty(); @@ -54,8 +53,8 @@ public class ContentClusterBuilder { } public ContentClusterBuilder docTypes(String ... docTypes) { - this.docTypes = Arrays.asList(docTypes).stream(). - map(type -> DocType.index(type)). + this.docTypes = Arrays.stream(docTypes). + map(DocType::index). toList(); return this; } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java index a8c67ebf0a3..360ad19b710 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java @@ -16,7 +16,6 @@ import com.yahoo.vespa.model.admin.monitoring.builder.Metrics; import com.yahoo.vespa.model.content.cluster.ContentCluster; import org.w3c.dom.Document; -import java.util.Collections; import java.util.List; import java.util.Optional; @@ -67,7 +66,7 @@ public class ContentClusterUtils { ConfigModelContext context = ConfigModelContext.create(applicationType, root.getDeployState(), null,null, root, null); - return new ContentCluster.Builder(admin).build(Collections.emptyList(), context, doc.getDocumentElement()); + return new ContentCluster.Builder(admin).build(List.of(), context, doc.getDocumentElement()); } public static ContentCluster createCluster(String clusterXml, List<String> schemas, DeployState.Builder deployStateBuilder) throws Exception { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/DocType.java b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/DocType.java index 3ffb33a47c8..ce05fa27e2e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/DocType.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/DocType.java @@ -1,7 +1,6 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.content.utils; -import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -46,7 +45,7 @@ public class DocType { } public static String listToXml(DocType... docTypes) { - return listToXml(Arrays.asList(docTypes)); + return listToXml(List.of(docTypes)); } public static String listToXml(List<DocType> docTypes) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java index 304f3dc426f..55ad9149a17 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java @@ -38,8 +38,7 @@ public class SchemaBuilder { } public static List<String> createSchemas(String ... docTypes) { - return Arrays.asList(docTypes) - .stream() + return Arrays.stream(docTypes) .map(type -> new SchemaBuilder().name(type).build()) .toList(); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java index f9999a30869..7809a97f85c 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java @@ -41,8 +41,8 @@ public class SchemaClusterTest { SDDocumentType sdt1 = new SDDocumentType("s1"); Schema schema1 = new Schema("s1", MockApplicationPackage.createEmpty()); SDField f1 = new SDField(sdt1, "f1", DataType.STRING); - f1.addAttribute(new Attribute("f1", DataType.STRING)); - f1.setIndexingScript(new ScriptExpression(new StatementExpression(new AttributeExpression("f1")))); + f1.addAttribute(new Attribute(schema1.getName(), f1.getName(), "f1", DataType.STRING)); + f1.setIndexingScript("s1", new ScriptExpression(new StatementExpression(new AttributeExpression("f1")))); sdt1.addField(f1); schema1.addDocument(sdt1); @@ -50,8 +50,8 @@ public class SchemaClusterTest { SDDocumentType sdt2 = new SDDocumentType("s2"); Schema schema2 = new Schema("s2", MockApplicationPackage.createEmpty()); SDField f2 = new SDField(sdt2, "f2", DataType.STRING); - f2.addAttribute(new Attribute("f2", DataType.STRING)); - f2.setIndexingScript(new ScriptExpression(new StatementExpression(new AttributeExpression("f2")))); + f2.addAttribute(new Attribute(schema2.getName(), f2.getName(), "f2", DataType.STRING)); + f2.setIndexingScript("s2", new ScriptExpression(new StatementExpression(new AttributeExpression("f2")))); sdt2.addField(f2); schema2.addDocument(sdt2); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java index 8502bfa92f4..672bba83e87 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java @@ -102,7 +102,7 @@ public class SchemaInfoTestCase { var schemaInfoTester = new SchemaInfoTester(); var schema = schemaInfoTester.createSchema("test"); var field = (SDField)schema.getDocument().addField(new SDField("f1", DataType.STRING)); - var attribute = field.addAttribute(new Attribute("f1Attribute", field.getDataType())); + var attribute = field.addAttribute(new Attribute(schema.getName(), field.getName(), "f1Attribute", field.getDataType())); attribute.getAliases().add("a1"); attribute.getAliases().add("a2"); assertEquals(""" diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaTester.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaTester.java index 7efacd6b5ad..e17db551798 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaTester.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaTester.java @@ -12,7 +12,6 @@ import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -181,7 +180,7 @@ public class SchemaTester { } public static List<String> generateSchemas(String schemaContent, String rankProfile, String ... schemaNames) { - return generateSchemas(schemaContent, rankProfile, Arrays.asList(schemaNames)); + return generateSchemas(schemaContent, rankProfile, List.of(schemaNames)); } public static List<String> generateSchemas(String schemaContent, String rankProfile, List<String> schemaNames) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/ApiConfigModel.java b/config-model/src/test/java/com/yahoo/vespa/model/test/ApiConfigModel.java index 41003f03c0d..b9be56d8d69 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/test/ApiConfigModel.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/test/ApiConfigModel.java @@ -10,7 +10,6 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -50,7 +49,7 @@ public class ApiConfigModel extends ConfigModel { @Override public List<ConfigModelId> handlesElements() { - return Arrays.asList(ConfigModelId.fromName("api")); + return List.of(ConfigModelId.fromName("api")); } @Override diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/SimpleConfigModel.java b/config-model/src/test/java/com/yahoo/vespa/model/test/SimpleConfigModel.java index 61bd3d885f5..d9be865bc7d 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/test/SimpleConfigModel.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/test/SimpleConfigModel.java @@ -10,7 +10,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -20,8 +19,8 @@ import java.util.List; */ public class SimpleConfigModel extends ConfigModel implements TestApi { - private List<SimpleService> simpleServices = new ArrayList<>(); - private List<ParentService> parentServices = new ArrayList<>(); + private final List<SimpleService> simpleServices = new ArrayList<>(); + private final List<ParentService> parentServices = new ArrayList<>(); public SimpleConfigModel(ConfigModelContext modelContext) { super(modelContext); @@ -43,7 +42,7 @@ public class SimpleConfigModel extends ConfigModel implements TestApi { @Override public List<ConfigModelId> handlesElements() { - return Arrays.asList(ConfigModelId.fromName("simple")); + return List.of(ConfigModelId.fromName("simple")); } @Override @@ -54,11 +53,10 @@ public class SimpleConfigModel extends ConfigModel implements TestApi { NodeList childNodes = spec.getChildNodes(); for (int i=0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); - if (! (child instanceof Element)) { + if (! (child instanceof Element e)) { // skip #text and #comment nodes continue; } - Element e = (Element)child; String service = e.getTagName(); if (service.equals("simpleservice")) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/utils/ApplicationPackageUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/test/utils/ApplicationPackageUtils.java index b9bc34688b7..ce373e558ef 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/test/utils/ApplicationPackageUtils.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/test/utils/ApplicationPackageUtils.java @@ -2,7 +2,6 @@ package com.yahoo.vespa.model.test.utils; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -50,7 +49,7 @@ public class ApplicationPackageUtils { } public static List<String> generateSchemas(String ... sdNames) { - return generateSchemas(Arrays.asList(sdNames)); + return generateSchemas(List.of(sdNames)); } public static List<String> generateSchemas(List<String> sdNames) { |