diff --git a/CHANGELOG.md b/CHANGELOG.md index a05e264d9781b..9b2c379f486a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - [Refactor] XContent base classes from xcontent to core library ([#5902](https://github.com/opensearch-project/OpenSearch/pull/5902)) ### Deprecated +- Map, List, and Set in org.opensearch.common.collect ([#6609](https://github.com/opensearch-project/OpenSearch/pull/6609)) ### Removed diff --git a/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/bucket/terms/StringTermsSerializationBenchmark.java b/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/bucket/terms/StringTermsSerializationBenchmark.java index 6d8721ce64090..e49ae187acea7 100644 --- a/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/bucket/terms/StringTermsSerializationBenchmark.java +++ b/benchmarks/src/main/java/org/opensearch/benchmark/search/aggregations/bucket/terms/StringTermsSerializationBenchmark.java @@ -64,9 +64,7 @@ @State(Scope.Benchmark) public class StringTermsSerializationBenchmark { private static final NamedWriteableRegistry REGISTRY = new NamedWriteableRegistry( - org.opensearch.common.collect.List.of( - new NamedWriteableRegistry.Entry(InternalAggregation.class, StringTerms.NAME, StringTerms::new) - ) + List.of(new NamedWriteableRegistry.Entry(InternalAggregation.class, StringTerms.NAME, StringTerms::new)) ); @Param(value = { "1000" }) private int buckets; @@ -75,15 +73,13 @@ public class StringTermsSerializationBenchmark { @Setup public void initResults() { - results = DelayableWriteable.referencing(InternalAggregations.from(org.opensearch.common.collect.List.of(newTerms(true)))); + results = DelayableWriteable.referencing(InternalAggregations.from(List.of(newTerms(true)))); } private StringTerms newTerms(boolean withNested) { List resultBuckets = new ArrayList<>(buckets); for (int i = 0; i < buckets; i++) { - InternalAggregations inner = withNested - ? InternalAggregations.from(org.opensearch.common.collect.List.of(newTerms(false))) - : InternalAggregations.EMPTY; + InternalAggregations inner = withNested ? InternalAggregations.from(List.of(newTerms(false))) : InternalAggregations.EMPTY; resultBuckets.add(new StringTerms.Bucket(new BytesRef("test" + i), i, inner, false, 0, DocValueFormat.RAW)); } return new StringTerms( diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java index b2559e2aa4a1f..3bde19ec7625b 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/IndicesClientIT.java @@ -2031,8 +2031,8 @@ public void testSimulateIndexTemplate() throws Exception { Settings settings = Settings.builder().put("index.number_of_shards", 1).build(); CompressedXContent mappings = new CompressedXContent("{\"properties\":{\"host_name\":{\"type\":\"keyword\"}}}"); AliasMetadata alias = AliasMetadata.builder("alias").writeIndex(true).build(); - Template template = new Template(settings, mappings, org.opensearch.common.collect.Map.of("alias", alias)); - List pattern = org.opensearch.common.collect.List.of("pattern"); + Template template = new Template(settings, mappings, Map.of("alias", alias)); + List pattern = List.of("pattern"); ComposableIndexTemplate indexTemplate = new ComposableIndexTemplate( pattern, template, @@ -2057,7 +2057,7 @@ public void testSimulateIndexTemplate() throws Exception { AliasMetadata simulationAlias = AliasMetadata.builder("simulation-alias").writeIndex(true).build(); ComposableIndexTemplate simulationTemplate = new ComposableIndexTemplate( pattern, - new Template(null, null, org.opensearch.common.collect.Map.of("simulation-alias", simulationAlias)), + new Template(null, null, Map.of("simulation-alias", simulationAlias)), Collections.emptyList(), 2L, 1L, diff --git a/libs/common/src/main/java/org/opensearch/common/collect/List.java b/libs/common/src/main/java/org/opensearch/common/collect/List.java index c28a69a515d35..07cfc2c019856 100644 --- a/libs/common/src/main/java/org/opensearch/common/collect/List.java +++ b/libs/common/src/main/java/org/opensearch/common/collect/List.java @@ -37,10 +37,10 @@ /** * Java 9 List * - * todo: deprecate and remove w/ min jdk upgrade to 11? * * @opensearch.internal */ +@Deprecated(forRemoval = true) public class List { /** diff --git a/libs/common/src/main/java/org/opensearch/common/collect/Map.java b/libs/common/src/main/java/org/opensearch/common/collect/Map.java index a0b8c03d3d3e4..3913c0fd942a4 100644 --- a/libs/common/src/main/java/org/opensearch/common/collect/Map.java +++ b/libs/common/src/main/java/org/opensearch/common/collect/Map.java @@ -35,10 +35,10 @@ /** * Java 9 Map * - * todo: deprecate and remove w/ min jdk upgrade to 11? * * @opensearch.internal */ +@Deprecated(forRemoval = true) public class Map { /** diff --git a/libs/common/src/main/java/org/opensearch/common/collect/Set.java b/libs/common/src/main/java/org/opensearch/common/collect/Set.java index 11d59cead6009..0c3899b2aaacd 100644 --- a/libs/common/src/main/java/org/opensearch/common/collect/Set.java +++ b/libs/common/src/main/java/org/opensearch/common/collect/Set.java @@ -37,10 +37,10 @@ /** * Java 9 Set * - * todo: deprecate and remove w/ min jdk upgrade to 11? * * @opensearch.internal */ +@Deprecated(forRemoval = true) public class Set { /** diff --git a/libs/common/src/test/java/org/opensearch/common/collect/ListTests.java b/libs/common/src/test/java/org/opensearch/common/collect/ListTests.java deleted file mode 100644 index 70841a102b783..0000000000000 --- a/libs/common/src/test/java/org/opensearch/common/collect/ListTests.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.common.collect; - -import org.opensearch.test.OpenSearchTestCase; - -import java.util.Arrays; -import java.util.Collection; - -import static org.hamcrest.CoreMatchers.equalTo; - -public class ListTests extends OpenSearchTestCase { - - public void testStringListOfZero() { - final String[] strings = {}; - final java.util.List stringsList = List.of(strings); - assertThat(stringsList.size(), equalTo(strings.length)); - assertTrue(stringsList.containsAll(Arrays.asList(strings))); - expectThrows(UnsupportedOperationException.class, () -> stringsList.add("foo")); - } - - public void testStringListOfOne() { - final String[] strings = { "foo" }; - final java.util.List stringsList = List.of(strings); - assertThat(stringsList.size(), equalTo(strings.length)); - assertTrue(stringsList.containsAll(Arrays.asList(strings))); - expectThrows(UnsupportedOperationException.class, () -> stringsList.add("foo")); - } - - public void testStringListOfTwo() { - final String[] strings = { "foo", "bar" }; - final java.util.List stringsList = List.of(strings); - assertThat(stringsList.size(), equalTo(strings.length)); - assertTrue(stringsList.containsAll(Arrays.asList(strings))); - expectThrows(UnsupportedOperationException.class, () -> stringsList.add("foo")); - } - - public void testStringListOfN() { - final String[] strings = { "foo", "bar", "baz" }; - final java.util.List stringsList = List.of(strings); - assertThat(stringsList.size(), equalTo(strings.length)); - assertTrue(stringsList.containsAll(Arrays.asList(strings))); - expectThrows(UnsupportedOperationException.class, () -> stringsList.add("foo")); - } - - public void testCopyOf() { - final Collection coll = Arrays.asList("foo", "bar", "baz"); - final java.util.List copy = List.copyOf(coll); - assertThat(coll.size(), equalTo(copy.size())); - assertTrue(copy.containsAll(coll)); - expectThrows(UnsupportedOperationException.class, () -> copy.add("foo")); - } -} diff --git a/libs/common/src/test/java/org/opensearch/common/collect/MapTests.java b/libs/common/src/test/java/org/opensearch/common/collect/MapTests.java deleted file mode 100644 index 8d7ffa71df562..0000000000000 --- a/libs/common/src/test/java/org/opensearch/common/collect/MapTests.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.common.collect; - -import org.opensearch.test.OpenSearchTestCase; - -import static org.hamcrest.CoreMatchers.equalTo; - -public class MapTests extends OpenSearchTestCase { - - private static final String[] numbers = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; - - public void testMapOfZero() { - final java.util.Map map = Map.of(); - validateMapContents(map, 0); - } - - public void testMapOfOne() { - final java.util.Map map = Map.of(numbers[0], 0); - validateMapContents(map, 1); - } - - public void testMapOfTwo() { - final java.util.Map map = Map.of(numbers[0], 0, numbers[1], 1); - validateMapContents(map, 2); - } - - public void testMapOfThree() { - final java.util.Map map = Map.of(numbers[0], 0, numbers[1], 1, numbers[2], 2); - validateMapContents(map, 3); - } - - public void testMapOfFour() { - final java.util.Map map = Map.of(numbers[0], 0, numbers[1], 1, numbers[2], 2, numbers[3], 3); - validateMapContents(map, 4); - } - - public void testMapOfFive() { - final java.util.Map map = Map.of(numbers[0], 0, numbers[1], 1, numbers[2], 2, numbers[3], 3, numbers[4], 4); - validateMapContents(map, 5); - } - - public void testMapOfSix() { - final java.util.Map map = Map.of( - numbers[0], - 0, - numbers[1], - 1, - numbers[2], - 2, - numbers[3], - 3, - numbers[4], - 4, - numbers[5], - 5 - ); - validateMapContents(map, 6); - } - - public void testMapOfSeven() { - final java.util.Map map = Map.of( - numbers[0], - 0, - numbers[1], - 1, - numbers[2], - 2, - numbers[3], - 3, - numbers[4], - 4, - numbers[5], - 5, - numbers[6], - 6 - ); - validateMapContents(map, 7); - } - - public void testMapOfEight() { - final java.util.Map map = Map.of( - numbers[0], - 0, - numbers[1], - 1, - numbers[2], - 2, - numbers[3], - 3, - numbers[4], - 4, - numbers[5], - 5, - numbers[6], - 6, - numbers[7], - 7 - ); - validateMapContents(map, 8); - } - - public void testMapOfNine() { - final java.util.Map map = Map.of( - numbers[0], - 0, - numbers[1], - 1, - numbers[2], - 2, - numbers[3], - 3, - numbers[4], - 4, - numbers[5], - 5, - numbers[6], - 6, - numbers[7], - 7, - numbers[8], - 8 - ); - validateMapContents(map, 9); - } - - public void testMapOfTen() { - final java.util.Map map = Map.of( - numbers[0], - 0, - numbers[1], - 1, - numbers[2], - 2, - numbers[3], - 3, - numbers[4], - 4, - numbers[5], - 5, - numbers[6], - 6, - numbers[7], - 7, - numbers[8], - 8, - numbers[9], - 9 - ); - validateMapContents(map, 10); - } - - private static void validateMapContents(java.util.Map map, int size) { - assertThat(map.size(), equalTo(size)); - for (int k = 0; k < map.size(); k++) { - assertEquals(Integer.class, map.get(numbers[k]).getClass()); - assertThat(k, equalTo(map.get(numbers[k]))); - } - expectThrows(UnsupportedOperationException.class, () -> map.put("foo", 42)); - } - - public void testOfEntries() { - final java.util.Map map = Map.ofEntries( - Map.entry(numbers[0], 0), - Map.entry(numbers[1], 1), - Map.entry(numbers[2], 2) - ); - validateMapContents(map, 3); - } - - public void testCopyOf() { - final java.util.Map map1 = Map.of("fooK", "fooV", "barK", "barV", "bazK", "bazV"); - final java.util.Map copy = Map.copyOf(map1); - assertThat(map1.size(), equalTo(copy.size())); - for (java.util.Map.Entry entry : map1.entrySet()) { - assertEquals(entry.getValue(), copy.get(entry.getKey())); - } - expectThrows(UnsupportedOperationException.class, () -> copy.put("foo", "bar")); - } -} diff --git a/libs/common/src/test/java/org/opensearch/common/collect/SetTests.java b/libs/common/src/test/java/org/opensearch/common/collect/SetTests.java deleted file mode 100644 index 1b7f29ff0d6f1..0000000000000 --- a/libs/common/src/test/java/org/opensearch/common/collect/SetTests.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.common.collect; - -import org.opensearch.test.OpenSearchTestCase; - -import java.util.Arrays; -import java.util.Collection; - -import static org.hamcrest.CoreMatchers.equalTo; - -public class SetTests extends OpenSearchTestCase { - - public void testStringSetOfZero() { - final String[] strings = {}; - final java.util.Set stringsSet = Set.of(strings); - assertThat(stringsSet.size(), equalTo(strings.length)); - assertTrue(stringsSet.containsAll(Arrays.asList(strings))); - expectThrows(UnsupportedOperationException.class, () -> stringsSet.add("foo")); - } - - public void testStringSetOfOne() { - final String[] strings = { "foo" }; - final java.util.Set stringsSet = Set.of(strings); - assertThat(stringsSet.size(), equalTo(strings.length)); - assertTrue(stringsSet.containsAll(Arrays.asList(strings))); - expectThrows(UnsupportedOperationException.class, () -> stringsSet.add("foo")); - } - - public void testStringSetOfTwo() { - final String[] strings = { "foo", "bar" }; - final java.util.Set stringsSet = Set.of(strings); - assertThat(stringsSet.size(), equalTo(strings.length)); - assertTrue(stringsSet.containsAll(Arrays.asList(strings))); - expectThrows(UnsupportedOperationException.class, () -> stringsSet.add("foo")); - } - - public void testStringSetOfN() { - final String[] strings = { "foo", "bar", "baz" }; - final java.util.Set stringsSet = Set.of(strings); - assertThat(stringsSet.size(), equalTo(strings.length)); - assertTrue(stringsSet.containsAll(Arrays.asList(strings))); - expectThrows(UnsupportedOperationException.class, () -> stringsSet.add("foo")); - } - - public void testCopyOf() { - final Collection coll = Arrays.asList("foo", "bar", "baz"); - final java.util.Set copy = Set.copyOf(coll); - assertThat(coll.size(), equalTo(copy.size())); - assertTrue(copy.containsAll(coll)); - expectThrows(UnsupportedOperationException.class, () -> copy.add("foo")); - } -} diff --git a/libs/grok/src/test/java/org/opensearch/grok/GrokTests.java b/libs/grok/src/test/java/org/opensearch/grok/GrokTests.java index ed48585cc124a..bdcde57f91bb3 100644 --- a/libs/grok/src/test/java/org/opensearch/grok/GrokTests.java +++ b/libs/grok/src/test/java/org/opensearch/grok/GrokTests.java @@ -65,20 +65,20 @@ public class GrokTests extends OpenSearchTestCase { public void testMatchWithoutCaptures() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "value", logger::warn); - assertThat(grok.captures("value"), equalTo(org.opensearch.common.collect.Map.of())); - assertThat(grok.captures("prefix_value"), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(grok.captures("value"), equalTo(Map.of())); + assertThat(grok.captures("prefix_value"), equalTo(Map.of())); assertThat(grok.captures("no_match"), nullValue()); } public void testCaputuresBytes() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{NUMBER:n:int}", logger::warn); byte[] utf8 = "10".getBytes(StandardCharsets.UTF_8); - assertThat(captureBytes(grok, utf8, 0, utf8.length), equalTo(org.opensearch.common.collect.Map.of("n", 10))); - assertThat(captureBytes(grok, utf8, 0, 1), equalTo(org.opensearch.common.collect.Map.of("n", 1))); + assertThat(captureBytes(grok, utf8, 0, utf8.length), equalTo(Map.of("n", 10))); + assertThat(captureBytes(grok, utf8, 0, 1), equalTo(Map.of("n", 1))); utf8 = "10 11 12".getBytes(StandardCharsets.UTF_8); - assertThat(captureBytes(grok, utf8, 0, 2), equalTo(org.opensearch.common.collect.Map.of("n", 10))); - assertThat(captureBytes(grok, utf8, 3, 2), equalTo(org.opensearch.common.collect.Map.of("n", 11))); - assertThat(captureBytes(grok, utf8, 6, 2), equalTo(org.opensearch.common.collect.Map.of("n", 12))); + assertThat(captureBytes(grok, utf8, 0, 2), equalTo(Map.of("n", 10))); + assertThat(captureBytes(grok, utf8, 3, 2), equalTo(Map.of("n", 11))); + assertThat(captureBytes(grok, utf8, 6, 2), equalTo(Map.of("n", 12))); } private Map captureBytes(Grok grok, byte[] utf8, int offset, int length) { @@ -99,15 +99,15 @@ public void testSimpleSyslogLine() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{SYSLOGLINE}", logger::warn); assertCaptureConfig( grok, - org.opensearch.common.collect.Map.ofEntries( - org.opensearch.common.collect.Map.entry("facility", STRING), - org.opensearch.common.collect.Map.entry("logsource", STRING), - org.opensearch.common.collect.Map.entry("message", STRING), - org.opensearch.common.collect.Map.entry("pid", STRING), - org.opensearch.common.collect.Map.entry("priority", STRING), - org.opensearch.common.collect.Map.entry("program", STRING), - org.opensearch.common.collect.Map.entry("timestamp", STRING), - org.opensearch.common.collect.Map.entry("timestamp8601", STRING) + Map.ofEntries( + Map.entry("facility", STRING), + Map.entry("logsource", STRING), + Map.entry("message", STRING), + Map.entry("pid", STRING), + Map.entry("priority", STRING), + Map.entry("program", STRING), + Map.entry("timestamp", STRING), + Map.entry("timestamp8601", STRING) ) ); Map matches = grok.captures(line); @@ -134,16 +134,16 @@ public void testSyslog5424Line() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{SYSLOG5424LINE}", logger::warn); assertCaptureConfig( grok, - org.opensearch.common.collect.Map.ofEntries( - org.opensearch.common.collect.Map.entry("syslog5424_app", STRING), - org.opensearch.common.collect.Map.entry("syslog5424_host", STRING), - org.opensearch.common.collect.Map.entry("syslog5424_msg", STRING), - org.opensearch.common.collect.Map.entry("syslog5424_msgid", STRING), - org.opensearch.common.collect.Map.entry("syslog5424_pri", STRING), - org.opensearch.common.collect.Map.entry("syslog5424_proc", STRING), - org.opensearch.common.collect.Map.entry("syslog5424_sd", STRING), - org.opensearch.common.collect.Map.entry("syslog5424_ts", STRING), - org.opensearch.common.collect.Map.entry("syslog5424_ver", STRING) + Map.ofEntries( + Map.entry("syslog5424_app", STRING), + Map.entry("syslog5424_host", STRING), + Map.entry("syslog5424_msg", STRING), + Map.entry("syslog5424_msgid", STRING), + Map.entry("syslog5424_pri", STRING), + Map.entry("syslog5424_proc", STRING), + Map.entry("syslog5424_sd", STRING), + Map.entry("syslog5424_ts", STRING), + Map.entry("syslog5424_ver", STRING) ) ); Map matches = grok.captures(line); @@ -161,14 +161,14 @@ public void testSyslog5424Line() { public void testDatePattern() { String line = "fancy 12-12-12 12:12:12"; Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "(?%{DATE_EU} %{TIME})", logger::warn); - assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("timestamp", STRING)); + assertCaptureConfig(grok, Map.of("timestamp", STRING)); Map matches = grok.captures(line); assertEquals("12-12-12 12:12:12", matches.get("timestamp")); } public void testNilCoercedValues() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "test (N/A|%{BASE10NUM:duration:float}ms)", logger::warn); - assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("duration", FLOAT)); + assertCaptureConfig(grok, Map.of("duration", FLOAT)); Map matches = grok.captures("test 28.4ms"); assertEquals(28.4f, matches.get("duration")); matches = grok.captures("test N/A"); @@ -177,7 +177,7 @@ public void testNilCoercedValues() { public void testNilWithNoCoercion() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "test (N/A|%{BASE10NUM:duration}ms)", logger::warn); - assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("duration", STRING)); + assertCaptureConfig(grok, Map.of("duration", STRING)); Map matches = grok.captures("test 28.4ms"); assertEquals("28.4", matches.get("duration")); matches = grok.captures("test N/A"); @@ -194,13 +194,13 @@ public void testUnicodeSyslog() { ); assertCaptureConfig( grok, - org.opensearch.common.collect.Map.ofEntries( - org.opensearch.common.collect.Map.entry("syslog_hostname", STRING), - org.opensearch.common.collect.Map.entry("syslog_message", STRING), - org.opensearch.common.collect.Map.entry("syslog_pid", STRING), - org.opensearch.common.collect.Map.entry("syslog_pri", STRING), - org.opensearch.common.collect.Map.entry("syslog_program", STRING), - org.opensearch.common.collect.Map.entry("syslog_timestamp", STRING) + Map.ofEntries( + Map.entry("syslog_hostname", STRING), + Map.entry("syslog_message", STRING), + Map.entry("syslog_pid", STRING), + Map.entry("syslog_pri", STRING), + Map.entry("syslog_program", STRING), + Map.entry("syslog_timestamp", STRING) ) ); Map matches = grok.captures( @@ -215,21 +215,21 @@ public void testUnicodeSyslog() { public void testNamedFieldsWithWholeTextMatch() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{DATE_EU:stimestamp}", logger::warn); - assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("stimestamp", STRING)); + assertCaptureConfig(grok, Map.of("stimestamp", STRING)); Map matches = grok.captures("11/01/01"); assertThat(matches.get("stimestamp"), equalTo("11/01/01")); } public void testWithOniguramaNamedCaptures() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "(?\\w+)", logger::warn); - assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("foo", STRING)); + assertCaptureConfig(grok, Map.of("foo", STRING)); Map matches = grok.captures("hello world"); assertThat(matches.get("foo"), equalTo("hello")); } public void testISO8601() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "^%{TIMESTAMP_ISO8601}$", logger::warn); - assertCaptureConfig(grok, org.opensearch.common.collect.Map.of()); + assertCaptureConfig(grok, Map.of()); List timeMessages = Arrays.asList( "2001-01-01T00:00:00", "1974-03-02T04:09:09", @@ -254,7 +254,7 @@ public void testISO8601() { public void testNotISO8601() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "^%{TIMESTAMP_ISO8601}$", logger::warn); - assertCaptureConfig(grok, org.opensearch.common.collect.Map.of()); + assertCaptureConfig(grok, Map.of()); List timeMessages = Arrays.asList( "2001-13-01T00:00:00", // invalid month "2001-00-01T00:00:00", // invalid month @@ -294,7 +294,7 @@ public void testNoNamedCaptures() { String text = "wowza !!!Tal!!! - Tal"; String pattern = "%{EXCITED_NAME} - %{NAME}"; Grok g = new Grok(bank, pattern, false, logger::warn); - assertCaptureConfig(g, org.opensearch.common.collect.Map.of("EXCITED_NAME_0", STRING, "NAME_21", STRING, "NAME_22", STRING)); + assertCaptureConfig(g, Map.of("EXCITED_NAME_0", STRING, "NAME_21", STRING, "NAME_22", STRING)); assertEquals("(?!!!(?Tal)!!!) - (?Tal)", g.toRegex(pattern)); assertEquals(true, g.match(text)); @@ -400,7 +400,7 @@ public void testMalformedPattern() { public void testBooleanCaptures() { String pattern = "%{WORD:name}=%{WORD:status:boolean}"; Grok g = new Grok(Grok.BUILTIN_PATTERNS, pattern, logger::warn); - assertCaptureConfig(g, org.opensearch.common.collect.Map.of("name", STRING, "status", BOOLEAN)); + assertCaptureConfig(g, Map.of("name", STRING, "status", BOOLEAN)); String text = "active=true"; Map expected = new HashMap<>(); @@ -428,7 +428,7 @@ public void testNumericCaptures() { String pattern = "%{NUMBER:bytes:float} %{NUMBER:id:long} %{NUMBER:rating:double}"; Grok g = new Grok(bank, pattern, logger::warn); - assertCaptureConfig(g, org.opensearch.common.collect.Map.of("bytes", FLOAT, "id", LONG, "rating", DOUBLE)); + assertCaptureConfig(g, Map.of("bytes", FLOAT, "id", LONG, "rating", DOUBLE)); String text = "12009.34 20000000000 4820.092"; Map expected = new HashMap<>(); @@ -476,7 +476,7 @@ public void testNumericCapturesCoercion() { String pattern = "%{NUMBER:bytes:float} %{NUMBER:status} %{NUMBER}"; Grok g = new Grok(bank, pattern, logger::warn); - assertCaptureConfig(g, org.opensearch.common.collect.Map.of("bytes", FLOAT, "status", STRING)); + assertCaptureConfig(g, Map.of("bytes", FLOAT, "status", STRING)); String text = "12009.34 200 9032"; Map expected = new HashMap<>(); @@ -494,8 +494,8 @@ public void testGarbageTypeNameBecomesString() { String pattern = "%{NUMBER:f:not_a_valid_type}"; Grok g = new Grok(bank, pattern, logger::warn); - assertCaptureConfig(g, org.opensearch.common.collect.Map.of("f", STRING)); - assertThat(g.captures("12009.34"), equalTo(org.opensearch.common.collect.Map.of("f", "12009.34"))); + assertCaptureConfig(g, Map.of("f", STRING)); + assertThat(g.captures("12009.34"), equalTo(Map.of("f", "12009.34"))); } public void testApacheLog() { @@ -505,19 +505,19 @@ public void testApacheLog() { Grok grok = new Grok(Grok.BUILTIN_PATTERNS, "%{COMBINEDAPACHELOG}", logger::warn); assertCaptureConfig( grok, - org.opensearch.common.collect.Map.ofEntries( - org.opensearch.common.collect.Map.entry("agent", STRING), - org.opensearch.common.collect.Map.entry("auth", STRING), - org.opensearch.common.collect.Map.entry("bytes", STRING), - org.opensearch.common.collect.Map.entry("clientip", STRING), - org.opensearch.common.collect.Map.entry("httpversion", STRING), - org.opensearch.common.collect.Map.entry("ident", STRING), - org.opensearch.common.collect.Map.entry("rawrequest", STRING), - org.opensearch.common.collect.Map.entry("referrer", STRING), - org.opensearch.common.collect.Map.entry("request", STRING), - org.opensearch.common.collect.Map.entry("response", STRING), - org.opensearch.common.collect.Map.entry("timestamp", STRING), - org.opensearch.common.collect.Map.entry("verb", STRING) + Map.ofEntries( + Map.entry("agent", STRING), + Map.entry("auth", STRING), + Map.entry("bytes", STRING), + Map.entry("clientip", STRING), + Map.entry("httpversion", STRING), + Map.entry("ident", STRING), + Map.entry("rawrequest", STRING), + Map.entry("referrer", STRING), + Map.entry("request", STRING), + Map.entry("response", STRING), + Map.entry("timestamp", STRING), + Map.entry("verb", STRING) ) ); Map matches = grok.captures(logLine); @@ -594,18 +594,18 @@ public void testComplete() { Grok grok = new Grok(bank, pattern, logger::warn); assertCaptureConfig( grok, - org.opensearch.common.collect.Map.ofEntries( - org.opensearch.common.collect.Map.entry("agent", STRING), - org.opensearch.common.collect.Map.entry("auth", STRING), - org.opensearch.common.collect.Map.entry("bytes", INTEGER), - org.opensearch.common.collect.Map.entry("clientip", STRING), - org.opensearch.common.collect.Map.entry("httpversion", STRING), - org.opensearch.common.collect.Map.entry("ident", STRING), - org.opensearch.common.collect.Map.entry("referrer", STRING), - org.opensearch.common.collect.Map.entry("request", STRING), - org.opensearch.common.collect.Map.entry("response", INTEGER), - org.opensearch.common.collect.Map.entry("timestamp", STRING), - org.opensearch.common.collect.Map.entry("verb", STRING) + Map.ofEntries( + Map.entry("agent", STRING), + Map.entry("auth", STRING), + Map.entry("bytes", INTEGER), + Map.entry("clientip", STRING), + Map.entry("httpversion", STRING), + Map.entry("ident", STRING), + Map.entry("referrer", STRING), + Map.entry("request", STRING), + Map.entry("response", INTEGER), + Map.entry("timestamp", STRING), + Map.entry("verb", STRING) ) ); @@ -642,7 +642,7 @@ public void testMultipleNamedCapturesWithSameName() { Map bank = new HashMap<>(); bank.put("SINGLEDIGIT", "[0-9]"); Grok grok = new Grok(bank, "%{SINGLEDIGIT:num}%{SINGLEDIGIT:num}", logger::warn); - assertCaptureConfig(grok, org.opensearch.common.collect.Map.of("num", STRING)); + assertCaptureConfig(grok, Map.of("num", STRING)); Map expected = new HashMap<>(); expected.put("num", "1"); diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java index 7caa63792f347..1cb1ad7e408f6 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java @@ -203,7 +203,7 @@ public void testAppendingUniqueValueToScalar() throws Exception { appendProcessor.execute(ingestDocument); List list = ingestDocument.getFieldValue(field, List.class); assertThat(list.size(), equalTo(2)); - assertThat(list, equalTo(org.opensearch.common.collect.List.of(originalValue, newValue))); + assertThat(list, equalTo(List.of(originalValue, newValue))); } public void testAppendingToListWithDuplicatesDisallowed() throws Exception { diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/ForEachProcessorTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/ForEachProcessorTests.java index f49d5492a09b3..241945e58fa06 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/ForEachProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/ForEachProcessorTests.java @@ -226,12 +226,8 @@ public void testModifyFieldsOutsideArray() throws Exception { "values", new CompoundProcessor( false, - org.opensearch.common.collect.List.of( - new UppercaseProcessor("_tag_upper", null, "_ingest._value", false, "_ingest._value") - ), - org.opensearch.common.collect.List.of( - new AppendProcessor("_tag", null, template, (model) -> (Collections.singletonList("added")), true) - ) + List.of(new UppercaseProcessor("_tag_upper", null, "_ingest._value", false, "_ingest._value")), + List.of(new AppendProcessor("_tag", null, template, (model) -> (Collections.singletonList("added")), true)) ), false ); diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java index ab8b105bc6620..db8c04cca7c80 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/GrokProcessorGetActionTests.java @@ -57,7 +57,7 @@ import static org.mockito.Mockito.mock; public class GrokProcessorGetActionTests extends OpenSearchTestCase { - private static final Map TEST_PATTERNS = org.opensearch.common.collect.Map.of("PATTERN2", "foo2", "PATTERN1", "foo1"); + private static final Map TEST_PATTERNS = Map.of("PATTERN2", "foo2", "PATTERN1", "foo1"); public void testRequest() throws Exception { GrokProcessorGetAction.Request request = new GrokProcessorGetAction.Request(false); diff --git a/modules/mapper-extras/src/main/java/org/opensearch/index/mapper/TokenCountFieldMapper.java b/modules/mapper-extras/src/main/java/org/opensearch/index/mapper/TokenCountFieldMapper.java index fd029503e9a7b..1851afcf0af85 100644 --- a/modules/mapper-extras/src/main/java/org/opensearch/index/mapper/TokenCountFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/opensearch/index/mapper/TokenCountFieldMapper.java @@ -122,7 +122,7 @@ static class TokenCountFieldType extends NumberFieldMapper.NumberFieldType { @Override public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) { if (hasDocValues() == false) { - return lookup -> org.opensearch.common.collect.List.of(); + return lookup -> List.of(); } return new DocValueFetcher(docValueFormat(format, null), searchLookup.doc().getForField(this)); } diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureFieldMapperTests.java index b86c38dc22cd4..6412059075e5c 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeatureFieldMapperTests.java @@ -39,13 +39,13 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.opensearch.common.Strings; -import org.opensearch.common.collect.List; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.plugins.Plugin; import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.List; import static org.hamcrest.Matchers.instanceOf; diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeaturesFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeaturesFieldMapperTests.java index 2d1d9540b49d3..6c844bae73da4 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeaturesFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/RankFeaturesFieldMapperTests.java @@ -42,6 +42,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.List; public class RankFeaturesFieldMapperTests extends MapperTestCase { @@ -58,7 +59,7 @@ protected void assertExistsQuery(MapperService mapperService) { @Override protected Collection getPlugins() { - return org.opensearch.common.collect.List.of(new MapperExtrasModulePlugin()); + return List.of(new MapperExtrasModulePlugin()); } @Override diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldMapperTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldMapperTests.java index 01f989c2f84f5..5e67aaa2ed246 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldMapperTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldMapperTests.java @@ -76,6 +76,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -134,7 +135,7 @@ protected void writeFieldValue(XContentBuilder builder) throws IOException { @Override protected Collection getPlugins() { - return org.opensearch.common.collect.List.of(new MapperExtrasModulePlugin()); + return List.of(new MapperExtrasModulePlugin()); } @Override @@ -150,20 +151,9 @@ protected IndexAnalyzers createIndexAnalyzers(IndexSettings indexSettings) { NamedAnalyzer simple = new NamedAnalyzer("simple", AnalyzerScope.INDEX, new SimpleAnalyzer()); NamedAnalyzer whitespace = new NamedAnalyzer("whitespace", AnalyzerScope.INDEX, new WhitespaceAnalyzer()); return new IndexAnalyzers( - org.opensearch.common.collect.Map.of( - "default", - dflt, - "standard", - standard, - "keyword", - keyword, - "simple", - simple, - "whitespace", - whitespace - ), - org.opensearch.common.collect.Map.of(), - org.opensearch.common.collect.Map.of() + Map.of("default", dflt, "standard", standard, "keyword", keyword, "simple", simple, "whitespace", whitespace), + Map.of(), + Map.of() ); } diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldTypeTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldTypeTests.java index 1998465318c2b..77e34560d4cad 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldTypeTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/mapper/SearchAsYouTypeFieldTypeTests.java @@ -49,6 +49,7 @@ import java.io.IOException; import java.util.Collections; +import java.util.List; import static java.util.Arrays.asList; import static org.apache.lucene.search.MultiTermQuery.CONSTANT_SCORE_REWRITE; @@ -154,9 +155,9 @@ public void testFetchSourceValue() throws IOException { SearchAsYouTypeFieldType fieldType = createFieldType(); fieldType.setIndexAnalyzer(Lucene.STANDARD_ANALYZER); - assertEquals(org.opensearch.common.collect.List.of("value"), fetchSourceValue(fieldType, "value")); - assertEquals(org.opensearch.common.collect.List.of("42"), fetchSourceValue(fieldType, 42L)); - assertEquals(org.opensearch.common.collect.List.of("true"), fetchSourceValue(fieldType, true)); + assertEquals(List.of("value"), fetchSourceValue(fieldType, "value")); + assertEquals(List.of("42"), fetchSourceValue(fieldType, 42L)); + assertEquals(List.of("true"), fetchSourceValue(fieldType, true)); SearchAsYouTypeFieldMapper.PrefixFieldType prefixFieldType = new SearchAsYouTypeFieldMapper.PrefixFieldType( fieldType.name(), @@ -164,17 +165,17 @@ public void testFetchSourceValue() throws IOException { 2, 10 ); - assertEquals(org.opensearch.common.collect.List.of("value"), fetchSourceValue(prefixFieldType, "value")); - assertEquals(org.opensearch.common.collect.List.of("42"), fetchSourceValue(prefixFieldType, 42L)); - assertEquals(org.opensearch.common.collect.List.of("true"), fetchSourceValue(prefixFieldType, true)); + assertEquals(List.of("value"), fetchSourceValue(prefixFieldType, "value")); + assertEquals(List.of("42"), fetchSourceValue(prefixFieldType, 42L)); + assertEquals(List.of("true"), fetchSourceValue(prefixFieldType, true)); SearchAsYouTypeFieldMapper.ShingleFieldType shingleFieldType = new SearchAsYouTypeFieldMapper.ShingleFieldType( fieldType.name(), 5, fieldType.getTextSearchInfo() ); - assertEquals(org.opensearch.common.collect.List.of("value"), fetchSourceValue(shingleFieldType, "value")); - assertEquals(org.opensearch.common.collect.List.of("42"), fetchSourceValue(shingleFieldType, 42L)); - assertEquals(org.opensearch.common.collect.List.of("true"), fetchSourceValue(shingleFieldType, true)); + assertEquals(List.of("value"), fetchSourceValue(shingleFieldType, "value")); + assertEquals(List.of("42"), fetchSourceValue(shingleFieldType, 42L)); + assertEquals(List.of("true"), fetchSourceValue(shingleFieldType, true)); } } diff --git a/plugins/analysis-icu/src/test/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperTests.java b/plugins/analysis-icu/src/test/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperTests.java index 26b6292d2d7c7..37cb73e21b5d4 100644 --- a/plugins/analysis-icu/src/test/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperTests.java +++ b/plugins/analysis-icu/src/test/java/org/opensearch/index/mapper/ICUCollationKeywordFieldMapperTests.java @@ -40,7 +40,6 @@ import org.apache.lucene.index.IndexableFieldType; import org.apache.lucene.util.BytesRef; import org.opensearch.common.Strings; -import org.opensearch.common.collect.List; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.plugin.analysis.icu.AnalysisICUPlugin; import org.opensearch.plugins.Plugin; @@ -48,6 +47,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.Set; import static org.hamcrest.Matchers.containsString; @@ -69,7 +69,7 @@ protected ICUCollationKeywordFieldMapper.Builder newBuilder() { @Override protected Set unsupportedProperties() { - return org.opensearch.common.collect.Set.of("analyzer", "similarity"); + return Set.of("analyzer", "similarity"); } @Override diff --git a/plugins/mapper-murmur3/src/test/java/org/opensearch/index/mapper/murmur3/Murmur3FieldMapperTests.java b/plugins/mapper-murmur3/src/test/java/org/opensearch/index/mapper/murmur3/Murmur3FieldMapperTests.java index c161128d4d3e9..04d46db50592c 100644 --- a/plugins/mapper-murmur3/src/test/java/org/opensearch/index/mapper/murmur3/Murmur3FieldMapperTests.java +++ b/plugins/mapper-murmur3/src/test/java/org/opensearch/index/mapper/murmur3/Murmur3FieldMapperTests.java @@ -45,6 +45,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.List; public class Murmur3FieldMapperTests extends MapperTestCase { @@ -55,7 +56,7 @@ protected void writeFieldValue(XContentBuilder builder) throws IOException { @Override protected Collection getPlugins() { - return org.opensearch.common.collect.List.of(new MapperMurmur3Plugin()); + return List.of(new MapperMurmur3Plugin()); } @Override diff --git a/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobStore.java b/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobStore.java index b540dd83c95a2..060ffdda79196 100644 --- a/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobStore.java +++ b/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureBlobStore.java @@ -442,7 +442,7 @@ private static class Stats { private final AtomicLong putBlockListOperations = new AtomicLong(); private Map toMap() { - return org.opensearch.common.collect.Map.of( + return Map.of( "GetBlob", getOperations.get(), "ListBlobs", diff --git a/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureRepository.java b/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureRepository.java index c20ca491edd43..3bcc54a359f3f 100644 --- a/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureRepository.java +++ b/plugins/repository-azure/src/main/java/org/opensearch/repositories/azure/AzureRepository.java @@ -150,7 +150,7 @@ public AzureRepository( } private static Map buildLocation(RepositoryMetadata metadata) { - return org.opensearch.common.collect.Map.of( + return Map.of( "base_path", Repository.BASE_PATH_SETTING.get(metadata.settings()), "container", diff --git a/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageHttpStatsCollector.java b/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageHttpStatsCollector.java index 7375d4edb9030..2f48de94a4830 100644 --- a/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageHttpStatsCollector.java +++ b/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageHttpStatsCollector.java @@ -36,8 +36,8 @@ import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpResponse; import com.google.api.client.http.HttpResponseInterceptor; -import org.opensearch.common.collect.List; +import java.util.List; import java.util.Locale; import java.util.function.Consumer; import java.util.function.Function; diff --git a/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRepository.java b/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRepository.java index 43d4253f2cd9a..0d6d246f0bcba 100644 --- a/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRepository.java +++ b/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRepository.java @@ -115,12 +115,7 @@ class GoogleCloudStorageRepository extends MeteredBlobStoreRepository { } private static Map buildLocation(RepositoryMetadata metadata) { - return org.opensearch.common.collect.Map.of( - "base_path", - BASE_PATH.get(metadata.settings()), - "bucket", - getSetting(BUCKET, metadata) - ); + return Map.of("base_path", BASE_PATH.get(metadata.settings()), "bucket", getSetting(BUCKET, metadata)); } @Override diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java index 41e0fb2231bd3..8094817035845 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java @@ -278,12 +278,7 @@ class S3Repository extends MeteredBlobStoreRepository { } private static Map buildLocation(RepositoryMetadata metadata) { - return org.opensearch.common.collect.Map.of( - "base_path", - BASE_PATH_SETTING.get(metadata.settings()), - "bucket", - BUCKET_SETTING.get(metadata.settings()) - ); + return Map.of("base_path", BASE_PATH_SETTING.get(metadata.settings()), "bucket", BUCKET_SETTING.get(metadata.settings())); } /** diff --git a/qa/os/src/test/java/org/opensearch/packaging/test/ArchiveTests.java b/qa/os/src/test/java/org/opensearch/packaging/test/ArchiveTests.java index 898ea12b6a6c3..29e40a4e179cb 100644 --- a/qa/os/src/test/java/org/opensearch/packaging/test/ArchiveTests.java +++ b/qa/os/src/test/java/org/opensearch/packaging/test/ArchiveTests.java @@ -328,7 +328,7 @@ public void test54ForceBundledJdkEmptyJavaHome() throws Exception { public void test70CustomPathConfAndJvmOptions() throws Exception { withCustomConfig(tempConf -> { - final List jvmOptions = org.opensearch.common.collect.List.of("-Xms512m", "-Xmx512m", "-Dlog4j2.disable.jmx=true"); + final List jvmOptions = List.of("-Xms512m", "-Xmx512m", "-Dlog4j2.disable.jmx=true"); Files.write(tempConf.resolve("jvm.options"), jvmOptions, CREATE, APPEND); sh.getEnv().put("OPENSEARCH_JAVA_OPTS", "-XX:-UseCompressedOops"); diff --git a/qa/os/src/test/java/org/opensearch/packaging/util/FileUtils.java b/qa/os/src/test/java/org/opensearch/packaging/util/FileUtils.java index aa52c3325bee5..d7005a17926ad 100644 --- a/qa/os/src/test/java/org/opensearch/packaging/util/FileUtils.java +++ b/qa/os/src/test/java/org/opensearch/packaging/util/FileUtils.java @@ -83,7 +83,7 @@ public class FileUtils { public static List lsGlob(Path directory, String glob) { List paths = new ArrayList<>(); if (Files.exists(directory) == false) { - return org.opensearch.common.collect.List.of(); + return List.of(); } try (DirectoryStream stream = Files.newDirectoryStream(directory, glob)) { diff --git a/qa/os/src/test/java/org/opensearch/packaging/util/Packages.java b/qa/os/src/test/java/org/opensearch/packaging/util/Packages.java index cea03a0b6fe70..b80ae422bda9a 100644 --- a/qa/os/src/test/java/org/opensearch/packaging/util/Packages.java +++ b/qa/os/src/test/java/org/opensearch/packaging/util/Packages.java @@ -322,7 +322,7 @@ private enum PackageManagerCommand { REMOVE } - private static Map RPM_OPTIONS = org.opensearch.common.collect.Map.of( + private static Map RPM_OPTIONS = Map.of( PackageManagerCommand.QUERY, "-qe", PackageManagerCommand.INSTALL, @@ -335,7 +335,7 @@ private enum PackageManagerCommand { "-e" ); - private static Map DEB_OPTIONS = org.opensearch.common.collect.Map.of( + private static Map DEB_OPTIONS = Map.of( PackageManagerCommand.QUERY, "-s", PackageManagerCommand.INSTALL, diff --git a/qa/smoke-test-http/src/test/java/org/opensearch/http/SystemIndexRestIT.java b/qa/smoke-test-http/src/test/java/org/opensearch/http/SystemIndexRestIT.java index e687e5eb8a151..9f2d686251947 100644 --- a/qa/smoke-test-http/src/test/java/org/opensearch/http/SystemIndexRestIT.java +++ b/qa/smoke-test-http/src/test/java/org/opensearch/http/SystemIndexRestIT.java @@ -157,7 +157,7 @@ public List getRestHandlers(Settings settings, RestController restC IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { - return org.opensearch.common.collect.List.of(new AddDocRestHandler()); + return List.of(new AddDocRestHandler()); } @Override @@ -178,7 +178,7 @@ public String getName() { @Override public List routes() { - return org.opensearch.common.collect.List.of(new Route(RestRequest.Method.POST, "/_sys_index_test/add_doc/{id}")); + return List.of(new Route(RestRequest.Method.POST, "/_sys_index_test/add_doc/{id}")); } @Override @@ -186,7 +186,7 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli IndexRequest indexRequest = new IndexRequest(SYSTEM_INDEX_NAME); indexRequest.id(request.param("id")); indexRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); - indexRequest.source(org.opensearch.common.collect.Map.of("some_field", "some_value")); + indexRequest.source(Map.of("some_field", "some_value")); return channel -> client.index(indexRequest, new RestStatusToXContentListener<>(channel, r -> r.getLocation(indexRequest.routing()))); } diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamIndexTemplateIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamIndexTemplateIT.java index ed500d72c3787..08f7fb17e5164 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamIndexTemplateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamIndexTemplateIT.java @@ -8,8 +8,7 @@ package org.opensearch.action.admin.indices.datastream; -import org.opensearch.common.collect.List; - +import java.util.List; import java.util.concurrent.ExecutionException; import static org.hamcrest.Matchers.containsString; diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamUsageIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamUsageIT.java index 785be061135f0..46f23e40f0864 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamUsageIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/datastream/DataStreamUsageIT.java @@ -13,12 +13,12 @@ import org.opensearch.action.index.IndexRequest; import org.opensearch.action.index.IndexResponse; import org.opensearch.cluster.metadata.DataStream; -import org.opensearch.common.collect.List; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.rest.RestStatus; import java.util.Arrays; +import java.util.List; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityWithRequestBreakerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityWithRequestBreakerIT.java index e8d425596beb0..be69428453952 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityWithRequestBreakerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityWithRequestBreakerIT.java @@ -42,6 +42,7 @@ import org.opensearch.search.aggregations.BucketOrder; import org.opensearch.test.OpenSearchIntegTestCase; +import java.util.Map; import java.util.stream.IntStream; import static org.opensearch.search.aggregations.AggregationBuilders.cardinality; @@ -62,7 +63,7 @@ public void testRequestBreaker() throws Exception { .mapToObj( i -> client().prepareIndex("test") .setId("id_" + i) - .setSource(org.opensearch.common.collect.Map.of("field0", randomAlphaOfLength(5), "field1", randomAlphaOfLength(5))) + .setSource(Map.of("field0", randomAlphaOfLength(5), "field1", randomAlphaOfLength(5))) ) .toArray(IndexRequestBuilder[]::new) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java index f3d1a479f1b46..0e9e409efae59 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java @@ -69,7 +69,7 @@ public class AggregationProfilerIT extends OpenSearchIntegTestCase { private static final String INITIALIZE = AggregationTimingType.INITIALIZE.toString(); private static final String BUILD_AGGREGATION = AggregationTimingType.BUILD_AGGREGATION.toString(); private static final String REDUCE = AggregationTimingType.REDUCE.toString(); - private static final Set BREAKDOWN_KEYS = org.opensearch.common.collect.Set.of( + private static final Set BREAKDOWN_KEYS = Set.of( INITIALIZE, BUILD_LEAF_COLLECTOR, COLLECT, @@ -107,7 +107,7 @@ protected void setupSuiteScopeCluster() throws Exception { client().admin() .indices() .prepareCreate("idx") - .setSettings(org.opensearch.common.collect.Map.of("number_of_shards", 1, "number_of_replicas", 0)) + .setSettings(Map.of("number_of_shards", 1, "number_of_replicas", 0)) .setMapping(STRING_FIELD, "type=keyword", NUMBER_FIELD, "type=integer", TAG_FIELD, "type=keyword") .get() ); @@ -166,7 +166,7 @@ public void testSimpleProfile() { assertThat(breakdown.get(REDUCE), equalTo(0L)); Map debug = histoAggResult.getDebugInfo(); assertThat(debug, notNullValue()); - assertThat(debug.keySet(), equalTo(org.opensearch.common.collect.Set.of(TOTAL_BUCKETS))); + assertThat(debug.keySet(), equalTo(Set.of(TOTAL_BUCKETS))); assertThat(((Number) debug.get(TOTAL_BUCKETS)).longValue(), greaterThan(0L)); } } @@ -209,7 +209,7 @@ public void testMultiLevelProfile() { assertThat(histoBreakdown.get(REDUCE), equalTo(0L)); Map histoDebugInfo = histoAggResult.getDebugInfo(); assertThat(histoDebugInfo, notNullValue()); - assertThat(histoDebugInfo.keySet(), equalTo(org.opensearch.common.collect.Set.of(TOTAL_BUCKETS))); + assertThat(histoDebugInfo.keySet(), equalTo(Set.of(TOTAL_BUCKETS))); assertThat(((Number) histoDebugInfo.get(TOTAL_BUCKETS)).longValue(), greaterThan(0L)); assertThat(histoAggResult.getProfiledChildren().size(), equalTo(1)); @@ -240,7 +240,7 @@ public void testMultiLevelProfile() { assertThat(avgBreakdown.get(COLLECT), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(avgBreakdown.get(REDUCE), equalTo(0L)); - assertThat(avgAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(avgAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0)); } } @@ -295,7 +295,7 @@ public void testMultiLevelProfileBreadthFirst() { assertThat(histoBreakdown.get(REDUCE), equalTo(0L)); Map histoDebugInfo = histoAggResult.getDebugInfo(); assertThat(histoDebugInfo, notNullValue()); - assertThat(histoDebugInfo.keySet(), equalTo(org.opensearch.common.collect.Set.of(TOTAL_BUCKETS))); + assertThat(histoDebugInfo.keySet(), equalTo(Set.of(TOTAL_BUCKETS))); assertThat(((Number) histoDebugInfo.get(TOTAL_BUCKETS)).longValue(), greaterThan(0L)); assertThat(histoAggResult.getProfiledChildren().size(), equalTo(1)); @@ -326,7 +326,7 @@ public void testMultiLevelProfileBreadthFirst() { assertThat(avgBreakdown.get(COLLECT), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(avgBreakdown.get(REDUCE), equalTo(0L)); - assertThat(avgAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(avgAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0)); } } @@ -366,10 +366,7 @@ public void testDiversifiedAggProfile() { assertThat(diversifyBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(diversifyBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(diversifyBreakdown.get(REDUCE), equalTo(0L)); - assertThat( - diversifyAggResult.getDebugInfo(), - equalTo(org.opensearch.common.collect.Map.of(DEFERRED, org.opensearch.common.collect.List.of("max"))) - ); + assertThat(diversifyAggResult.getDebugInfo(), equalTo(Map.of(DEFERRED, List.of("max")))); assertThat(diversifyAggResult.getProfiledChildren().size(), equalTo(1)); ProfileResult maxAggResult = diversifyAggResult.getProfiledChildren().get(0); @@ -386,7 +383,7 @@ public void testDiversifiedAggProfile() { assertThat(diversifyBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(maxBreakdown.get(REDUCE), equalTo(0L)); - assertThat(maxAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(maxAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(maxAggResult.getProfiledChildren().size(), equalTo(0)); } } @@ -441,7 +438,7 @@ public void testComplexProfile() { assertThat(histoBreakdown.get(REDUCE), equalTo(0L)); Map histoDebugInfo = histoAggResult.getDebugInfo(); assertThat(histoDebugInfo, notNullValue()); - assertThat(histoDebugInfo.keySet(), equalTo(org.opensearch.common.collect.Set.of(TOTAL_BUCKETS))); + assertThat(histoDebugInfo.keySet(), equalTo(Set.of(TOTAL_BUCKETS))); assertThat(((Number) histoDebugInfo.get(TOTAL_BUCKETS)).longValue(), greaterThan(0L)); assertThat(histoAggResult.getProfiledChildren().size(), equalTo(2)); @@ -482,7 +479,7 @@ public void testComplexProfile() { assertThat(avgBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(avgBreakdown.get(REDUCE), equalTo(0L)); - assertThat(avgAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(avgAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0)); ProfileResult maxAggResult = tagsAggResultSubAggregations.get("max"); @@ -498,7 +495,7 @@ public void testComplexProfile() { assertThat(maxBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(maxBreakdown.get(REDUCE), equalTo(0L)); - assertThat(maxAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(maxAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(maxAggResult.getProfiledChildren().size(), equalTo(0)); ProfileResult stringsAggResult = histoAggResultSubAggregations.get("strings"); @@ -534,7 +531,7 @@ public void testComplexProfile() { assertThat(avgBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(avgBreakdown.get(REDUCE), equalTo(0L)); - assertThat(avgAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(avgAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0)); maxAggResult = stringsAggResultSubAggregations.get("max"); @@ -550,7 +547,7 @@ public void testComplexProfile() { assertThat(maxBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(maxBreakdown.get(REDUCE), equalTo(0L)); - assertThat(maxAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(maxAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(maxAggResult.getProfiledChildren().size(), equalTo(0)); tagsAggResult = stringsAggResultSubAggregations.get("tags"); @@ -587,7 +584,7 @@ public void testComplexProfile() { assertThat(avgBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(avgBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(avgBreakdown.get(REDUCE), equalTo(0L)); - assertThat(avgAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(avgAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(avgAggResult.getProfiledChildren().size(), equalTo(0)); maxAggResult = tagsAggResultSubAggregations.get("max"); @@ -603,7 +600,7 @@ public void testComplexProfile() { assertThat(maxBreakdown.get(POST_COLLECTION), greaterThan(0L)); assertThat(maxBreakdown.get(BUILD_AGGREGATION), greaterThan(0L)); assertThat(maxBreakdown.get(REDUCE), equalTo(0L)); - assertThat(maxAggResult.getDebugInfo(), equalTo(org.opensearch.common.collect.Map.of())); + assertThat(maxAggResult.getDebugInfo(), equalTo(Map.of())); assertThat(maxAggResult.getProfiledChildren().size(), equalTo(0)); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/MetadataRolloverService.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/MetadataRolloverService.java index c3862bb115b21..65b18845b919a 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/MetadataRolloverService.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/MetadataRolloverService.java @@ -74,7 +74,7 @@ */ public class MetadataRolloverService { private static final Pattern INDEX_NAME_PATTERN = Pattern.compile("^.*-\\d+$"); - private static final List VALID_ROLLOVER_TARGETS = org.opensearch.common.collect.List.of(ALIAS, DATA_STREAM); + private static final List VALID_ROLLOVER_TARGETS = List.of(ALIAS, DATA_STREAM); private final ThreadPool threadPool; private final MetadataCreateIndexService createIndexService; diff --git a/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java b/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java index e20494fbc0675..e304e4da6af08 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java @@ -57,7 +57,6 @@ import static java.util.Collections.singletonMap; import static java.util.Collections.unmodifiableMap; -import static org.opensearch.common.collect.Map.of; /** * An index template is comprised of a set of index patterns, an optional template, and a list of @@ -325,7 +324,10 @@ public TimestampField getTimestampField() { public Map getDataStreamMappingSnippet() { return singletonMap( MapperService.SINGLE_MAPPING_NAME, - singletonMap("_data_stream_timestamp", unmodifiableMap(of("enabled", true, "timestamp_field", getTimestampField().toMap()))) + singletonMap( + "_data_stream_timestamp", + unmodifiableMap(Map.of("enabled", true, "timestamp_field", getTimestampField().toMap())) + ) ); } diff --git a/server/src/main/java/org/opensearch/cluster/metadata/IndexAbstraction.java b/server/src/main/java/org/opensearch/cluster/metadata/IndexAbstraction.java index f9328d5b61183..11ead3e29c346 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/IndexAbstraction.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/IndexAbstraction.java @@ -46,7 +46,6 @@ import static org.opensearch.cluster.metadata.DataStream.getDefaultBackingIndexName; import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_HIDDEN_SETTING; -import static org.opensearch.common.collect.List.copyOf; /** * An index abstraction is a reference to one or more concrete indices. @@ -346,7 +345,7 @@ class DataStream implements IndexAbstraction { public DataStream(org.opensearch.cluster.metadata.DataStream dataStream, List dataStreamIndices) { this.dataStream = dataStream; - this.dataStreamIndices = copyOf(dataStreamIndices); + this.dataStreamIndices = List.copyOf(dataStreamIndices); this.writeIndex = dataStreamIndices.get(dataStreamIndices.size() - 1); assert writeIndex.getIndex().getName().equals(getDefaultBackingIndexName(dataStream.getName(), dataStream.getGeneration())); } diff --git a/server/src/main/java/org/opensearch/cluster/metadata/IndexNameExpressionResolver.java b/server/src/main/java/org/opensearch/cluster/metadata/IndexNameExpressionResolver.java index 003b37fbf3777..cb81afa884b12 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/IndexNameExpressionResolver.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/IndexNameExpressionResolver.java @@ -87,10 +87,7 @@ public class IndexNameExpressionResolver { private final DateMathExpressionResolver dateMathExpressionResolver = new DateMathExpressionResolver(); private final WildcardExpressionResolver wildcardExpressionResolver = new WildcardExpressionResolver(); - private final List expressionResolvers = org.opensearch.common.collect.List.of( - dateMathExpressionResolver, - wildcardExpressionResolver - ); + private final List expressionResolvers = List.of(dateMathExpressionResolver, wildcardExpressionResolver); private final ThreadContext threadContext; @@ -174,7 +171,7 @@ public List dataStreamNames(ClusterState state, IndicesOptions options, } List dataStreams = wildcardExpressionResolver.resolve(context, Arrays.asList(indexExpressions)); - return ((dataStreams == null) ? org.opensearch.common.collect.List.of() : dataStreams).stream() + return ((dataStreams == null) ? List.of() : dataStreams).stream() .map(x -> state.metadata().getIndicesLookup().get(x)) .filter(Objects::nonNull) .filter(ia -> ia.getType() == IndexAbstraction.Type.DATA_STREAM) diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java index 3c896e01e6a47..42c8028ce7dfa 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java @@ -730,7 +730,7 @@ private ClusterState applyCreateIndexRequestWithExistingMetadata( // shard id and the current timestamp indexService.newQueryShardContext(0, null, () -> 0L, null) ), - org.opensearch.common.collect.List.of(), + List.of(), metadataTransformer ); } diff --git a/server/src/main/java/org/opensearch/index/mapper/ArraySourceValueFetcher.java b/server/src/main/java/org/opensearch/index/mapper/ArraySourceValueFetcher.java index 936d6b4fb7f8b..f5dc34ab8ac5d 100644 --- a/server/src/main/java/org/opensearch/index/mapper/ArraySourceValueFetcher.java +++ b/server/src/main/java/org/opensearch/index/mapper/ArraySourceValueFetcher.java @@ -74,7 +74,7 @@ public List fetchValues(SourceLookup lookup) { for (String path : sourcePaths) { Object sourceValue = lookup.extractValue(path, nullValue); if (sourceValue == null) { - return org.opensearch.common.collect.List.of(); + return List.of(); } values.addAll((List) parseSourceValue(sourceValue)); } diff --git a/server/src/main/java/org/opensearch/index/mapper/FieldTypeLookup.java b/server/src/main/java/org/opensearch/index/mapper/FieldTypeLookup.java index bede143ed5e92..8e1b6f2a3c08b 100644 --- a/server/src/main/java/org/opensearch/index/mapper/FieldTypeLookup.java +++ b/server/src/main/java/org/opensearch/index/mapper/FieldTypeLookup.java @@ -153,9 +153,7 @@ public Set sourcePaths(String field) { } } - return fieldToCopiedFields.containsKey(resolvedField) - ? fieldToCopiedFields.get(resolvedField) - : org.opensearch.common.collect.Set.of(resolvedField); + return fieldToCopiedFields.containsKey(resolvedField) ? fieldToCopiedFields.get(resolvedField) : Set.of(resolvedField); } @Override diff --git a/server/src/main/java/org/opensearch/index/mapper/SourceValueFetcher.java b/server/src/main/java/org/opensearch/index/mapper/SourceValueFetcher.java index d602fceeed041..69f53ba126790 100644 --- a/server/src/main/java/org/opensearch/index/mapper/SourceValueFetcher.java +++ b/server/src/main/java/org/opensearch/index/mapper/SourceValueFetcher.java @@ -75,7 +75,7 @@ public List fetchValues(SourceLookup lookup) { for (String path : sourcePaths) { Object sourceValue = lookup.extractValue(path, nullValue); if (sourceValue == null) { - return org.opensearch.common.collect.List.of(); + return List.of(); } // We allow source values to contain multiple levels of arrays, such as `"field": [[1, 2]]`. diff --git a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestGetDataStreamsAction.java b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestGetDataStreamsAction.java index 3cf27e324a336..4b447d1ac337a 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestGetDataStreamsAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestGetDataStreamsAction.java @@ -55,10 +55,7 @@ public String getName() { @Override public List routes() { - return org.opensearch.common.collect.List.of( - new Route(RestRequest.Method.GET, "/_data_stream"), - new Route(RestRequest.Method.GET, "/_data_stream/{name}") - ); + return List.of(new Route(RestRequest.Method.GET, "/_data_stream"), new Route(RestRequest.Method.GET, "/_data_stream/{name}")); } @Override diff --git a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestResolveIndexAction.java b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestResolveIndexAction.java index 687ff554bd8d4..eee9804abec3b 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestResolveIndexAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestResolveIndexAction.java @@ -57,7 +57,7 @@ public String getName() { @Override public List routes() { - return org.opensearch.common.collect.List.of(new Route(RestRequest.Method.GET, "/_resolve/index/{name}")); + return List.of(new Route(RestRequest.Method.GET, "/_resolve/index/{name}")); } @Override diff --git a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestSimulateIndexTemplateAction.java b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestSimulateIndexTemplateAction.java index aa5e29fbf46cd..db3ffaa1552cd 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/indices/RestSimulateIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/indices/RestSimulateIndexTemplateAction.java @@ -58,7 +58,7 @@ public class RestSimulateIndexTemplateAction extends BaseRestHandler { @Override public List routes() { - return org.opensearch.common.collect.List.of(new Route(POST, "/_index_template/_simulate_index/{name}")); + return List.of(new Route(POST, "/_index_template/_simulate_index/{name}")); } @Override diff --git a/server/src/main/java/org/opensearch/script/AbstractSortScript.java b/server/src/main/java/org/opensearch/script/AbstractSortScript.java index c72717f8bc927..ac39be1074efa 100644 --- a/server/src/main/java/org/opensearch/script/AbstractSortScript.java +++ b/server/src/main/java/org/opensearch/script/AbstractSortScript.java @@ -54,7 +54,7 @@ abstract class AbstractSortScript implements ScorerAware { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> PARAMS_FUNCTIONS = org.opensearch.common.collect.Map.of("doc", value -> { + private static final Map> PARAMS_FUNCTIONS = Map.of("doc", value -> { deprecationLogger.deprecate( "sort-script_doc", "Accessing variable [doc] via [params.doc] from within an sort-script " + "is deprecated in favor of directly accessing [doc]." diff --git a/server/src/main/java/org/opensearch/script/AggregationScript.java b/server/src/main/java/org/opensearch/script/AggregationScript.java index 4c9d6060ddbfd..ef300e9473d3e 100644 --- a/server/src/main/java/org/opensearch/script/AggregationScript.java +++ b/server/src/main/java/org/opensearch/script/AggregationScript.java @@ -58,7 +58,7 @@ public abstract class AggregationScript implements ScorerAware { public static final ScriptContext CONTEXT = new ScriptContext<>("aggs", Factory.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> PARAMS_FUNCTIONS = org.opensearch.common.collect.Map.of("doc", value -> { + private static final Map> PARAMS_FUNCTIONS = Map.of("doc", value -> { deprecationLogger.deprecate( "aggregation-script_doc", "Accessing variable [doc] via [params.doc] from within an aggregation-script " diff --git a/server/src/main/java/org/opensearch/script/FieldScript.java b/server/src/main/java/org/opensearch/script/FieldScript.java index 531616a74dce9..82b5c9a088a2c 100644 --- a/server/src/main/java/org/opensearch/script/FieldScript.java +++ b/server/src/main/java/org/opensearch/script/FieldScript.java @@ -54,7 +54,7 @@ public abstract class FieldScript { public static final String[] PARAMETERS = {}; private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> PARAMS_FUNCTIONS = org.opensearch.common.collect.Map.of("doc", value -> { + private static final Map> PARAMS_FUNCTIONS = Map.of("doc", value -> { deprecationLogger.deprecate( "field-script_doc", "Accessing variable [doc] via [params.doc] from within an field-script " + "is deprecated in favor of directly accessing [doc]." diff --git a/server/src/main/java/org/opensearch/script/ScoreScript.java b/server/src/main/java/org/opensearch/script/ScoreScript.java index dba44995b18f0..5c6553ffc2a28 100644 --- a/server/src/main/java/org/opensearch/script/ScoreScript.java +++ b/server/src/main/java/org/opensearch/script/ScoreScript.java @@ -84,7 +84,7 @@ public Explanation get(double score, Explanation subQueryExplanation) { } private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> PARAMS_FUNCTIONS = org.opensearch.common.collect.Map.of("doc", value -> { + private static final Map> PARAMS_FUNCTIONS = Map.of("doc", value -> { deprecationLogger.deprecate( "score-script_doc", "Accessing variable [doc] via [params.doc] from within an score-script " + "is deprecated in favor of directly accessing [doc]." diff --git a/server/src/main/java/org/opensearch/script/ScriptedMetricAggContexts.java b/server/src/main/java/org/opensearch/script/ScriptedMetricAggContexts.java index 58d0f7b4f6040..2f61fd75471ad 100644 --- a/server/src/main/java/org/opensearch/script/ScriptedMetricAggContexts.java +++ b/server/src/main/java/org/opensearch/script/ScriptedMetricAggContexts.java @@ -99,7 +99,7 @@ public interface Factory extends ScriptFactory { public abstract static class MapScript { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> PARAMS_FUNCTIONS = org.opensearch.common.collect.Map.of("doc", value -> { + private static final Map> PARAMS_FUNCTIONS = Map.of("doc", value -> { deprecationLogger.deprecate( "map-script_doc", "Accessing variable [doc] via [params.doc] from within an scripted metric agg map script " diff --git a/server/src/main/java/org/opensearch/script/TermsSetQueryScript.java b/server/src/main/java/org/opensearch/script/TermsSetQueryScript.java index 02e361b0f5415..99fa2d584ebfd 100644 --- a/server/src/main/java/org/opensearch/script/TermsSetQueryScript.java +++ b/server/src/main/java/org/opensearch/script/TermsSetQueryScript.java @@ -55,7 +55,7 @@ public abstract class TermsSetQueryScript { public static final ScriptContext CONTEXT = new ScriptContext<>("terms_set", Factory.class); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); - private static final Map> PARAMS_FUNCTIONS = org.opensearch.common.collect.Map.of("doc", value -> { + private static final Map> PARAMS_FUNCTIONS = Map.of("doc", value -> { deprecationLogger.deprecate( "terms-set-query-script_doc", "Accessing variable [doc] via [params.doc] from within an terms-set-query-script " diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java index cb1580f5d9be1..ddb64371eda16 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/DateHistogramValuesSourceBuilder.java @@ -62,6 +62,7 @@ import java.io.IOException; import java.time.ZoneId; import java.time.ZoneOffset; +import java.util.List; import java.util.Objects; import java.util.function.LongConsumer; @@ -291,7 +292,7 @@ public DateHistogramValuesSourceBuilder offset(long offset) { public static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC), + List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC), (valuesSourceConfig, rounding, name, hasScript, format, missingBucket, missingOrder, order) -> { ValuesSource.Numeric numeric = (ValuesSource.Numeric) valuesSourceConfig.getValuesSource(); // TODO once composite is plugged in to the values source registry or at least understands Date values source types use it diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java index dc43592f541f4..00cd869f90ddc 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/HistogramValuesSourceBuilder.java @@ -51,6 +51,7 @@ import org.opensearch.search.sort.SortOrder; import java.io.IOException; +import java.util.List; import java.util.Objects; import java.util.function.LongConsumer; @@ -100,7 +101,7 @@ static HistogramValuesSourceBuilder parse(String name, XContentParser parser) th public static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC), + List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC), (valuesSourceConfig, interval, name, hasScript, format, missingBucket, missingOrder, order) -> { ValuesSource.Numeric numeric = (ValuesSource.Numeric) valuesSourceConfig.getValuesSource(); final HistogramValuesSource vs = new HistogramValuesSource(numeric, interval); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/TermsValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/TermsValuesSourceBuilder.java index 500c5e93121ac..afa584a068c31 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/TermsValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/TermsValuesSourceBuilder.java @@ -52,6 +52,7 @@ import org.opensearch.search.sort.SortOrder; import java.io.IOException; +import java.util.List; import java.util.function.LongConsumer; import java.util.function.LongUnaryOperator; @@ -118,7 +119,7 @@ public String type() { static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC, CoreValuesSourceType.BOOLEAN), + List.of(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC, CoreValuesSourceType.BOOLEAN), (valuesSourceConfig, name, hasScript, format, missingBucket, missingOrder, order) -> { final DocValueFormat docValueFormat; if (format == null && valuesSourceConfig.valueSourceType() == CoreValuesSourceType.DATE) { @@ -180,7 +181,7 @@ static void register(ValuesSourceRegistry.Builder builder) { builder.register( REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.BYTES, CoreValuesSourceType.IP), + List.of(CoreValuesSourceType.BYTES, CoreValuesSourceType.IP), (valuesSourceConfig, name, hasScript, format, missingBucket, missingOrder, order) -> new CompositeValuesSourceConfig( name, valuesSourceConfig.fieldType(), diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java index eb22a857643c4..dd74d83c665de 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorFactory.java @@ -33,7 +33,6 @@ package org.opensearch.search.aggregations.bucket.histogram; import org.opensearch.common.Rounding; -import org.opensearch.common.collect.List; import org.opensearch.index.query.QueryShardContext; import org.opensearch.search.aggregations.Aggregator; import org.opensearch.search.aggregations.AggregatorFactories; @@ -47,6 +46,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/HistogramAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/HistogramAggregatorFactory.java index 722bf87201631..321c16cdba970 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/HistogramAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/HistogramAggregatorFactory.java @@ -32,7 +32,6 @@ package org.opensearch.search.aggregations.bucket.histogram; -import org.opensearch.common.collect.List; import org.opensearch.index.query.QueryShardContext; import org.opensearch.search.aggregations.Aggregator; import org.opensearch.search.aggregations.AggregatorFactories; @@ -46,6 +45,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/InternalAutoDateHistogram.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/InternalAutoDateHistogram.java index e2a090fda3878..fb83ae2e489d9 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/InternalAutoDateHistogram.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/histogram/InternalAutoDateHistogram.java @@ -482,10 +482,7 @@ private BucketReduceResult addEmptyBuckets(BucketReduceResult current, ReduceCon Bucket lastBucket = null; ListIterator iter = list.listIterator(); - InternalAggregations reducedEmptySubAggs = InternalAggregations.reduce( - org.opensearch.common.collect.List.of(bucketInfo.emptySubAggregations), - reduceContext - ); + InternalAggregations reducedEmptySubAggs = InternalAggregations.reduce(List.of(bucketInfo.emptySubAggregations), reduceContext); // Add the empty buckets within the data, // e.g. if the data series is [1,2,3,7] there're 3 empty buckets that will be created for 4,5,6 diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/range/AbstractRangeAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/range/AbstractRangeAggregatorFactory.java index 90ae2e994caf1..bfd7845e7e16f 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/range/AbstractRangeAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/range/AbstractRangeAggregatorFactory.java @@ -47,6 +47,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -67,7 +68,7 @@ public static void registerAggregators( ) { builder.register( registryKey, - org.opensearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), + List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), RangeAggregator::new, true ); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedAggregatorFactory.java index f8d3040620a51..41ef823a375c0 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/sampler/DiversifiedAggregatorFactory.java @@ -47,6 +47,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -59,7 +60,7 @@ public class DiversifiedAggregatorFactory extends ValuesSourceAggregatorFactory public static void registerAggregators(ValuesSourceRegistry.Builder builder) { builder.register( DiversifiedAggregationBuilder.REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), + List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), ( String name, int shardSize, diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregationFactory.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregationFactory.java index 8a061c0fbf512..01975381f15a4 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregationFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregationFactory.java @@ -50,21 +50,14 @@ public class MultiTermsAggregationFactory extends AggregatorFactory { private final boolean showTermDocCountError; public static void registerAggregators(ValuesSourceRegistry.Builder builder) { - builder.register( - REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.BYTES, CoreValuesSourceType.IP), - config -> { - final IncludeExclude.StringFilter filter = config.v2() == null - ? null - : config.v2().convertToStringFilter(config.v1().format()); - return MultiTermsAggregator.InternalValuesSourceFactory.bytesValuesSource(config.v1().getValuesSource(), filter); - }, - true - ); + builder.register(REGISTRY_KEY, List.of(CoreValuesSourceType.BYTES, CoreValuesSourceType.IP), config -> { + final IncludeExclude.StringFilter filter = config.v2() == null ? null : config.v2().convertToStringFilter(config.v1().format()); + return MultiTermsAggregator.InternalValuesSourceFactory.bytesValuesSource(config.v1().getValuesSource(), filter); + }, true); builder.register( REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.BOOLEAN, CoreValuesSourceType.DATE), + List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.BOOLEAN, CoreValuesSourceType.DATE), config -> { ValuesSourceConfig valuesSourceConfig = config.v1(); IncludeExclude includeExclude = config.v2(); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java index 45898a689a605..c21bfd6fb73b9 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregator.java @@ -188,7 +188,7 @@ InternalMultiTerms buildResult(long owningBucketOrd, long otherDocCount, Interna otherDocCount, 0, formats, - org.opensearch.common.collect.List.of(topBuckets) + List.of(topBuckets) ); } @@ -341,7 +341,7 @@ private void apply( List> results ) throws IOException { if (index == collectedValues.size()) { - results.add(org.opensearch.common.collect.List.copyOf(current)); + results.add(List.copyOf(current)); } else if (null != collectedValues.get(index)) { for (Object value : collectedValues.get(index).get()) { current.add(value); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregator.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregator.java index 2c4c502b86695..70e98c0d19cd7 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregator.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/terms/NumericTermsAggregator.java @@ -37,7 +37,6 @@ import org.apache.lucene.search.ScoreMode; import org.apache.lucene.util.NumericUtils; import org.apache.lucene.util.PriorityQueue; -import org.opensearch.common.collect.List; import org.opensearch.common.lease.Releasable; import org.opensearch.common.lease.Releasables; import org.opensearch.common.util.LongArray; @@ -62,6 +61,7 @@ import java.io.IOException; import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.function.BiConsumer; import java.util.function.Function; diff --git a/server/src/main/java/org/opensearch/search/aggregations/metrics/AvgAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/metrics/AvgAggregatorFactory.java index 727304f8a5254..75419b7c64b12 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/metrics/AvgAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/metrics/AvgAggregatorFactory.java @@ -44,6 +44,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -67,7 +68,7 @@ class AvgAggregatorFactory extends ValuesSourceAggregatorFactory { static void registerAggregators(ValuesSourceRegistry.Builder builder) { builder.register( AvgAggregationBuilder.REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), + List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), AvgAggregator::new, true ); diff --git a/server/src/main/java/org/opensearch/search/aggregations/metrics/MaxAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/metrics/MaxAggregatorFactory.java index 3ec24ad04d9aa..96f1af94f2d07 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/metrics/MaxAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/metrics/MaxAggregatorFactory.java @@ -44,6 +44,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -56,7 +57,7 @@ class MaxAggregatorFactory extends ValuesSourceAggregatorFactory { static void registerAggregators(ValuesSourceRegistry.Builder builder) { builder.register( MaxAggregationBuilder.REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), + List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), MaxAggregator::new, true ); diff --git a/server/src/main/java/org/opensearch/search/aggregations/metrics/MinAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/metrics/MinAggregatorFactory.java index 1b24b88d6f068..b117f70c81baf 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/metrics/MinAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/metrics/MinAggregatorFactory.java @@ -44,6 +44,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -56,7 +57,7 @@ class MinAggregatorFactory extends ValuesSourceAggregatorFactory { static void registerAggregators(ValuesSourceRegistry.Builder builder) { builder.register( MinAggregationBuilder.REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), + List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), MinAggregator::new, true ); diff --git a/server/src/main/java/org/opensearch/search/aggregations/metrics/ScriptedMetricAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/metrics/ScriptedMetricAggregatorFactory.java index 7b5848fc79197..5c831d60f75a8 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/metrics/ScriptedMetricAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/metrics/ScriptedMetricAggregatorFactory.java @@ -103,7 +103,7 @@ public Aggregator createInternal( CardinalityUpperBound cardinality, Map metadata ) throws IOException { - Map aggParams = this.aggParams == null ? org.opensearch.common.collect.Map.of() : this.aggParams; + Map aggParams = this.aggParams == null ? Map.of() : this.aggParams; Script reduceScript = deepCopyScript(this.reduceScript, searchContext, aggParams); diff --git a/server/src/main/java/org/opensearch/search/aggregations/metrics/StatsAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/metrics/StatsAggregatorFactory.java index 6e343ed9a31d1..0c10df174efa0 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/metrics/StatsAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/metrics/StatsAggregatorFactory.java @@ -44,6 +44,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -67,7 +68,7 @@ class StatsAggregatorFactory extends ValuesSourceAggregatorFactory { static void registerAggregators(ValuesSourceRegistry.Builder builder) { builder.register( StatsAggregationBuilder.REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), + List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), StatsAggregator::new, true ); diff --git a/server/src/main/java/org/opensearch/search/aggregations/metrics/SumAggregatorFactory.java b/server/src/main/java/org/opensearch/search/aggregations/metrics/SumAggregatorFactory.java index c94949bca09e6..b3506ff958833 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/metrics/SumAggregatorFactory.java +++ b/server/src/main/java/org/opensearch/search/aggregations/metrics/SumAggregatorFactory.java @@ -44,6 +44,7 @@ import org.opensearch.search.internal.SearchContext; import java.io.IOException; +import java.util.List; import java.util.Map; /** @@ -67,7 +68,7 @@ class SumAggregatorFactory extends ValuesSourceAggregatorFactory { static void registerAggregators(ValuesSourceRegistry.Builder builder) { builder.register( SumAggregationBuilder.REGISTRY_KEY, - org.opensearch.common.collect.List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), + List.of(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN), SumAggregator::new, true ); diff --git a/server/src/main/java/org/opensearch/search/fetch/subphase/FetchFieldsPhase.java b/server/src/main/java/org/opensearch/search/fetch/subphase/FetchFieldsPhase.java index 0b15124f08cee..9988abb778bce 100644 --- a/server/src/main/java/org/opensearch/search/fetch/subphase/FetchFieldsPhase.java +++ b/server/src/main/java/org/opensearch/search/fetch/subphase/FetchFieldsPhase.java @@ -96,7 +96,7 @@ public void process(HitContext hitContext) throws IOException { private Set getIgnoredFields(SearchHit hit) { DocumentField field = hit.field(IgnoredFieldMapper.NAME); if (field == null) { - return org.opensearch.common.collect.Set.of(); + return Set.of(); } Set ignoredFields = new HashSet<>(); diff --git a/server/src/main/java/org/opensearch/search/profile/ProfileResult.java b/server/src/main/java/org/opensearch/search/profile/ProfileResult.java index 7b64ad56b9236..0ce99cd44e4fc 100644 --- a/server/src/main/java/org/opensearch/search/profile/ProfileResult.java +++ b/server/src/main/java/org/opensearch/search/profile/ProfileResult.java @@ -90,8 +90,8 @@ public ProfileResult( this.type = type; this.description = description; this.breakdown = Objects.requireNonNull(breakdown, "required breakdown argument missing"); - this.debug = debug == null ? org.opensearch.common.collect.Map.of() : debug; - this.children = children == null ? org.opensearch.common.collect.List.of() : children; + this.debug = debug == null ? Map.of() : debug; + this.children = children == null ? List.of() : children; this.nodeTime = nodeTime; } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamRequestTests.java index b6e143d28b4aa..e33b873a52f19 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/datastream/DeleteDataStreamRequestTests.java @@ -95,11 +95,8 @@ public void testValidateRequestWithoutName() { public void testDeleteDataStream() { final String dataStreamName = "my-data-stream"; - final List otherIndices = randomSubsetOf(org.opensearch.common.collect.List.of("foo", "bar", "baz")); - ClusterState cs = getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of(new Tuple<>(dataStreamName, 2)), - otherIndices - ); + final List otherIndices = randomSubsetOf(List.of("foo", "bar", "baz")); + ClusterState cs = getClusterStateWithDataStreams(List.of(new Tuple<>(dataStreamName, 2)), otherIndices); DeleteDataStreamAction.Request req = new DeleteDataStreamAction.Request(new String[] { dataStreamName }); ClusterState newState = DeleteDataStreamAction.TransportAction.removeDataStream(getMetadataDeleteIndexService(), cs, req); assertThat(newState.metadata().dataStreams().size(), equalTo(0)); @@ -112,13 +109,13 @@ public void testDeleteDataStream() { public void testDeleteMultipleDataStreams() { String[] dataStreamNames = { "foo", "bar", "baz", "eggplant" }; ClusterState cs = getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of( + List.of( new Tuple<>(dataStreamNames[0], randomIntBetween(1, 3)), new Tuple<>(dataStreamNames[1], randomIntBetween(1, 3)), new Tuple<>(dataStreamNames[2], randomIntBetween(1, 3)), new Tuple<>(dataStreamNames[3], randomIntBetween(1, 3)) ), - org.opensearch.common.collect.List.of() + List.of() ); DeleteDataStreamAction.Request req = new DeleteDataStreamAction.Request(new String[] { "ba*", "eggplant" }); @@ -182,13 +179,13 @@ public void testDeleteNonexistentDataStream() { final String dataStreamName = "my-data-stream"; String[] dataStreamNames = { "foo", "bar", "baz", "eggplant" }; ClusterState cs = getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of( + List.of( new Tuple<>(dataStreamNames[0], randomIntBetween(1, 3)), new Tuple<>(dataStreamNames[1], randomIntBetween(1, 3)), new Tuple<>(dataStreamNames[2], randomIntBetween(1, 3)), new Tuple<>(dataStreamNames[3], randomIntBetween(1, 3)) ), - org.opensearch.common.collect.List.of() + List.of() ); DeleteDataStreamAction.Request req = new DeleteDataStreamAction.Request(new String[] { dataStreamName }); ClusterState newState = DeleteDataStreamAction.TransportAction.removeDataStream(getMetadataDeleteIndexService(), cs, req); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/datastream/GetDataStreamsRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/datastream/GetDataStreamsRequestTests.java index 25734a9824c41..54e83bc764cad 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/datastream/GetDataStreamsRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/datastream/GetDataStreamsRequestTests.java @@ -82,10 +82,7 @@ protected Request createTestInstance() { public void testGetDataStream() { final String dataStreamName = "my-data-stream"; - ClusterState cs = getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of(new Tuple<>(dataStreamName, 1)), - org.opensearch.common.collect.List.of() - ); + ClusterState cs = getClusterStateWithDataStreams(List.of(new Tuple<>(dataStreamName, 1)), List.of()); GetDataStreamAction.Request req = new GetDataStreamAction.Request(new String[] { dataStreamName }); List dataStreams = GetDataStreamAction.TransportAction.getDataStreams( cs, @@ -99,8 +96,8 @@ public void testGetDataStream() { public void testGetDataStreamsWithWildcards() { final String[] dataStreamNames = { "my-data-stream", "another-data-stream" }; ClusterState cs = getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of(new Tuple<>(dataStreamNames[0], 1), new Tuple<>(dataStreamNames[1], 1)), - org.opensearch.common.collect.List.of() + List.of(new Tuple<>(dataStreamNames[0], 1), new Tuple<>(dataStreamNames[1], 1)), + List.of() ); GetDataStreamAction.Request req = new GetDataStreamAction.Request(new String[] { dataStreamNames[1].substring(0, 5) + "*" }); @@ -144,8 +141,8 @@ public void testGetDataStreamsWithWildcards() { public void testGetDataStreamsWithoutWildcards() { final String[] dataStreamNames = { "my-data-stream", "another-data-stream" }; ClusterState cs = getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of(new Tuple<>(dataStreamNames[0], 1), new Tuple<>(dataStreamNames[1], 1)), - org.opensearch.common.collect.List.of() + List.of(new Tuple<>(dataStreamNames[0], 1), new Tuple<>(dataStreamNames[1], 1)), + List.of() ); GetDataStreamAction.Request req = new GetDataStreamAction.Request(new String[] { dataStreamNames[0], dataStreamNames[1] }); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java index 255577684f2e7..6846ebbb314f8 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java @@ -164,21 +164,18 @@ private static PutMappingRequest createTestItem() throws IOException { public void testResolveIndicesWithWriteIndexOnlyAndDataStreamsAndWriteAliases() { String[] dataStreamNames = { "foo", "bar", "baz" }; - List> dsMetadata = org.opensearch.common.collect.List.of( + List> dsMetadata = List.of( tuple(dataStreamNames[0], randomIntBetween(1, 3)), tuple(dataStreamNames[1], randomIntBetween(1, 3)), tuple(dataStreamNames[2], randomIntBetween(1, 3)) ); - ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams( - dsMetadata, - org.opensearch.common.collect.List.of("index1", "index2", "index3") - ); + ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams(dsMetadata, List.of("index1", "index2", "index3")); cs = addAliases( cs, - org.opensearch.common.collect.List.of( - tuple("alias1", org.opensearch.common.collect.List.of(tuple("index1", false), tuple("index2", true))), - tuple("alias2", org.opensearch.common.collect.List.of(tuple("index2", false), tuple("index3", true))) + List.of( + tuple("alias1", List.of(tuple("index1", false), tuple("index2", true))), + tuple("alias2", List.of(tuple("index2", false), tuple("index3", true))) ) ); PutMappingRequest request = new PutMappingRequest().indices("foo", "alias1", "alias2").writeIndexOnly(true); @@ -195,21 +192,18 @@ public void testResolveIndicesWithWriteIndexOnlyAndDataStreamsAndWriteAliases() public void testResolveIndicesWithoutWriteIndexOnlyAndDataStreamsAndWriteAliases() { String[] dataStreamNames = { "foo", "bar", "baz" }; - List> dsMetadata = org.opensearch.common.collect.List.of( + List> dsMetadata = List.of( tuple(dataStreamNames[0], randomIntBetween(1, 3)), tuple(dataStreamNames[1], randomIntBetween(1, 3)), tuple(dataStreamNames[2], randomIntBetween(1, 3)) ); - ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams( - dsMetadata, - org.opensearch.common.collect.List.of("index1", "index2", "index3") - ); + ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams(dsMetadata, List.of("index1", "index2", "index3")); cs = addAliases( cs, - org.opensearch.common.collect.List.of( - tuple("alias1", org.opensearch.common.collect.List.of(tuple("index1", false), tuple("index2", true))), - tuple("alias2", org.opensearch.common.collect.List.of(tuple("index2", false), tuple("index3", true))) + List.of( + tuple("alias1", List.of(tuple("index1", false), tuple("index2", true))), + tuple("alias2", List.of(tuple("index2", false), tuple("index3", true))) ) ); PutMappingRequest request = new PutMappingRequest().indices("foo", "alias1", "alias2"); @@ -221,28 +215,25 @@ public void testResolveIndicesWithoutWriteIndexOnlyAndDataStreamsAndWriteAliases List indexNames = Arrays.stream(indices).map(Index::getName).collect(Collectors.toList()); IndexAbstraction expectedDs = cs.metadata().getIndicesLookup().get("foo"); List expectedIndices = expectedDs.getIndices().stream().map(im -> im.getIndex().getName()).collect(Collectors.toList()); - expectedIndices.addAll(org.opensearch.common.collect.List.of("index1", "index2", "index3")); + expectedIndices.addAll(List.of("index1", "index2", "index3")); // should resolve the data stream and each alias to _all_ their respective indices assertThat(indexNames, containsInAnyOrder(expectedIndices.toArray())); } public void testResolveIndicesWithWriteIndexOnlyAndDataStreamAndIndex() { String[] dataStreamNames = { "foo", "bar", "baz" }; - List> dsMetadata = org.opensearch.common.collect.List.of( + List> dsMetadata = List.of( tuple(dataStreamNames[0], randomIntBetween(1, 3)), tuple(dataStreamNames[1], randomIntBetween(1, 3)), tuple(dataStreamNames[2], randomIntBetween(1, 3)) ); - ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams( - dsMetadata, - org.opensearch.common.collect.List.of("index1", "index2", "index3") - ); + ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams(dsMetadata, List.of("index1", "index2", "index3")); cs = addAliases( cs, - org.opensearch.common.collect.List.of( - tuple("alias1", org.opensearch.common.collect.List.of(tuple("index1", false), tuple("index2", true))), - tuple("alias2", org.opensearch.common.collect.List.of(tuple("index2", false), tuple("index3", true))) + List.of( + tuple("alias1", List.of(tuple("index1", false), tuple("index2", true))), + tuple("alias2", List.of(tuple("index2", false), tuple("index3", true))) ) ); PutMappingRequest request = new PutMappingRequest().indices("foo", "index3").writeIndexOnly(true); @@ -254,28 +245,25 @@ public void testResolveIndicesWithWriteIndexOnlyAndDataStreamAndIndex() { List indexNames = Arrays.stream(indices).map(Index::getName).collect(Collectors.toList()); IndexAbstraction expectedDs = cs.metadata().getIndicesLookup().get("foo"); List expectedIndices = expectedDs.getIndices().stream().map(im -> im.getIndex().getName()).collect(Collectors.toList()); - expectedIndices.addAll(org.opensearch.common.collect.List.of("index1", "index2", "index3")); + expectedIndices.addAll(List.of("index1", "index2", "index3")); // should resolve the data stream and each alias to _all_ their respective indices assertThat(indexNames, containsInAnyOrder(expectedDs.getWriteIndex().getIndex().getName(), "index3")); } public void testResolveIndicesWithWriteIndexOnlyAndNoSingleWriteIndex() { String[] dataStreamNames = { "foo", "bar", "baz" }; - List> dsMetadata = org.opensearch.common.collect.List.of( + List> dsMetadata = List.of( tuple(dataStreamNames[0], randomIntBetween(1, 3)), tuple(dataStreamNames[1], randomIntBetween(1, 3)), tuple(dataStreamNames[2], randomIntBetween(1, 3)) ); - ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams( - dsMetadata, - org.opensearch.common.collect.List.of("index1", "index2", "index3") - ); + ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams(dsMetadata, List.of("index1", "index2", "index3")); final ClusterState cs2 = addAliases( cs, - org.opensearch.common.collect.List.of( - tuple("alias1", org.opensearch.common.collect.List.of(tuple("index1", false), tuple("index2", true))), - tuple("alias2", org.opensearch.common.collect.List.of(tuple("index2", false), tuple("index3", true))) + List.of( + tuple("alias1", List.of(tuple("index1", false), tuple("index2", true))), + tuple("alias2", List.of(tuple("index2", false), tuple("index3", true))) ) ); PutMappingRequest request = new PutMappingRequest().indices("*").writeIndexOnly(true); @@ -288,21 +276,18 @@ public void testResolveIndicesWithWriteIndexOnlyAndNoSingleWriteIndex() { public void testResolveIndicesWithWriteIndexOnlyAndAliasWithoutWriteIndex() { String[] dataStreamNames = { "foo", "bar", "baz" }; - List> dsMetadata = org.opensearch.common.collect.List.of( + List> dsMetadata = List.of( tuple(dataStreamNames[0], randomIntBetween(1, 3)), tuple(dataStreamNames[1], randomIntBetween(1, 3)), tuple(dataStreamNames[2], randomIntBetween(1, 3)) ); - ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams( - dsMetadata, - org.opensearch.common.collect.List.of("index1", "index2", "index3") - ); + ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams(dsMetadata, List.of("index1", "index2", "index3")); final ClusterState cs2 = addAliases( cs, - org.opensearch.common.collect.List.of( - tuple("alias1", org.opensearch.common.collect.List.of(tuple("index1", false), tuple("index2", false))), - tuple("alias2", org.opensearch.common.collect.List.of(tuple("index2", false), tuple("index3", false))) + List.of( + tuple("alias1", List.of(tuple("index1", false), tuple("index2", false))), + tuple("alias2", List.of(tuple("index2", false), tuple("index3", false))) ) ); PutMappingRequest request = new PutMappingRequest().indices("alias2").writeIndexOnly(true); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/resolve/ResolveIndexResponseTests.java b/server/src/test/java/org/opensearch/action/admin/indices/resolve/ResolveIndexResponseTests.java index c5ec5233d5d10..a9b99df5c4ce3 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/resolve/ResolveIndexResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/resolve/ResolveIndexResponseTests.java @@ -92,9 +92,7 @@ protected Response createTestInstance() { private static ResolvedIndex createTestResolvedIndexInstance() { String name = randomAlphaOfLength(6); String[] aliases = randomStringArray(0, 5); - String[] attributes = randomSubsetOf(org.opensearch.common.collect.List.of("open", "hidden", "frozen")).toArray( - Strings.EMPTY_ARRAY - ); + String[] attributes = randomSubsetOf(List.of("open", "hidden", "frozen")).toArray(Strings.EMPTY_ARRAY); String dataStream = randomBoolean() ? randomAlphaOfLength(6) : null; return new ResolvedIndex(name, aliases, attributes, dataStream); diff --git a/server/src/test/java/org/opensearch/action/admin/indices/template/put/PutComposableIndexTemplateRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/template/put/PutComposableIndexTemplateRequestTests.java index 98e833b051032..d73ba0c7e9105 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/template/put/PutComposableIndexTemplateRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/template/put/PutComposableIndexTemplateRequestTests.java @@ -71,15 +71,7 @@ protected PutComposableIndexTemplateAction.Request mutateInstance(PutComposableI public void testPutGlobalTemplatesCannotHaveHiddenIndexSetting() { Template template = new Template(Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, true).build(), null, null); - ComposableIndexTemplate globalTemplate = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("*"), - template, - null, - null, - null, - null, - null - ); + ComposableIndexTemplate globalTemplate = new ComposableIndexTemplate(List.of("*"), template, null, null, null, null, null); PutComposableIndexTemplateAction.Request request = new PutComposableIndexTemplateAction.Request("test"); request.indexTemplate(globalTemplate); diff --git a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTests.java b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTests.java index 5eb395cb05971..6c23092c789d1 100644 --- a/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTests.java +++ b/server/src/test/java/org/opensearch/action/bulk/TransportBulkActionTests.java @@ -74,6 +74,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; import java.util.concurrent.TimeUnit; @@ -343,19 +344,17 @@ public void testIncludesSystem() { ".bar", new Index(IndexMetadata.builder(".bar").settings(settings).system(true).numberOfShards(1).numberOfReplicas(0).build()) ); - SystemIndices systemIndices = new SystemIndices( - org.opensearch.common.collect.Map.of("plugin", org.opensearch.common.collect.List.of(new SystemIndexDescriptor(".test", ""))) - ); - List onlySystem = org.opensearch.common.collect.List.of(".foo", ".bar"); + SystemIndices systemIndices = new SystemIndices(Map.of("plugin", List.of(new SystemIndexDescriptor(".test", "")))); + List onlySystem = List.of(".foo", ".bar"); assertTrue(bulkAction.includesSystem(buildBulkRequest(onlySystem), indicesLookup, systemIndices)); - onlySystem = org.opensearch.common.collect.List.of(".foo", ".bar", ".test"); + onlySystem = List.of(".foo", ".bar", ".test"); assertTrue(bulkAction.includesSystem(buildBulkRequest(onlySystem), indicesLookup, systemIndices)); - List nonSystem = org.opensearch.common.collect.List.of("foo", "bar"); + List nonSystem = List.of("foo", "bar"); assertFalse(bulkAction.includesSystem(buildBulkRequest(nonSystem), indicesLookup, systemIndices)); - List mixed = org.opensearch.common.collect.List.of(".foo", ".test", "other"); + List mixed = List.of(".foo", ".test", "other"); assertTrue(bulkAction.includesSystem(buildBulkRequest(mixed), indicesLookup, systemIndices)); } diff --git a/server/src/test/java/org/opensearch/action/support/AutoCreateIndexTests.java b/server/src/test/java/org/opensearch/action/support/AutoCreateIndexTests.java index 068414678e860..7263cbe90c1b7 100644 --- a/server/src/test/java/org/opensearch/action/support/AutoCreateIndexTests.java +++ b/server/src/test/java/org/opensearch/action/support/AutoCreateIndexTests.java @@ -231,7 +231,7 @@ public void testUpdate() { settings, clusterSettings, new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)), - new SystemIndices(org.opensearch.common.collect.Map.of()) + new SystemIndices(Map.of()) ); assertThat(autoCreateIndex.getAutoCreate().isAutoCreateIndex(), equalTo(value)); @@ -257,12 +257,7 @@ private static ClusterState buildClusterState(String... indices) { } private AutoCreateIndex newAutoCreateIndex(Settings settings) { - SystemIndices systemIndices = new SystemIndices( - org.opensearch.common.collect.Map.of( - "plugin", - org.opensearch.common.collect.List.of(new SystemIndexDescriptor(TEST_SYSTEM_INDEX_NAME, "")) - ) - ); + SystemIndices systemIndices = new SystemIndices(Map.of("plugin", List.of(new SystemIndexDescriptor(TEST_SYSTEM_INDEX_NAME, "")))); return new AutoCreateIndex( settings, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), diff --git a/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java b/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java index 70fdb91ee0632..c1ea8c82d4ebf 100644 --- a/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java +++ b/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java @@ -59,6 +59,7 @@ import org.opensearch.test.client.NoOpClient; import org.opensearch.threadpool.ThreadPool; +import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import static org.opensearch.cluster.InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING; @@ -209,11 +210,7 @@ protected void if (request instanceof NodesStatsRequest || request instanceof IndicesStatsRequest) { requestCount++; // ClusterInfoService handles ClusterBlockExceptions quietly, so we invent such an exception to avoid excess logging - listener.onFailure( - new ClusterBlockException( - org.opensearch.common.collect.Set.of(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ALL) - ) - ); + listener.onFailure(new ClusterBlockException(Set.of(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ALL))); } else { fail("unexpected action: " + action.name()); } diff --git a/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java b/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java index 1998dbf9c4c5c..6d4cc67cd8b45 100644 --- a/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java @@ -44,7 +44,6 @@ import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.collect.Map; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.index.Index; @@ -56,6 +55,7 @@ import org.opensearch.test.OpenSearchTestCase; import java.util.List; +import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_VERSION_CREATED; diff --git a/server/src/test/java/org/opensearch/cluster/action/shard/routing/weighted/get/TransportGetWeightedRoutingActionTests.java b/server/src/test/java/org/opensearch/cluster/action/shard/routing/weighted/get/TransportGetWeightedRoutingActionTests.java index df5b6566b503e..a0ac9d94c8c37 100644 --- a/server/src/test/java/org/opensearch/cluster/action/shard/routing/weighted/get/TransportGetWeightedRoutingActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/shard/routing/weighted/get/TransportGetWeightedRoutingActionTests.java @@ -41,6 +41,7 @@ import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -129,7 +130,7 @@ private ClusterState addClusterManagerNodes(ClusterState clusterState) { private ClusterState addDataNodeForAZone(ClusterState clusterState, String zone, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()); - org.opensearch.common.collect.List.of(nodeIds) + List.of(nodeIds) .forEach( nodeId -> nodeBuilder.add( new DiscoveryNode( @@ -148,7 +149,7 @@ private ClusterState addDataNodeForAZone(ClusterState clusterState, String zone, private ClusterState addClusterManagerNodeForAZone(ClusterState clusterState, String zone, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()); - org.opensearch.common.collect.List.of(nodeIds) + List.of(nodeIds) .forEach( nodeId -> nodeBuilder.add( new DiscoveryNode( diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java index 0a534c34b4f86..b091130db0b98 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java @@ -48,6 +48,7 @@ import java.util.Arrays; import java.util.HashSet; +import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; @@ -288,7 +289,7 @@ public void testDescriptionOnUnhealthyNodes() { "local", buildNewFakeTransportAddress(), emptyMap(), - org.opensearch.common.collect.Set.of(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), + Set.of(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); clusterState = ClusterState.builder(ClusterName.DEFAULT) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java b/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java index f6401558221b0..d57fd6c1abd7a 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java @@ -48,13 +48,13 @@ import org.opensearch.cluster.routing.RerouteService; import org.opensearch.cluster.routing.allocation.AllocationService; import org.opensearch.common.UUIDs; -import org.opensearch.common.collect.List; import org.opensearch.common.settings.Settings; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.VersionUtils; import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Map; import static org.hamcrest.Matchers.is; diff --git a/server/src/test/java/org/opensearch/cluster/coordination/OpenSearchNodeCommandTests.java b/server/src/test/java/org/opensearch/cluster/coordination/OpenSearchNodeCommandTests.java index f40c17955467d..853ead71b30fb 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/OpenSearchNodeCommandTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/OpenSearchNodeCommandTests.java @@ -39,7 +39,6 @@ import org.opensearch.cluster.metadata.Metadata; import org.opensearch.common.UUIDs; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.List; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -50,6 +49,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; diff --git a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java index 9736355629fd9..7108e06fe39fc 100644 --- a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java +++ b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionControllerTests.java @@ -40,6 +40,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -265,7 +266,7 @@ public void onFailure(Exception e) { private ClusterState addNodes(ClusterState clusterState, String zone, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()); - org.opensearch.common.collect.List.of(nodeIds).forEach(nodeId -> nodeBuilder.add(newNode(nodeId, singletonMap("zone", zone)))); + List.of(nodeIds).forEach(nodeId -> nodeBuilder.add(newNode(nodeId, singletonMap("zone", zone)))); clusterState = ClusterState.builder(clusterState).nodes(nodeBuilder).build(); return clusterState; } diff --git a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java index 51cd0e6eb23ed..5509a238f700f 100644 --- a/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/decommission/DecommissionServiceTests.java @@ -42,6 +42,7 @@ import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -421,15 +422,14 @@ private void setWeightedRoutingWeights(Map weights) { private ClusterState addDataNodes(ClusterState clusterState, String zone, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()); - org.opensearch.common.collect.List.of(nodeIds).forEach(nodeId -> nodeBuilder.add(newDataNode(nodeId, singletonMap("zone", zone)))); + List.of(nodeIds).forEach(nodeId -> nodeBuilder.add(newDataNode(nodeId, singletonMap("zone", zone)))); clusterState = ClusterState.builder(clusterState).nodes(nodeBuilder).build(); return clusterState; } private ClusterState addClusterManagerNodes(ClusterState clusterState, String zone, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()); - org.opensearch.common.collect.List.of(nodeIds) - .forEach(nodeId -> nodeBuilder.add(newClusterManagerNode(nodeId, singletonMap("zone", zone)))); + List.of(nodeIds).forEach(nodeId -> nodeBuilder.add(newClusterManagerNode(nodeId, singletonMap("zone", zone)))); clusterState = ClusterState.builder(clusterState).nodes(nodeBuilder).build(); return clusterState; } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/IndexNameExpressionResolverTests.java b/server/src/test/java/org/opensearch/cluster/metadata/IndexNameExpressionResolverTests.java index e736e27e5aa44..52a2663f173a7 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/IndexNameExpressionResolverTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/IndexNameExpressionResolverTests.java @@ -2020,14 +2020,7 @@ public void testIndicesAliasesRequestTargetDataStreams() { Metadata.Builder mdBuilder = Metadata.builder() .put(backingIndex, false) - .put( - new DataStream( - dataStreamName, - createTimestampField("@timestamp"), - org.opensearch.common.collect.List.of(backingIndex.getIndex()), - 1 - ) - ); + .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), List.of(backingIndex.getIndex()), 1)); ClusterState state = ClusterState.builder(new ClusterName("_name")).metadata(mdBuilder).build(); { @@ -2248,14 +2241,7 @@ public void testDataStreams() { Metadata.Builder mdBuilder = Metadata.builder() .put(index1, false) .put(index2, false) - .put( - new DataStream( - dataStreamName, - createTimestampField("@timestamp"), - org.opensearch.common.collect.List.of(index1.getIndex(), index2.getIndex()), - 2 - ) - ); + .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), List.of(index1.getIndex(), index2.getIndex()), 2)); ClusterState state = ClusterState.builder(new ClusterName("_name")).metadata(mdBuilder).build(); { @@ -2347,20 +2333,8 @@ public void testDataStreamsWithWildcardExpression() { .put(index2, false) .put(index3, false) .put(index4, false) - .put( - new DataStream( - dataStream1, - createTimestampField("@timestamp"), - org.opensearch.common.collect.List.of(index1.getIndex(), index2.getIndex()) - ) - ) - .put( - new DataStream( - dataStream2, - createTimestampField("@timestamp"), - org.opensearch.common.collect.List.of(index3.getIndex(), index4.getIndex()) - ) - ); + .put(new DataStream(dataStream1, createTimestampField("@timestamp"), List.of(index1.getIndex(), index2.getIndex()))) + .put(new DataStream(dataStream2, createTimestampField("@timestamp"), List.of(index3.getIndex(), index4.getIndex()))); ClusterState state = ClusterState.builder(new ClusterName("_name")).metadata(mdBuilder).build(); { @@ -2417,20 +2391,8 @@ public void testDataStreamsWithClosedBackingIndicesAndWildcardExpressions() { .put(index2, false) .put(index3, false) .put(index4, false) - .put( - new DataStream( - dataStream1, - createTimestampField("@timestamp"), - org.opensearch.common.collect.List.of(index1.getIndex(), index2.getIndex()) - ) - ) - .put( - new DataStream( - dataStream2, - createTimestampField("@timestamp"), - org.opensearch.common.collect.List.of(index3.getIndex(), index4.getIndex()) - ) - ); + .put(new DataStream(dataStream1, createTimestampField("@timestamp"), List.of(index1.getIndex(), index2.getIndex()))) + .put(new DataStream(dataStream2, createTimestampField("@timestamp"), List.of(index3.getIndex(), index4.getIndex()))); ClusterState state = ClusterState.builder(new ClusterName("_name")).metadata(mdBuilder).build(); IndicesOptions indicesOptions = IndicesOptions.STRICT_EXPAND_OPEN; diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java index b70e5e798f9f0..66196331093bf 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java @@ -946,13 +946,7 @@ public void testClusterStateCreateIndexThrowsWriteIndexValidationException() thr assertThat( expectThrows( IllegalStateException.class, - () -> clusterStateCreateIndex( - currentClusterState, - org.opensearch.common.collect.Set.of(), - newIndex, - (state, reason) -> state, - null - ) + () -> clusterStateCreateIndex(currentClusterState, Set.of(), newIndex, (state, reason) -> state, null) ).getMessage(), startsWith("alias [alias1] has more than one write index [") ); @@ -977,7 +971,7 @@ public void testClusterStateCreateIndex() { ClusterState updatedClusterState = clusterStateCreateIndex( currentClusterState, - org.opensearch.common.collect.Set.of(INDEX_READ_ONLY_BLOCK), + Set.of(INDEX_READ_ONLY_BLOCK), newIndexMetadata, rerouteRoutingTable, null @@ -1016,7 +1010,7 @@ public void testClusterStateCreateIndexWithMetadataTransaction() { ClusterState updatedClusterState = clusterStateCreateIndex( currentClusterState, - org.opensearch.common.collect.Set.of(INDEX_READ_ONLY_BLOCK), + Set.of(INDEX_READ_ONLY_BLOCK), newIndexMetadata, (clusterState, y) -> clusterState, metadataTransformer diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataDeleteIndexServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataDeleteIndexServiceTests.java index 5caea9f5bf674..dbff833cfee60 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataDeleteIndexServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataDeleteIndexServiceTests.java @@ -98,7 +98,7 @@ public void testDeleteSnapshotting() { String index = randomAlphaOfLength(5); Snapshot snapshot = new Snapshot("doesn't matter", new SnapshotId("snapshot name", "snapshot uuid")); SnapshotsInProgress snaps = SnapshotsInProgress.of( - org.opensearch.common.collect.List.of( + List.of( new SnapshotsInProgress.Entry( snapshot, true, @@ -153,14 +153,14 @@ public void testDeleteBackingIndexForDataStream() { int numBackingIndices = randomIntBetween(2, 5); String dataStreamName = randomAlphaOfLength(6).toLowerCase(Locale.ROOT); ClusterState before = DataStreamTestHelper.getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of(new Tuple<>(dataStreamName, numBackingIndices)), - org.opensearch.common.collect.List.of() + List.of(new Tuple<>(dataStreamName, numBackingIndices)), + List.of() ); int numIndexToDelete = randomIntBetween(1, numBackingIndices - 1); Index indexToDelete = before.metadata().index(DataStream.getDefaultBackingIndexName(dataStreamName, numIndexToDelete)).getIndex(); - ClusterState after = service.deleteIndices(before, org.opensearch.common.collect.Set.of(indexToDelete)); + ClusterState after = service.deleteIndices(before, Set.of(indexToDelete)); assertThat(after.metadata().getIndices().get(indexToDelete.getName()), IsNull.nullValue()); assertThat(after.metadata().getIndices().size(), equalTo(numBackingIndices - 1)); @@ -175,8 +175,8 @@ public void testDeleteMultipleBackingIndexForDataStream() { int numBackingIndicesToDelete = randomIntBetween(2, numBackingIndices - 1); String dataStreamName = randomAlphaOfLength(6).toLowerCase(Locale.ROOT); ClusterState before = DataStreamTestHelper.getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of(new Tuple<>(dataStreamName, numBackingIndices)), - org.opensearch.common.collect.List.of() + List.of(new Tuple<>(dataStreamName, numBackingIndices)), + List.of() ); List indexNumbersToDelete = randomSubsetOf( @@ -204,15 +204,12 @@ public void testDeleteCurrentWriteIndexForDataStream() { int numBackingIndices = randomIntBetween(1, 5); String dataStreamName = randomAlphaOfLength(6).toLowerCase(Locale.ROOT); ClusterState before = DataStreamTestHelper.getClusterStateWithDataStreams( - org.opensearch.common.collect.List.of(new Tuple<>(dataStreamName, numBackingIndices)), - org.opensearch.common.collect.List.of() + List.of(new Tuple<>(dataStreamName, numBackingIndices)), + List.of() ); Index indexToDelete = before.metadata().index(DataStream.getDefaultBackingIndexName(dataStreamName, numBackingIndices)).getIndex(); - Exception e = expectThrows( - IllegalArgumentException.class, - () -> service.deleteIndices(before, org.opensearch.common.collect.Set.of(indexToDelete)) - ); + Exception e = expectThrows(IllegalArgumentException.class, () -> service.deleteIndices(before, Set.of(indexToDelete))); assertThat( e.getMessage(), diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexStateServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexStateServiceTests.java index 72b22e0efc09b..70ad47634d2da 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexStateServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexStateServiceTests.java @@ -360,10 +360,7 @@ public void testCloseCurrentWriteIndexForDataStream() { dataStreamsToCreate.add(new Tuple<>(dataStreamName, numBackingIndices)); writeIndices.add(DataStream.getDefaultBackingIndexName(dataStreamName, numBackingIndices)); } - ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams( - dataStreamsToCreate, - org.opensearch.common.collect.List.of() - ); + ClusterState cs = DeleteDataStreamRequestTests.getClusterStateWithDataStreams(dataStreamsToCreate, List.of()); ClusterService clusterService = mock(ClusterService.class); when(clusterService.state()).thenReturn(cs); diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java index d3b2bec40abbd..886d71b159634 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataIndexTemplateServiceTests.java @@ -430,9 +430,9 @@ public void testUpdateComponentTemplateWithIndexHiddenSetting() throws Exception assertNotNull(state.metadata().componentTemplates().get("foo")); ComposableIndexTemplate firstGlobalIndexTemplate = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("*"), + List.of("*"), template, - org.opensearch.common.collect.List.of("foo"), + List.of("foo"), 1L, null, null, @@ -441,9 +441,9 @@ public void testUpdateComponentTemplateWithIndexHiddenSetting() throws Exception state = metadataIndexTemplateService.addIndexTemplateV2(state, true, "globalindextemplate1", firstGlobalIndexTemplate); ComposableIndexTemplate secondGlobalIndexTemplate = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("*"), + List.of("*"), template, - org.opensearch.common.collect.List.of("foo"), + List.of("foo"), 2L, null, null, @@ -452,9 +452,9 @@ public void testUpdateComponentTemplateWithIndexHiddenSetting() throws Exception state = metadataIndexTemplateService.addIndexTemplateV2(state, true, "globalindextemplate2", secondGlobalIndexTemplate); ComposableIndexTemplate fooPatternIndexTemplate = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("foo-*"), + List.of("foo-*"), template, - org.opensearch.common.collect.List.of("foo"), + List.of("foo"), 3L, null, null, @@ -617,9 +617,9 @@ public void onFailure(Exception e) { waitToCreateComponentTemplate.await(10, TimeUnit.SECONDS); ComposableIndexTemplate globalIndexTemplate = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("*"), + List.of("*"), null, - org.opensearch.common.collect.List.of("ct-with-index-hidden-setting"), + List.of("ct-with-index-hidden-setting"), null, null, null, @@ -942,9 +942,9 @@ public void testFindV2InvalidGlobalTemplate() { try { // add an invalid global template that specifies the `index.hidden` setting ComposableIndexTemplate invalidGlobalTemplate = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("*"), + List.of("*"), templateWithHiddenSetting, - org.opensearch.common.collect.List.of("ct"), + List.of("ct"), 5L, 1L, null, @@ -953,9 +953,7 @@ public void testFindV2InvalidGlobalTemplate() { Metadata invalidGlobalTemplateMetadata = Metadata.builder() .putCustom( ComposableIndexTemplateMetadata.TYPE, - new ComposableIndexTemplateMetadata( - org.opensearch.common.collect.Map.of("invalid_global_template", invalidGlobalTemplate) - ) + new ComposableIndexTemplateMetadata(Map.of("invalid_global_template", invalidGlobalTemplate)) ) .build(); @@ -1214,7 +1212,7 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex { ComposableIndexTemplate it = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("logs*"), + List.of("logs*"), new Template( null, new CompressedXContent( @@ -1228,7 +1226,7 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex ), null ), - org.opensearch.common.collect.List.of("ct1"), + List.of("ct1"), 0L, 1L, null, @@ -1246,7 +1244,7 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex assertThat(mappings.size(), equalTo(4)); List> parsedMappings = mappings.stream().map(m -> { try { - return MapperService.parseMapping(new NamedXContentRegistry(org.opensearch.common.collect.List.of()), m.string()); + return MapperService.parseMapping(new NamedXContentRegistry(List.of()), m.string()); } catch (Exception e) { logger.error(e); fail("failed to parse mappings: " + m.string()); @@ -1254,38 +1252,23 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex } }).collect(Collectors.toList()); - Map firstParsedMapping = org.opensearch.common.collect.Map.of( + Map firstParsedMapping = Map.of( "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of(TIMESTAMP_FIELD.getName(), org.opensearch.common.collect.Map.of("type", "date")) - ) + Map.of("properties", Map.of(TIMESTAMP_FIELD.getName(), Map.of("type", "date"))) ); assertThat(parsedMappings.get(0), equalTo(firstParsedMapping)); - Map secondMapping = org.opensearch.common.collect.Map.of( - "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of("field1", org.opensearch.common.collect.Map.of("type", "keyword")) - ) - ); + Map secondMapping = Map.of("_doc", Map.of("properties", Map.of("field1", Map.of("type", "keyword")))); assertThat(parsedMappings.get(1), equalTo(secondMapping)); - Map thirdMapping = org.opensearch.common.collect.Map.of( - "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of("field2", org.opensearch.common.collect.Map.of("type", "integer")) - ) - ); + Map thirdMapping = Map.of("_doc", Map.of("properties", Map.of("field2", Map.of("type", "integer")))); assertThat(parsedMappings.get(2), equalTo(thirdMapping)); } { // indices matched by templates without the data stream field defined don't get the default @timestamp mapping ComposableIndexTemplate it = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("timeseries*"), + List.of("timeseries*"), new Template( null, new CompressedXContent( @@ -1299,7 +1282,7 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex ), null ), - org.opensearch.common.collect.List.of("ct1"), + List.of("ct1"), 0L, 1L, null, @@ -1313,7 +1296,7 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex assertThat(mappings.size(), equalTo(2)); List> parsedMappings = mappings.stream().map(m -> { try { - return MapperService.parseMapping(new NamedXContentRegistry(org.opensearch.common.collect.List.of()), m.string()); + return MapperService.parseMapping(new NamedXContentRegistry(List.of()), m.string()); } catch (Exception e) { logger.error(e); fail("failed to parse mappings: " + m.string()); @@ -1321,22 +1304,10 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex } }).collect(Collectors.toList()); - Map firstMapping = org.opensearch.common.collect.Map.of( - "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of("field1", org.opensearch.common.collect.Map.of("type", "keyword")) - ) - ); + Map firstMapping = Map.of("_doc", Map.of("properties", Map.of("field1", Map.of("type", "keyword")))); assertThat(parsedMappings.get(0), equalTo(firstMapping)); - Map secondMapping = org.opensearch.common.collect.Map.of( - "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of("field2", org.opensearch.common.collect.Map.of("type", "integer")) - ) - ); + Map secondMapping = Map.of("_doc", Map.of("properties", Map.of("field2", Map.of("type", "integer")))); assertThat(parsedMappings.get(1), equalTo(secondMapping)); // a default @timestamp mapping will not be added if the matching template doesn't have the data stream field configured, even @@ -1351,7 +1322,7 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex assertThat(mappings.size(), equalTo(2)); parsedMappings = mappings.stream().map(m -> { try { - return MapperService.parseMapping(new NamedXContentRegistry(org.opensearch.common.collect.List.of()), m.string()); + return MapperService.parseMapping(new NamedXContentRegistry(List.of()), m.string()); } catch (Exception e) { logger.error(e); fail("failed to parse mappings: " + m.string()); @@ -1359,22 +1330,10 @@ public void testDefinedTimestampMappingIsAddedForDataStreamTemplates() throws Ex } }).collect(Collectors.toList()); - firstMapping = org.opensearch.common.collect.Map.of( - "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of("field1", org.opensearch.common.collect.Map.of("type", "keyword")) - ) - ); + firstMapping = Map.of("_doc", Map.of("properties", Map.of("field1", Map.of("type", "keyword")))); assertThat(parsedMappings.get(0), equalTo(firstMapping)); - secondMapping = org.opensearch.common.collect.Map.of( - "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of("field2", org.opensearch.common.collect.Map.of("type", "integer")) - ) - ); + secondMapping = Map.of("_doc", Map.of("properties", Map.of("field2", Map.of("type", "integer")))); assertThat(parsedMappings.get(1), equalTo(secondMapping)); } } @@ -1405,9 +1364,9 @@ public void testUserDefinedMappingTakesPrecedenceOverDefault() throws Exception state = service.addComponentTemplate(state, true, "ct1", ct1); ComposableIndexTemplate it = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("logs*"), + List.of("logs*"), null, - org.opensearch.common.collect.List.of("ct1"), + List.of("ct1"), 0L, 1L, null, @@ -1425,7 +1384,7 @@ public void testUserDefinedMappingTakesPrecedenceOverDefault() throws Exception assertThat(mappings.size(), equalTo(3)); List> parsedMappings = mappings.stream().map(m -> { try { - return MapperService.parseMapping(new NamedXContentRegistry(org.opensearch.common.collect.List.of()), m.string()); + return MapperService.parseMapping(new NamedXContentRegistry(List.of()), m.string()); } catch (Exception e) { logger.error(e); fail("failed to parse mappings: " + m.string()); @@ -1433,24 +1392,15 @@ public void testUserDefinedMappingTakesPrecedenceOverDefault() throws Exception } }).collect(Collectors.toList()); - Map firstMapping = org.opensearch.common.collect.Map.of( + Map firstMapping = Map.of( "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of(TIMESTAMP_FIELD.getName(), org.opensearch.common.collect.Map.of("type", "date")) - ) + Map.of("properties", Map.of(TIMESTAMP_FIELD.getName(), Map.of("type", "date"))) ); assertThat(parsedMappings.get(0), equalTo(firstMapping)); - Map secondMapping = org.opensearch.common.collect.Map.of( + Map secondMapping = Map.of( "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of( - TIMESTAMP_FIELD.getName(), - org.opensearch.common.collect.Map.of("type", "date_nanos") - ) - ) + Map.of("properties", Map.of(TIMESTAMP_FIELD.getName(), Map.of("type", "date_nanos"))) ); assertThat(parsedMappings.get(1), equalTo(secondMapping)); } @@ -1471,7 +1421,7 @@ public void testUserDefinedMappingTakesPrecedenceOverDefault() throws Exception null ); ComposableIndexTemplate it = new ComposableIndexTemplate( - org.opensearch.common.collect.List.of("timeseries*"), + List.of("timeseries*"), template, null, 0L, @@ -1491,31 +1441,22 @@ public void testUserDefinedMappingTakesPrecedenceOverDefault() throws Exception assertThat(mappings.size(), equalTo(3)); List> parsedMappings = mappings.stream().map(m -> { try { - return MapperService.parseMapping(new NamedXContentRegistry(org.opensearch.common.collect.List.of()), m.string()); + return MapperService.parseMapping(new NamedXContentRegistry(List.of()), m.string()); } catch (Exception e) { logger.error(e); fail("failed to parse mappings: " + m.string()); return null; } }).collect(Collectors.toList()); - Map firstMapping = org.opensearch.common.collect.Map.of( + Map firstMapping = Map.of( "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of(TIMESTAMP_FIELD.getName(), org.opensearch.common.collect.Map.of("type", "date")) - ) + Map.of("properties", Map.of(TIMESTAMP_FIELD.getName(), Map.of("type", "date"))) ); assertThat(parsedMappings.get(0), equalTo(firstMapping)); - Map secondMapping = org.opensearch.common.collect.Map.of( + Map secondMapping = Map.of( "_doc", - org.opensearch.common.collect.Map.of( - "properties", - org.opensearch.common.collect.Map.of( - TIMESTAMP_FIELD.getName(), - org.opensearch.common.collect.Map.of("type", "date_nanos") - ) - ) + Map.of("properties", Map.of(TIMESTAMP_FIELD.getName(), Map.of("type", "date_nanos"))) ); assertThat(parsedMappings.get(1), equalTo(secondMapping)); } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataTests.java index 55161c6f488f2..cb675cb9308af 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataTests.java @@ -1065,7 +1065,7 @@ public void testBuilderRejectsDataStreamThatConflictsWithIndex() { IndexMetadata.builder(dataStreamName).settings(settings(Version.CURRENT)).numberOfShards(1).numberOfReplicas(1).build(), false ) - .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), org.opensearch.common.collect.List.of(idx.getIndex()))); + .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), List.of(idx.getIndex()))); IllegalStateException e = expectThrows(IllegalStateException.class, b::build); assertThat( @@ -1084,7 +1084,7 @@ public void testBuilderRejectsDataStreamThatConflictsWithAlias() { IndexMetadata idx = createFirstBackingIndex(dataStreamName).putAlias(AliasMetadata.builder(dataStreamName).build()).build(); Metadata.Builder b = Metadata.builder() .put(idx, false) - .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), org.opensearch.common.collect.List.of(idx.getIndex()))); + .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), List.of(idx.getIndex()))); IllegalStateException e = expectThrows(IllegalStateException.class, b::build); assertThat( @@ -1107,13 +1107,7 @@ public void testBuilderRejectsDataStreamWithConflictingBackingIndices() { Metadata.Builder b = Metadata.builder() .put(validIdx, false) .put(invalidIdx, false) - .put( - new DataStream( - dataStreamName, - createTimestampField("@timestamp"), - org.opensearch.common.collect.List.of(validIdx.getIndex()) - ) - ); + .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), List.of(validIdx.getIndex()))); IllegalStateException e = expectThrows(IllegalStateException.class, b::build); assertThat( @@ -1134,7 +1128,7 @@ public void testBuilderRejectsDataStreamWithConflictingBackingAlias() { IndexMetadata idx = createFirstBackingIndex(dataStreamName).putAlias(new AliasMetadata.Builder(conflictingName)).build(); Metadata.Builder b = Metadata.builder() .put(idx, false) - .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), org.opensearch.common.collect.List.of(idx.getIndex()))); + .put(new DataStream(dataStreamName, createTimestampField("@timestamp"), List.of(idx.getIndex()))); IllegalStateException e = expectThrows(IllegalStateException.class, b::build); assertThat( @@ -1269,7 +1263,7 @@ public void testValidateDataStreamsThrowsExceptionOnConflict() { Index index = standaloneIndexConflictingWithBackingIndices.getIndex(); indicesLookup.put(index.getName(), new IndexAbstraction.Index(standaloneIndexConflictingWithBackingIndices, null)); - DataStreamMetadata dataStreamMetadata = new DataStreamMetadata(org.opensearch.common.collect.Map.of(dataStreamName, dataStream)); + DataStreamMetadata dataStreamMetadata = new DataStreamMetadata(Map.of(dataStreamName, dataStream)); IllegalStateException illegalStateException = expectThrows( IllegalStateException.class, @@ -1362,7 +1356,7 @@ public void testValidateDataStreamsAllowsPrefixedBackingIndices() { indicesLookup.put(indexMeta.getIndex().getName(), new IndexAbstraction.Index(indexMeta, dataStreamAbstraction)); } } - DataStreamMetadata dataStreamMetadata = new DataStreamMetadata(org.opensearch.common.collect.Map.of(dataStreamName, dataStream)); + DataStreamMetadata dataStreamMetadata = new DataStreamMetadata(Map.of(dataStreamName, dataStream)); // prefixed indices with a lower generation than the data stream's generation are allowed even if the non-prefixed, matching the // data stream backing indices naming pattern, indices are already in the system diff --git a/server/src/test/java/org/opensearch/cluster/metadata/ToAndFromJsonMetadataTests.java b/server/src/test/java/org/opensearch/cluster/metadata/ToAndFromJsonMetadataTests.java index 5ac2796e130f9..b87412a6caadd 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/ToAndFromJsonMetadataTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/ToAndFromJsonMetadataTests.java @@ -51,6 +51,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import static org.opensearch.cluster.DataStreamTestHelper.createFirstBackingIndex; @@ -128,8 +129,8 @@ public void testSimpleJsonFromAndTo() throws IOException { ) .put(idx1, false) .put(idx2, false) - .put(new DataStream("data-stream1", createTimestampField("@timestamp"), org.opensearch.common.collect.List.of(idx1.getIndex()))) - .put(new DataStream("data-stream2", createTimestampField("@timestamp"), org.opensearch.common.collect.List.of(idx2.getIndex()))) + .put(new DataStream("data-stream1", createTimestampField("@timestamp"), List.of(idx1.getIndex()))) + .put(new DataStream("data-stream2", createTimestampField("@timestamp"), List.of(idx2.getIndex()))) .build(); XContentBuilder builder = JsonXContent.contentBuilder(); diff --git a/server/src/test/java/org/opensearch/cluster/metadata/WildcardExpressionResolverTests.java b/server/src/test/java/org/opensearch/cluster/metadata/WildcardExpressionResolverTests.java index e4027234ac0b4..03807fb5f8c4d 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/WildcardExpressionResolverTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/WildcardExpressionResolverTests.java @@ -302,7 +302,7 @@ public void testResolveDataStreams() { new DataStream( dataStreamName, createTimestampField("@timestamp"), - org.opensearch.common.collect.List.of(firstBackingIndexMetadata.getIndex(), secondBackingIndexMetadata.getIndex()) + List.of(firstBackingIndexMetadata.getIndex(), secondBackingIndexMetadata.getIndex()) ) ); diff --git a/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java index 65fc1b902f9a4..81464fcd2610d 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java @@ -43,6 +43,7 @@ import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -130,7 +131,7 @@ private ClusterState addClusterManagerNodes(ClusterState clusterState) { private ClusterState addDataNodeForAZone(ClusterState clusterState, String zone, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()); - org.opensearch.common.collect.List.of(nodeIds) + List.of(nodeIds) .forEach( nodeId -> nodeBuilder.add( new DiscoveryNode( @@ -149,7 +150,7 @@ private ClusterState addDataNodeForAZone(ClusterState clusterState, String zone, private ClusterState addClusterManagerNodeForAZone(ClusterState clusterState, String zone, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()); - org.opensearch.common.collect.List.of(nodeIds) + List.of(nodeIds) .forEach( nodeId -> nodeBuilder.add( new DiscoveryNode( diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/NodeLoadAwareAllocationTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/NodeLoadAwareAllocationTests.java index c4dcae84581cb..0d53e4bf8c4ed 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/NodeLoadAwareAllocationTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/NodeLoadAwareAllocationTests.java @@ -28,6 +28,7 @@ import org.opensearch.gateway.GatewayAllocator; import org.opensearch.test.gateway.TestGatewayAllocator; +import java.util.List; import java.util.Map; import static java.util.Collections.singletonMap; @@ -43,7 +44,7 @@ public class NodeLoadAwareAllocationTests extends OpenSearchAllocationTestCase { public void testNewUnassignedPrimaryAllocationOnOverload() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 5, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -136,7 +137,7 @@ public void testNewUnassignedPrimaryAllocationOnOverload() { public void testNoAllocationLimitsOnOverloadForDisabledLoadFactor() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 5, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -231,7 +232,7 @@ public void testNoAllocationLimitsOnOverloadForDisabledLoadFactor() { public void testExistingPrimariesAllocationOnOverload() { GatewayAllocator gatewayAllocator = new TestGatewayAllocator(); AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 5, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -317,7 +318,7 @@ public void testExistingPrimariesAllocationOnOverload() { logger.info("--> change the overload load factor to zero and verify if unassigned primaries on disk get assigned despite overload"); strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 5, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -383,7 +384,7 @@ public void testExistingPrimariesAllocationOnOverload() { public void testSingleZoneOneReplicaLimitsShardAllocationOnOverload() { GatewayAllocator gatewayAllocator = new TestGatewayAllocator(); AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 5, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -494,7 +495,7 @@ public void testSingleZoneOneReplicaLimitsShardAllocationOnOverload() { logger.info("change settings to allow unassigned primaries"); strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 5, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -534,7 +535,7 @@ public void testSingleZoneOneReplicaLimitsShardAllocationOnOverload() { public void testThreeZoneTwoReplicaLimitsShardAllocationOnOverload() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 15, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -643,7 +644,7 @@ public void testThreeZoneTwoReplicaLimitsShardAllocationOnOverload() { public void testThreeZoneOneReplicaLimitsShardAllocationOnOverload() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 15, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -738,7 +739,7 @@ public void testThreeZoneOneReplicaLimitsShardAllocationOnOverload() { public void testThreeZoneTwoReplicaLimitsShardAllocationOnOverloadAcrossZones() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 9, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -832,7 +833,7 @@ public void testThreeZoneTwoReplicaLimitsShardAllocationOnOverloadAcrossZones() public void testSingleZoneTwoReplicaLimitsReplicaAllocationOnOverload() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 3, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -893,7 +894,7 @@ public void testSingleZoneTwoReplicaLimitsReplicaAllocationOnOverload() { public void testSingleZoneOneReplicaLimitsReplicaAllocationOnOverload() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 5, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -976,7 +977,7 @@ public void testSingleZoneOneReplicaLimitsReplicaAllocationOnOverload() { public void testThreeZoneTwoReplicaLimitsReplicaAllocationUnderFullZoneFailure() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 15, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -1087,7 +1088,7 @@ public void testThreeZoneTwoReplicaLimitsReplicaAllocationUnderFullZoneFailure() public void testThreeZoneOneReplicaWithSkewFactorZeroAllShardsAssignedAfterRecovery() { AllocationService strategy = createAllocationServiceWithAdditionalSettings( - org.opensearch.common.collect.Map.of( + Map.of( NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_PROVISIONED_CAPACITY_SETTING.getKey(), 15, NodeLoadAwareAllocationDecider.CLUSTER_ROUTING_ALLOCATION_LOAD_AWARENESS_SKEW_FACTOR_SETTING.getKey(), @@ -1201,13 +1202,13 @@ public void testThreeZoneOneReplicaWithSkewFactorZeroAllShardsAssignedAfterRecov private ClusterState removeNodes(ClusterState clusterState, AllocationService allocationService, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.getNodes()); - org.opensearch.common.collect.List.of(nodeIds).forEach(nodeId -> nodeBuilder.remove(nodeId)); + List.of(nodeIds).forEach(nodeId -> nodeBuilder.remove(nodeId)); return allocationService.disassociateDeadNodes(ClusterState.builder(clusterState).nodes(nodeBuilder).build(), true, "reroute"); } private ClusterState addNodes(ClusterState clusterState, AllocationService allocationService, String zone, String... nodeIds) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.nodes()); - org.opensearch.common.collect.List.of(nodeIds).forEach(nodeId -> nodeBuilder.add(newNode(nodeId, singletonMap("zone", zone)))); + List.of(nodeIds).forEach(nodeId -> nodeBuilder.add(newNode(nodeId, singletonMap("zone", zone)))); clusterState = ClusterState.builder(clusterState).nodes(nodeBuilder).build(); return allocationService.reroute(clusterState, "reroute"); } diff --git a/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java b/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java index b5fd6097832fb..ca7e04cd70584 100644 --- a/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java +++ b/server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java @@ -225,14 +225,8 @@ public void testExtractValueWithNullValue() throws Exception { assertNull(XContentMapValues.extractValue("object1.missing", map, "NULL")); assertEquals("NULL", XContentMapValues.extractValue("other_field", map, "NULL")); - assertEquals( - org.opensearch.common.collect.List.of("value1", "NULL", "value2"), - XContentMapValues.extractValue("array", map, "NULL") - ); - assertEquals( - org.opensearch.common.collect.List.of("NULL", "value"), - XContentMapValues.extractValue("object_array.field", map, "NULL") - ); + assertEquals(List.of("value1", "NULL", "value2"), XContentMapValues.extractValue("array", map, "NULL")); + assertEquals(List.of("NULL", "value"), XContentMapValues.extractValue("object_array.field", map, "NULL")); assertEquals("NULL", XContentMapValues.extractValue("object1.object2.field", map, "NULL")); } diff --git a/server/src/test/java/org/opensearch/index/get/DocumentFieldTests.java b/server/src/test/java/org/opensearch/index/get/DocumentFieldTests.java index f9a8805f4ca67..06893c216e776 100644 --- a/server/src/test/java/org/opensearch/index/get/DocumentFieldTests.java +++ b/server/src/test/java/org/opensearch/index/get/DocumentFieldTests.java @@ -34,7 +34,6 @@ import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.Map; import org.opensearch.common.collect.Tuple; import org.opensearch.common.document.DocumentField; import org.opensearch.core.xcontent.ToXContent; @@ -49,6 +48,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.function.Predicate; import java.util.function.Supplier; diff --git a/server/src/test/java/org/opensearch/index/mapper/DateFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/DateFieldMapperTests.java index 6a3f47eac5265..72944eb7743af 100644 --- a/server/src/test/java/org/opensearch/index/mapper/DateFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/DateFieldMapperTests.java @@ -34,7 +34,6 @@ import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.IndexableField; -import org.opensearch.common.collect.List; import org.opensearch.common.time.DateFormatter; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.termvectors.TermVectorsService; @@ -44,6 +43,7 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.util.List; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.notNullValue; diff --git a/server/src/test/java/org/opensearch/index/mapper/DocumentMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/DocumentMapperTests.java index 9a1113d04a6f6..fa6ef72552faf 100644 --- a/server/src/test/java/org/opensearch/index/mapper/DocumentMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/DocumentMapperTests.java @@ -266,12 +266,7 @@ public void testMergeMetaForIndexTemplate() throws IOException { b.endObject(); })); - Map expected = org.opensearch.common.collect.Map.of( - "field", - "value", - "object", - org.opensearch.common.collect.Map.of("field1", "value1", "field2", "value2") - ); + Map expected = Map.of("field", "value", "object", Map.of("field1", "value1", "field2", "value2")); assertThat(initMapper.meta(), equalTo(expected)); DocumentMapper updatedMapper = createDocumentMapper(fieldMapping(b -> b.field("type", "text"))); @@ -293,12 +288,7 @@ public void testMergeMetaForIndexTemplate() throws IOException { })); mergedMapper = mergedMapper.merge(updatedMapper.mapping(), MergeReason.INDEX_TEMPLATE); - expected = org.opensearch.common.collect.Map.of( - "field", - "value", - "object", - org.opensearch.common.collect.Map.of("field1", "value1", "field2", "new_value", "field3", "value3") - ); + expected = Map.of("field", "value", "object", Map.of("field1", "value1", "field2", "new_value", "field3", "value3")); assertThat(mergedMapper.meta(), equalTo(expected)); } } diff --git a/server/src/test/java/org/opensearch/index/mapper/FieldTypeLookupTests.java b/server/src/test/java/org/opensearch/index/mapper/FieldTypeLookupTests.java index 9aa9c7d5074e7..583f9ab48edad 100644 --- a/server/src/test/java/org/opensearch/index/mapper/FieldTypeLookupTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/FieldTypeLookupTests.java @@ -32,13 +32,13 @@ package org.opensearch.index.mapper; -import org.opensearch.common.collect.Set; import org.opensearch.test.OpenSearchTestCase; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; +import java.util.Set; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; diff --git a/server/src/test/java/org/opensearch/index/mapper/GeoPointFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/GeoPointFieldMapperTests.java index 94ce458ff4b65..4112d792aa087 100644 --- a/server/src/test/java/org/opensearch/index/mapper/GeoPointFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/GeoPointFieldMapperTests.java @@ -56,7 +56,7 @@ public class GeoPointFieldMapperTests extends FieldMapperTestCase2 unsupportedProperties() { - return org.opensearch.common.collect.Set.of("analyzer", "similarity", "doc_values"); + return Set.of("analyzer", "similarity", "doc_values"); } @Override diff --git a/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldMapperTests.java index d9101df81a081..4a5c342883cc8 100644 --- a/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldMapperTests.java @@ -33,7 +33,6 @@ import org.opensearch.common.Explicit; import org.opensearch.common.Strings; -import org.opensearch.common.collect.List; import org.opensearch.common.geo.builders.ShapeBuilder; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.ToXContent; @@ -45,6 +44,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Set; import static org.hamcrest.Matchers.containsString; @@ -56,7 +56,7 @@ public class GeoShapeFieldMapperTests extends FieldMapperTestCase2 unsupportedProperties() { - return org.opensearch.common.collect.Set.of("analyzer", "similarity", "store"); + return Set.of("analyzer", "similarity", "store"); } @Override diff --git a/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldTypeTests.java index f4767403ffbf7..127117ee9c7b2 100644 --- a/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/GeoShapeFieldTypeTests.java @@ -49,13 +49,13 @@ public void testFetchSourceValue() throws IOException { MappedFieldType mapper = new GeoShapeFieldMapper.Builder("field").build(context).fieldType(); - Map jsonLineString = org.opensearch.common.collect.Map.of( + Map jsonLineString = Map.of( "type", "LineString", "coordinates", Arrays.asList(Arrays.asList(42.0, 27.1), Arrays.asList(30.0, 50.0)) ); - Map jsonPoint = org.opensearch.common.collect.Map.of("type", "Point", "coordinates", Arrays.asList(14.0, 15.0)); + Map jsonPoint = Map.of("type", "Point", "coordinates", Arrays.asList(14.0, 15.0)); String wktLineString = "LINESTRING (42.0 27.1, 30.0 50.0)"; String wktPoint = "POINT (14.0 15.0)"; diff --git a/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldTypeTests.java index c2c6293eec4bd..36edc4e92504b 100644 --- a/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/IpRangeFieldTypeTests.java @@ -47,11 +47,8 @@ public void testFetchSourceValue() throws IOException { Mapper.BuilderContext context = new Mapper.BuilderContext(settings, new ContentPath()); RangeFieldMapper mapper = new RangeFieldMapper.Builder("field", RangeType.IP, true, Version.V_EMPTY).build(context); - Map range = org.opensearch.common.collect.Map.of("gte", "2001:db8:0:0:0:0:2:1"); - assertEquals( - Collections.singletonList(org.opensearch.common.collect.Map.of("gte", "2001:db8::2:1")), - fetchSourceValue(mapper.fieldType(), range) - ); + Map range = Map.of("gte", "2001:db8:0:0:0:0:2:1"); + assertEquals(Collections.singletonList(Map.of("gte", "2001:db8::2:1")), fetchSourceValue(mapper.fieldType(), range)); assertEquals(Collections.singletonList("2001:db8::2:1/32"), fetchSourceValue(mapper.fieldType(), "2001:db8:0:0:0:0:2:1/32")); } } diff --git a/server/src/test/java/org/opensearch/index/mapper/KeywordFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/KeywordFieldMapperTests.java index 8346ae720aa5d..7a56143a82afd 100644 --- a/server/src/test/java/org/opensearch/index/mapper/KeywordFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/KeywordFieldMapperTests.java @@ -134,7 +134,7 @@ protected Collection getPlugins() { protected IndexAnalyzers createIndexAnalyzers(IndexSettings indexSettings) { return new IndexAnalyzers( singletonMap("default", new NamedAnalyzer("default", AnalyzerScope.INDEX, new StandardAnalyzer())), - org.opensearch.common.collect.Map.of( + Map.of( "lowercase", new NamedAnalyzer("lowercase", AnalyzerScope.INDEX, new LowercaseNormalizer()), "other_lowercase", diff --git a/server/src/test/java/org/opensearch/index/mapper/KeywordFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/KeywordFieldTypeTests.java index 6b7216a584ca9..ad529c685d6f3 100644 --- a/server/src/test/java/org/opensearch/index/mapper/KeywordFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/KeywordFieldTypeTests.java @@ -72,6 +72,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; public class KeywordFieldTypeTests extends FieldTypeTestCase { @@ -245,18 +246,12 @@ public void testFetchSourceValue() throws IOException { private static IndexAnalyzers createIndexAnalyzers() { return new IndexAnalyzers( - org.opensearch.common.collect.Map.of("default", new NamedAnalyzer("default", AnalyzerScope.INDEX, new StandardAnalyzer())), - org.opensearch.common.collect.Map.ofEntries( - org.opensearch.common.collect.Map.entry( - "lowercase", - new NamedAnalyzer("lowercase", AnalyzerScope.INDEX, new LowercaseNormalizer()) - ), - org.opensearch.common.collect.Map.entry( - "other_lowercase", - new NamedAnalyzer("other_lowercase", AnalyzerScope.INDEX, new LowercaseNormalizer()) - ) + Map.of("default", new NamedAnalyzer("default", AnalyzerScope.INDEX, new StandardAnalyzer())), + Map.ofEntries( + Map.entry("lowercase", new NamedAnalyzer("lowercase", AnalyzerScope.INDEX, new LowercaseNormalizer())), + Map.entry("other_lowercase", new NamedAnalyzer("other_lowercase", AnalyzerScope.INDEX, new LowercaseNormalizer())) ), - org.opensearch.common.collect.Map.of( + Map.of( "lowercase", new NamedAnalyzer( "lowercase", diff --git a/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldMapperTests.java index 09f518b932114..82482141d15f8 100644 --- a/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldMapperTests.java @@ -39,7 +39,6 @@ import org.opensearch.OpenSearchException; import org.opensearch.common.Explicit; import org.opensearch.common.Strings; -import org.opensearch.common.collect.List; import org.opensearch.common.geo.GeoUtils; import org.opensearch.common.geo.ShapeRelation; import org.opensearch.common.geo.SpatialStrategy; @@ -54,6 +53,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.List; import java.util.Set; import static java.util.Collections.singletonMap; @@ -80,7 +80,7 @@ protected LegacyGeoShapeFieldMapper.Builder newBuilder() { @Override protected Set unsupportedProperties() { - return org.opensearch.common.collect.Set.of("analyzer", "similarity", "doc_values", "store"); + return Set.of("analyzer", "similarity", "doc_values", "store"); } @Override diff --git a/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldTypeTests.java index 5157232bea1a2..45161bed1d40e 100644 --- a/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/LegacyGeoShapeFieldTypeTests.java @@ -63,13 +63,13 @@ public void testFetchSourceValue() throws IOException { MappedFieldType mapper = new LegacyGeoShapeFieldMapper.Builder("field").build(context).fieldType(); - Map jsonLineString = org.opensearch.common.collect.Map.of( + Map jsonLineString = Map.of( "type", "LineString", "coordinates", Arrays.asList(Arrays.asList(42.0, 27.1), Arrays.asList(30.0, 50.0)) ); - Map jsonPoint = org.opensearch.common.collect.Map.of("type", "Point", "coordinates", Arrays.asList(14.0, 15.0)); + Map jsonPoint = Map.of("type", "Point", "coordinates", Arrays.asList(14.0, 15.0)); String wktLineString = "LINESTRING (42.0 27.1, 30.0 50.0)"; String wktPoint = "POINT (14.0 15.0)"; diff --git a/server/src/test/java/org/opensearch/index/mapper/NumberFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/NumberFieldMapperTests.java index 008998895132c..8989d237acbe9 100644 --- a/server/src/test/java/org/opensearch/index/mapper/NumberFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/NumberFieldMapperTests.java @@ -55,12 +55,12 @@ public class NumberFieldMapperTests extends AbstractNumericFieldMapperTestCase { @Override protected Set types() { - return org.opensearch.common.collect.Set.of("byte", "short", "integer", "long", "float", "double", "half_float"); + return Set.of("byte", "short", "integer", "long", "float", "double", "half_float"); } @Override protected Set wholeTypes() { - return org.opensearch.common.collect.Set.of("byte", "short", "integer", "long"); + return Set.of("byte", "short", "integer", "long"); } @Override diff --git a/server/src/test/java/org/opensearch/index/mapper/ParametrizedMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/ParametrizedMapperTests.java index e3eaa4d4f9b9c..9c135c806ddc4 100644 --- a/server/src/test/java/org/opensearch/index/mapper/ParametrizedMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/ParametrizedMapperTests.java @@ -68,7 +68,7 @@ public class ParametrizedMapperTests extends MapperServiceTestCase { public static class TestPlugin extends Plugin implements MapperPlugin { @Override public Map getMappers() { - return org.opensearch.common.collect.Map.of("test_mapper", new TypeParser()); + return Map.of("test_mapper", new TypeParser()); } } @@ -218,7 +218,7 @@ protected String contentType() { private static TestMapper fromMapping(String mapping, Version version) { MapperService mapperService = mock(MapperService.class); IndexAnalyzers indexAnalyzers = new IndexAnalyzers( - org.opensearch.common.collect.Map.of( + Map.of( "_standard", Lucene.STANDARD_ANALYZER, "_keyword", diff --git a/server/src/test/java/org/opensearch/index/mapper/RangeFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/RangeFieldMapperTests.java index eb00820176568..4c1dc44f801ea 100644 --- a/server/src/test/java/org/opensearch/index/mapper/RangeFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/RangeFieldMapperTests.java @@ -68,12 +68,12 @@ public class RangeFieldMapperTests extends AbstractNumericFieldMapperTestCase { @Override protected Set types() { - return org.opensearch.common.collect.Set.of("date_range", "ip_range", "float_range", "double_range", "integer_range", "long_range"); + return Set.of("date_range", "ip_range", "float_range", "double_range", "integer_range", "long_range"); } @Override protected Set wholeTypes() { - return org.opensearch.common.collect.Set.of("integer_range", "long_range"); + return Set.of("integer_range", "long_range"); } @Override diff --git a/server/src/test/java/org/opensearch/index/mapper/RangeFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/RangeFieldTypeTests.java index d4772f24cca93..668666a53cd7c 100644 --- a/server/src/test/java/org/opensearch/index/mapper/RangeFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/RangeFieldTypeTests.java @@ -538,20 +538,14 @@ public void testFetchSourceValue() throws IOException { MappedFieldType longMapper = new RangeFieldMapper.Builder("field", RangeType.LONG, true, Version.V_EMPTY).build(context) .fieldType(); - Map longRange = org.opensearch.common.collect.Map.of("gte", 3.14, "lt", "42.9"); - assertEquals( - Collections.singletonList(org.opensearch.common.collect.Map.of("gte", 3L, "lt", 42L)), - fetchSourceValue(longMapper, longRange) - ); + Map longRange = Map.of("gte", 3.14, "lt", "42.9"); + assertEquals(Collections.singletonList(Map.of("gte", 3L, "lt", 42L)), fetchSourceValue(longMapper, longRange)); MappedFieldType dateMapper = new RangeFieldMapper.Builder("field", RangeType.DATE, true, Version.V_EMPTY).format( "yyyy/MM/dd||epoch_millis" ).build(context).fieldType(); - Map dateRange = org.opensearch.common.collect.Map.of("lt", "1990/12/29", "gte", 597429487111L); - assertEquals( - Collections.singletonList(org.opensearch.common.collect.Map.of("lt", "1990/12/29", "gte", "1988/12/06")), - fetchSourceValue(dateMapper, dateRange) - ); + Map dateRange = Map.of("lt", "1990/12/29", "gte", 597429487111L); + assertEquals(Collections.singletonList(Map.of("lt", "1990/12/29", "gte", "1988/12/06")), fetchSourceValue(dateMapper, dateRange)); } public void testParseSourceValueWithFormat() throws IOException { @@ -560,23 +554,14 @@ public void testParseSourceValueWithFormat() throws IOException { MappedFieldType longMapper = new RangeFieldMapper.Builder("field", RangeType.LONG, true, Version.V_EMPTY).build(context) .fieldType(); - Map longRange = org.opensearch.common.collect.Map.of("gte", 3.14, "lt", "42.9"); - assertEquals( - Collections.singletonList(org.opensearch.common.collect.Map.of("gte", 3L, "lt", 42L)), - fetchSourceValue(longMapper, longRange) - ); + Map longRange = Map.of("gte", 3.14, "lt", "42.9"); + assertEquals(Collections.singletonList(Map.of("gte", 3L, "lt", 42L)), fetchSourceValue(longMapper, longRange)); MappedFieldType dateMapper = new RangeFieldMapper.Builder("field", RangeType.DATE, true, Version.V_EMPTY).format("strict_date_time") .build(context) .fieldType(); - Map dateRange = org.opensearch.common.collect.Map.of("lt", "1990-12-29T00:00:00.000Z"); - assertEquals( - Collections.singletonList(org.opensearch.common.collect.Map.of("lt", "1990/12/29")), - fetchSourceValue(dateMapper, dateRange, "yyy/MM/dd") - ); - assertEquals( - Collections.singletonList(org.opensearch.common.collect.Map.of("lt", "662428800000")), - fetchSourceValue(dateMapper, dateRange, "epoch_millis") - ); + Map dateRange = Map.of("lt", "1990-12-29T00:00:00.000Z"); + assertEquals(Collections.singletonList(Map.of("lt", "1990/12/29")), fetchSourceValue(dateMapper, dateRange, "yyy/MM/dd")); + assertEquals(Collections.singletonList(Map.of("lt", "662428800000")), fetchSourceValue(dateMapper, dateRange, "epoch_millis")); } } diff --git a/server/src/test/java/org/opensearch/index/mapper/TextFieldMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/TextFieldMapperTests.java index d62ed33bf7be4..109fa69eb6c3e 100644 --- a/server/src/test/java/org/opensearch/index/mapper/TextFieldMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/TextFieldMapperTests.java @@ -230,20 +230,9 @@ public TokenStream create(TokenStream tokenStream) { ) ); return new IndexAnalyzers( - org.opensearch.common.collect.Map.of( - "default", - dflt, - "standard", - standard, - "keyword", - keyword, - "whitespace", - whitespace, - "my_stop_analyzer", - stop - ), - org.opensearch.common.collect.Map.of(), - org.opensearch.common.collect.Map.of() + Map.of("default", dflt, "standard", standard, "keyword", keyword, "whitespace", whitespace, "my_stop_analyzer", stop), + Map.of(), + Map.of() ); } diff --git a/server/src/test/java/org/opensearch/index/mapper/TextFieldTypeTests.java b/server/src/test/java/org/opensearch/index/mapper/TextFieldTypeTests.java index b9ec5a07b207d..206be8c8352ef 100644 --- a/server/src/test/java/org/opensearch/index/mapper/TextFieldTypeTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/TextFieldTypeTests.java @@ -207,18 +207,18 @@ public void testFetchSourceValue() throws IOException { TextFieldType fieldType = createFieldType(); fieldType.setIndexAnalyzer(Lucene.STANDARD_ANALYZER); - assertEquals(org.opensearch.common.collect.List.of("value"), fetchSourceValue(fieldType, "value")); - assertEquals(org.opensearch.common.collect.List.of("42"), fetchSourceValue(fieldType, 42L)); - assertEquals(org.opensearch.common.collect.List.of("true"), fetchSourceValue(fieldType, true)); + assertEquals(List.of("value"), fetchSourceValue(fieldType, "value")); + assertEquals(List.of("42"), fetchSourceValue(fieldType, 42L)); + assertEquals(List.of("true"), fetchSourceValue(fieldType, true)); TextFieldMapper.PrefixFieldType prefixFieldType = new TextFieldMapper.PrefixFieldType(fieldType, "field._index_prefix", 2, 10); - assertEquals(org.opensearch.common.collect.List.of("value"), fetchSourceValue(prefixFieldType, "value")); - assertEquals(org.opensearch.common.collect.List.of("42"), fetchSourceValue(prefixFieldType, 42L)); - assertEquals(org.opensearch.common.collect.List.of("true"), fetchSourceValue(prefixFieldType, true)); + assertEquals(List.of("value"), fetchSourceValue(prefixFieldType, "value")); + assertEquals(List.of("42"), fetchSourceValue(prefixFieldType, 42L)); + assertEquals(List.of("true"), fetchSourceValue(prefixFieldType, true)); TextFieldMapper.PhraseFieldType phraseFieldType = new TextFieldMapper.PhraseFieldType(fieldType); - assertEquals(org.opensearch.common.collect.List.of("value"), fetchSourceValue(phraseFieldType, "value")); - assertEquals(org.opensearch.common.collect.List.of("42"), fetchSourceValue(phraseFieldType, 42L)); - assertEquals(org.opensearch.common.collect.List.of("true"), fetchSourceValue(phraseFieldType, true)); + assertEquals(List.of("value"), fetchSourceValue(phraseFieldType, "value")); + assertEquals(List.of("42"), fetchSourceValue(phraseFieldType, 42L)); + assertEquals(List.of("true"), fetchSourceValue(phraseFieldType, true)); } } diff --git a/server/src/test/java/org/opensearch/index/store/RemoteDirectoryTests.java b/server/src/test/java/org/opensearch/index/store/RemoteDirectoryTests.java index 97575248b4ad3..15f1585bd1477 100644 --- a/server/src/test/java/org/opensearch/index/store/RemoteDirectoryTests.java +++ b/server/src/test/java/org/opensearch/index/store/RemoteDirectoryTests.java @@ -15,7 +15,6 @@ import org.opensearch.common.blobstore.BlobContainer; import org.opensearch.common.blobstore.BlobMetadata; import org.opensearch.common.blobstore.support.PlainBlobMetadata; -import org.opensearch.common.collect.Set; import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; @@ -25,6 +24,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; diff --git a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java index 4f763b90bdc40..956279c3ea048 100644 --- a/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java +++ b/server/src/test/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryTests.java @@ -21,7 +21,6 @@ import org.junit.Before; import org.opensearch.common.UUIDs; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.Set; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.lucene.store.ByteArrayIndexInput; import org.opensearch.index.store.remote.metadata.RemoteSegmentMetadata; @@ -34,6 +33,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doReturn; diff --git a/server/src/test/java/org/opensearch/indices/replication/common/CopyStateTests.java b/server/src/test/java/org/opensearch/indices/replication/common/CopyStateTests.java index 6b212a7021e4a..a87a8de206a39 100644 --- a/server/src/test/java/org/opensearch/indices/replication/common/CopyStateTests.java +++ b/server/src/test/java/org/opensearch/indices/replication/common/CopyStateTests.java @@ -12,7 +12,6 @@ import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.util.Version; -import org.opensearch.common.collect.Map; import org.opensearch.common.collect.Tuple; import org.opensearch.common.concurrent.GatedCloseable; import org.opensearch.index.shard.IndexShard; @@ -23,6 +22,7 @@ import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint; import java.io.IOException; +import java.util.Map; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/server/src/test/java/org/opensearch/ingest/ConditionalProcessorTests.java b/server/src/test/java/org/opensearch/ingest/ConditionalProcessorTests.java index 1550dd65442a4..d2e4115f50e1d 100644 --- a/server/src/test/java/org/opensearch/ingest/ConditionalProcessorTests.java +++ b/server/src/test/java/org/opensearch/ingest/ConditionalProcessorTests.java @@ -166,19 +166,10 @@ public void testActsOnImmutableData() throws Exception { public void testPrecompiledError() { ScriptService scriptService = MockScriptService.singleContext( IngestConditionalScript.CONTEXT, - code -> { - throw new ScriptException( - "bad script", - new ParseException("error", 0), - org.opensearch.common.collect.List.of(), - "", - "lang", - null - ); - }, - org.opensearch.common.collect.Map.of() + code -> { throw new ScriptException("bad script", new ParseException("error", 0), List.of(), "", "lang", null); }, + Map.of() ); - Script script = new Script(ScriptType.INLINE, "lang", "foo", org.opensearch.common.collect.Map.of()); + Script script = new Script(ScriptType.INLINE, "lang", "foo", Map.of()); ScriptException e = expectThrows(ScriptException.class, () -> new ConditionalProcessor(null, null, script, scriptService, null)); assertThat(e.getMessage(), equalTo("bad script")); } @@ -186,17 +177,10 @@ public void testPrecompiledError() { public void testRuntimeCompileError() { AtomicBoolean fail = new AtomicBoolean(false); Map storedScripts = new HashMap<>(); - storedScripts.put("foo", new StoredScriptSource("lang", "", org.opensearch.common.collect.Map.of())); + storedScripts.put("foo", new StoredScriptSource("lang", "", Map.of())); ScriptService scriptService = MockScriptService.singleContext(IngestConditionalScript.CONTEXT, code -> { if (fail.get()) { - throw new ScriptException( - "bad script", - new ParseException("error", 0), - org.opensearch.common.collect.List.of(), - "", - "lang", - null - ); + throw new ScriptException("bad script", new ParseException("error", 0), List.of(), "", "lang", null); } else { return params -> new IngestConditionalScript(params) { @Override @@ -206,12 +190,12 @@ public boolean execute(Map ctx) { }; } }, storedScripts); - Script script = new Script(ScriptType.STORED, null, "foo", org.opensearch.common.collect.Map.of()); + Script script = new Script(ScriptType.STORED, null, "foo", Map.of()); ConditionalProcessor processor = new ConditionalProcessor(null, null, script, scriptService, null); fail.set(true); // must change the script source or the cached version will be used - storedScripts.put("foo", new StoredScriptSource("lang", "changed", org.opensearch.common.collect.Map.of())); - IngestDocument ingestDoc = new IngestDocument(org.opensearch.common.collect.Map.of(), org.opensearch.common.collect.Map.of()); + storedScripts.put("foo", new StoredScriptSource("lang", "changed", Map.of())); + IngestDocument ingestDoc = new IngestDocument(Map.of(), Map.of()); processor.execute(ingestDoc, (doc, e) -> { assertThat(e.getMessage(), equalTo("bad script")); }); } @@ -224,11 +208,11 @@ public boolean execute(Map ctx) { throw new IllegalArgumentException("runtime problem"); } }, - org.opensearch.common.collect.Map.of() + Map.of() ); - Script script = new Script(ScriptType.INLINE, "lang", "foo", org.opensearch.common.collect.Map.of()); + Script script = new Script(ScriptType.INLINE, "lang", "foo", Map.of()); ConditionalProcessor processor = new ConditionalProcessor(null, null, script, scriptService, null); - IngestDocument ingestDoc = new IngestDocument(org.opensearch.common.collect.Map.of(), org.opensearch.common.collect.Map.of()); + IngestDocument ingestDoc = new IngestDocument(Map.of(), Map.of()); processor.execute(ingestDoc, (doc, e) -> { assertThat(e.getMessage(), equalTo("runtime problem")); }); } diff --git a/server/src/test/java/org/opensearch/ingest/IngestDocumentTests.java b/server/src/test/java/org/opensearch/ingest/IngestDocumentTests.java index a6ea02a5423c4..8358dadf9cc3a 100644 --- a/server/src/test/java/org/opensearch/ingest/IngestDocumentTests.java +++ b/server/src/test/java/org/opensearch/ingest/IngestDocumentTests.java @@ -471,7 +471,7 @@ public void testListAppendFieldValueWithDuplicate() { @SuppressWarnings("unchecked") List list = (List) object; assertThat(list.size(), equalTo(3)); - assertThat(list, equalTo(org.opensearch.common.collect.List.of("foo", "bar", "baz"))); + assertThat(list, equalTo(List.of("foo", "bar", "baz"))); } public void testListAppendFieldValueWithoutDuplicate() { @@ -481,7 +481,7 @@ public void testListAppendFieldValueWithoutDuplicate() { @SuppressWarnings("unchecked") List list = (List) object; assertThat(list.size(), equalTo(4)); - assertThat(list, equalTo(org.opensearch.common.collect.List.of("foo", "bar", "baz", "foo2"))); + assertThat(list, equalTo(List.of("foo", "bar", "baz", "foo2"))); } public void testListAppendFieldValues() { @@ -499,7 +499,7 @@ public void testListAppendFieldValues() { } public void testListAppendFieldValuesWithoutDuplicates() { - ingestDocument.appendFieldValue("list2", org.opensearch.common.collect.List.of("foo", "bar", "baz", "foo2"), false); + ingestDocument.appendFieldValue("list2", List.of("foo", "bar", "baz", "foo2"), false); Object object = ingestDocument.getSourceAndMetadata().get("list2"); assertThat(object, instanceOf(List.class)); @SuppressWarnings("unchecked") diff --git a/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java b/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java index 23210e3c0b7bb..03636c97d1319 100644 --- a/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java +++ b/server/src/test/java/org/opensearch/repositories/RepositoriesServiceTests.java @@ -101,7 +101,7 @@ public void setUp() throws Exception { when(clusterApplierService.threadPool()).thenReturn(threadPool); final ClusterService clusterService = mock(ClusterService.class); when(clusterService.getClusterApplierService()).thenReturn(clusterApplierService); - Map typesRegistry = org.opensearch.common.collect.Map.of( + Map typesRegistry = Map.of( TestRepository.TYPE, TestRepository::new, MeteredRepositoryTypeA.TYPE, @@ -386,7 +386,7 @@ public void close() { private static class MeteredRepositoryTypeA extends MeteredBlobStoreRepository { private static final String TYPE = "type-a"; - private static final RepositoryStats STATS = new RepositoryStats(org.opensearch.common.collect.Map.of("GET", 10L)); + private static final RepositoryStats STATS = new RepositoryStats(Map.of("GET", 10L)); private MeteredRepositoryTypeA(RepositoryMetadata metadata, ClusterService clusterService) { super( @@ -395,7 +395,7 @@ private MeteredRepositoryTypeA(RepositoryMetadata metadata, ClusterService clust mock(NamedXContentRegistry.class), clusterService, mock(RecoverySettings.class), - org.opensearch.common.collect.Map.of("bucket", "bucket-a") + Map.of("bucket", "bucket-a") ); } @@ -417,7 +417,7 @@ public BlobPath basePath() { private static class MeteredRepositoryTypeB extends MeteredBlobStoreRepository { private static final String TYPE = "type-b"; - private static final RepositoryStats STATS = new RepositoryStats(org.opensearch.common.collect.Map.of("LIST", 20L)); + private static final RepositoryStats STATS = new RepositoryStats(Map.of("LIST", 20L)); private MeteredRepositoryTypeB(RepositoryMetadata metadata, ClusterService clusterService) { super( @@ -426,7 +426,7 @@ private MeteredRepositoryTypeB(RepositoryMetadata metadata, ClusterService clust mock(NamedXContentRegistry.class), clusterService, mock(RecoverySettings.class), - org.opensearch.common.collect.Map.of("bucket", "bucket-b") + Map.of("bucket", "bucket-b") ); } diff --git a/server/src/test/java/org/opensearch/repositories/RepositoriesStatsArchiveTests.java b/server/src/test/java/org/opensearch/repositories/RepositoriesStatsArchiveTests.java index 4ad3e1ef85f70..cf0b06a3f7d16 100644 --- a/server/src/test/java/org/opensearch/repositories/RepositoriesStatsArchiveTests.java +++ b/server/src/test/java/org/opensearch/repositories/RepositoriesStatsArchiveTests.java @@ -37,6 +37,7 @@ import org.opensearch.test.OpenSearchTestCase; import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import static org.hamcrest.Matchers.equalTo; @@ -60,19 +61,14 @@ public void testStatsAreEvictedOnceTheyAreOlderThanRetentionPeriod() { fakeRelativeClock.set(retentionTimeInMillis * 2); int statsToBeRetainedCount = randomInt(10); for (int i = 0; i < statsToBeRetainedCount; i++) { - RepositoryStatsSnapshot repoStats = createRepositoryStats( - new RepositoryStats(org.opensearch.common.collect.Map.of("GET", 10L)) - ); + RepositoryStatsSnapshot repoStats = createRepositoryStats(new RepositoryStats(Map.of("GET", 10L))); repositoriesStatsArchive.archive(repoStats); } List archivedStats = repositoriesStatsArchive.getArchivedStats(); assertThat(archivedStats.size(), equalTo(statsToBeRetainedCount)); for (RepositoryStatsSnapshot repositoryStatsSnapshot : archivedStats) { - assertThat( - repositoryStatsSnapshot.getRepositoryStats().requestCounts, - equalTo(org.opensearch.common.collect.Map.of("GET", 10L)) - ); + assertThat(repositoryStatsSnapshot.getRepositoryStats().requestCounts, equalTo(Map.of("GET", 10L))); } } @@ -129,7 +125,7 @@ private RepositoryStatsSnapshot createRepositoryStats(RepositoryStats repository UUIDs.randomBase64UUID(), randomAlphaOfLength(10), randomAlphaOfLength(10), - org.opensearch.common.collect.Map.of("bucket", randomAlphaOfLength(10)), + Map.of("bucket", randomAlphaOfLength(10)), System.currentTimeMillis(), null ); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/MergingBucketsDeferringCollectorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/MergingBucketsDeferringCollectorTests.java index 051056f7e0fdc..21e08b034f1d0 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/MergingBucketsDeferringCollectorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/MergingBucketsDeferringCollectorTests.java @@ -73,16 +73,7 @@ public void collect(int doc, long owningBucketOrd) throws IOException { }, (deferringCollector, finalCollector) -> { deferringCollector.prepareSelectedBuckets(0, 8, 9); - equalTo( - org.opensearch.common.collect.Map.of( - 0L, - org.opensearch.common.collect.List.of(0, 1, 2, 3, 4, 5, 6, 7), - 1L, - org.opensearch.common.collect.List.of(8), - 2L, - org.opensearch.common.collect.List.of(9) - ) - ); + equalTo(Map.of(0L, List.of(0, 1, 2, 3, 4, 5, 6, 7), 1L, List.of(8), 2L, List.of(9))); }); } @@ -99,19 +90,7 @@ public void collect(int doc, long owningBucketOrd) throws IOException { }, (deferringCollector, finalCollector) -> { deferringCollector.prepareSelectedBuckets(0, 8, 9); - assertThat( - finalCollector.collection, - equalTo( - org.opensearch.common.collect.Map.of( - 0L, - org.opensearch.common.collect.List.of(4, 5, 6, 7), - 1L, - org.opensearch.common.collect.List.of(8), - 2L, - org.opensearch.common.collect.List.of(9) - ) - ) - ); + assertThat(finalCollector.collection, equalTo(Map.of(0L, List.of(4, 5, 6, 7), 1L, List.of(8), 2L, List.of(9)))); }); } @@ -129,19 +108,7 @@ public void collect(int doc, long owningBucketOrd) throws IOException { }, (deferringCollector, finalCollector) -> { deferringCollector.prepareSelectedBuckets(0, 8, 9); - assertThat( - finalCollector.collection, - equalTo( - org.opensearch.common.collect.Map.of( - 0L, - org.opensearch.common.collect.List.of(0, 1, 2, 3), - 1L, - org.opensearch.common.collect.List.of(8), - 2L, - org.opensearch.common.collect.List.of(9) - ) - ) - ); + assertThat(finalCollector.collection, equalTo(Map.of(0L, List.of(0, 1, 2, 3), 1L, List.of(8), 2L, List.of(9)))); }); } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/InternalFilterTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/InternalFilterTests.java index b856a81515b52..110773a82404d 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/InternalFilterTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/InternalFilterTests.java @@ -92,7 +92,7 @@ public InternalAggregation reduce(InternalAggregation aggregation, ReduceContext } }; PipelineTree tree = new PipelineTree( - org.opensearch.common.collect.Map.of(inner.getName(), new PipelineTree(emptyMap(), singletonList(mockPipeline))), + Map.of(inner.getName(), new PipelineTree(emptyMap(), singletonList(mockPipeline))), emptyList() ); InternalFilter reduced = (InternalFilter) test.reducePipelines(test, emptyReduceContextBuilder().forFinalReduction(), tree); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/InternalFiltersTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/InternalFiltersTests.java index 176bfefdefc1e..038efc9f7c4f4 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/InternalFiltersTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/filter/InternalFiltersTests.java @@ -156,7 +156,7 @@ public InternalAggregation reduce(InternalAggregation aggregation, ReduceContext } }; PipelineTree tree = new PipelineTree( - org.opensearch.common.collect.Map.of(inner.getName(), new PipelineTree(emptyMap(), singletonList(mockPipeline))), + Map.of(inner.getName(), new PipelineTree(emptyMap(), singletonList(mockPipeline))), emptyList() ); InternalFilters reduced = (InternalFilters) test.reducePipelines(test, emptyReduceContextBuilder().forFinalReduction(), tree); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java index 0f49e02febabe..315f148ad5a02 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java @@ -305,7 +305,7 @@ public void testAsSubAggWithIncreasedRounding() throws IOException { int n = 0; for (long d = start; d < end; d += anHour) { docs.add( - org.opensearch.common.collect.List.of( + List.of( new SortedNumericDocValuesField(AGGREGABLE_DATE, d), new SortedSetDocValuesField("k1", aBytes), new SortedSetDocValuesField("k1", d < useC ? bBytes : cBytes), @@ -373,12 +373,7 @@ public void testAsSubAggInManyBuckets() throws IOException { List> docs = new ArrayList<>(); int n = 0; for (long d = start; d < end; d += anHour) { - docs.add( - org.opensearch.common.collect.List.of( - new SortedNumericDocValuesField(AGGREGABLE_DATE, d), - new SortedNumericDocValuesField("n", n % 100) - ) - ); + docs.add(List.of(new SortedNumericDocValuesField(AGGREGABLE_DATE, d), new SortedNumericDocValuesField("n", n % 100))); n++; } /* diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTestCase.java index ff9122aa42326..f3cda87342c18 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTestCase.java @@ -48,6 +48,7 @@ import java.io.IOException; import java.util.Collections; +import java.util.List; import java.util.function.Consumer; public abstract class DateHistogramAggregatorTestCase extends AggregatorTestCase { @@ -63,7 +64,7 @@ protected final void asSubAggTestCase(Aggregatio throws IOException { CheckedBiConsumer buildIndex = (iw, dft) -> { iw.addDocument( - org.opensearch.common.collect.List.of( + List.of( new SortedNumericDocValuesField(AGGREGABLE_DATE, dft.parse("2020-02-01T00:00:00Z")), new SortedSetDocValuesField("k1", new BytesRef("a")), new SortedSetDocValuesField("k2", new BytesRef("a")), @@ -71,7 +72,7 @@ protected final void asSubAggTestCase(Aggregatio ) ); iw.addDocument( - org.opensearch.common.collect.List.of( + List.of( new SortedNumericDocValuesField(AGGREGABLE_DATE, dft.parse("2020-03-01T00:00:00Z")), new SortedSetDocValuesField("k1", new BytesRef("a")), new SortedSetDocValuesField("k2", new BytesRef("a")), @@ -79,7 +80,7 @@ protected final void asSubAggTestCase(Aggregatio ) ); iw.addDocument( - org.opensearch.common.collect.List.of( + List.of( new SortedNumericDocValuesField(AGGREGABLE_DATE, dft.parse("2021-02-01T00:00:00Z")), new SortedSetDocValuesField("k1", new BytesRef("a")), new SortedSetDocValuesField("k2", new BytesRef("a")), @@ -87,7 +88,7 @@ protected final void asSubAggTestCase(Aggregatio ) ); iw.addDocument( - org.opensearch.common.collect.List.of( + List.of( new SortedNumericDocValuesField(AGGREGABLE_DATE, dft.parse("2021-03-01T00:00:00Z")), new SortedSetDocValuesField("k1", new BytesRef("a")), new SortedSetDocValuesField("k2", new BytesRef("b")), @@ -95,7 +96,7 @@ protected final void asSubAggTestCase(Aggregatio ) ); iw.addDocument( - org.opensearch.common.collect.List.of( + List.of( new SortedNumericDocValuesField(AGGREGABLE_DATE, dft.parse("2020-02-01T00:00:00Z")), new SortedSetDocValuesField("k1", new BytesRef("b")), new SortedSetDocValuesField("k2", new BytesRef("b")), diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java index 597175d89bcfe..7bd39c72ae325 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/DateHistogramAggregatorTests.java @@ -193,14 +193,14 @@ public void testAsSubAgg() throws IOException { InternalDateHistogram adh = a.getAggregations().get("dh"); assertThat( adh.getBuckets().stream().map(bucket -> bucket.getKey().toString()).collect(toList()), - equalTo(org.opensearch.common.collect.List.of("2020-01-01T00:00Z", "2021-01-01T00:00Z")) + equalTo(List.of("2020-01-01T00:00Z", "2021-01-01T00:00Z")) ); StringTerms.Bucket b = terms.getBucketByKey("b"); InternalDateHistogram bdh = b.getAggregations().get("dh"); assertThat( bdh.getBuckets().stream().map(bucket -> bucket.getKey().toString()).collect(toList()), - equalTo(org.opensearch.common.collect.List.of("2020-01-01T00:00Z")) + equalTo(List.of("2020-01-01T00:00Z")) ); }); builder = new TermsAggregationBuilder("k2").field("k2").subAggregation(builder); @@ -211,7 +211,7 @@ public void testAsSubAgg() throws IOException { InternalDateHistogram ak1adh = ak1a.getAggregations().get("dh"); assertThat( ak1adh.getBuckets().stream().map(bucket -> bucket.getKey().toString()).collect(toList()), - equalTo(org.opensearch.common.collect.List.of("2020-01-01T00:00Z", "2021-01-01T00:00Z")) + equalTo(List.of("2020-01-01T00:00Z", "2021-01-01T00:00Z")) ); StringTerms.Bucket b = terms.getBucketByKey("b"); @@ -220,13 +220,13 @@ public void testAsSubAgg() throws IOException { InternalDateHistogram bk1adh = bk1a.getAggregations().get("dh"); assertThat( bk1adh.getBuckets().stream().map(bucket -> bucket.getKey().toString()).collect(toList()), - equalTo(org.opensearch.common.collect.List.of("2021-01-01T00:00Z")) + equalTo(List.of("2021-01-01T00:00Z")) ); StringTerms.Bucket bk1b = bk1.getBucketByKey("b"); InternalDateHistogram bk1bdh = bk1b.getAggregations().get("dh"); assertThat( bk1bdh.getBuckets().stream().map(bucket -> bucket.getKey().toString()).collect(toList()), - equalTo(org.opensearch.common.collect.List.of("2020-01-01T00:00Z")) + equalTo(List.of("2020-01-01T00:00Z")) ); }); } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/NumericHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/NumericHistogramAggregatorTests.java index e7b22a9a57476..9a7546a2f9aea 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/NumericHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/NumericHistogramAggregatorTests.java @@ -420,7 +420,7 @@ public void testAsSubAgg() throws IOException { List> docs = new ArrayList<>(); for (int n = 0; n < 10000; n++) { docs.add( - org.opensearch.common.collect.List.of( + List.of( new SortedNumericDocValuesField("outer", n % 100), new SortedNumericDocValuesField("inner", n / 100), new SortedNumericDocValuesField("n", n) diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/RangeHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/RangeHistogramAggregatorTests.java index 41bd0d77bff00..3ee9765e445fd 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/RangeHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/RangeHistogramAggregatorTests.java @@ -492,14 +492,14 @@ public void testAsSubAgg() throws IOException { List> docs = new ArrayList<>(); for (int n = 0; n < 10000; n++) { BytesRef outerRange = RangeType.LONG.encodeRanges( - org.opensearch.common.collect.Set.of(new RangeFieldMapper.Range(RangeType.LONG, n % 100, n % 100 + 10, true, true)) + Set.of(new RangeFieldMapper.Range(RangeType.LONG, n % 100, n % 100 + 10, true, true)) ); BytesRef innerRange = RangeType.LONG.encodeRanges( - org.opensearch.common.collect.Set.of(new RangeFieldMapper.Range(RangeType.LONG, n / 100, n / 100 + 10, true, true)) + Set.of(new RangeFieldMapper.Range(RangeType.LONG, n / 100, n / 100 + 10, true, true)) ); docs.add( - org.opensearch.common.collect.List.of( + List.of( new BinaryDocValuesField("outer", outerRange), new BinaryDocValuesField("inner", innerRange), new SortedNumericDocValuesField("n", n) diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java index b1d62f3402bc3..103a1be8595c7 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java @@ -493,22 +493,12 @@ public void testAsSubAggregation() throws IOException { AggregationBuilder builder = new TermsAggregationBuilder("t").field("t") .subAggregation(new VariableWidthHistogramAggregationBuilder("v").field("v").setNumBuckets(2)); CheckedConsumer buildIndex = iw -> { - iw.addDocument( - org.opensearch.common.collect.List.of(new SortedNumericDocValuesField("t", 1), new SortedNumericDocValuesField("v", 1)) - ); - iw.addDocument( - org.opensearch.common.collect.List.of(new SortedNumericDocValuesField("t", 1), new SortedNumericDocValuesField("v", 10)) - ); - iw.addDocument( - org.opensearch.common.collect.List.of(new SortedNumericDocValuesField("t", 1), new SortedNumericDocValuesField("v", 11)) - ); + iw.addDocument(List.of(new SortedNumericDocValuesField("t", 1), new SortedNumericDocValuesField("v", 1))); + iw.addDocument(List.of(new SortedNumericDocValuesField("t", 1), new SortedNumericDocValuesField("v", 10))); + iw.addDocument(List.of(new SortedNumericDocValuesField("t", 1), new SortedNumericDocValuesField("v", 11))); - iw.addDocument( - org.opensearch.common.collect.List.of(new SortedNumericDocValuesField("t", 2), new SortedNumericDocValuesField("v", 20)) - ); - iw.addDocument( - org.opensearch.common.collect.List.of(new SortedNumericDocValuesField("t", 2), new SortedNumericDocValuesField("v", 30)) - ); + iw.addDocument(List.of(new SortedNumericDocValuesField("t", 2), new SortedNumericDocValuesField("v", 20))); + iw.addDocument(List.of(new SortedNumericDocValuesField("t", 2), new SortedNumericDocValuesField("v", 30))); }; Consumer verify = terms -> { /* @@ -520,14 +510,14 @@ public void testAsSubAggregation() throws IOException { InternalVariableWidthHistogram v1 = t1.getAggregations().get("v"); assertThat( v1.getBuckets().stream().map(InternalVariableWidthHistogram.Bucket::centroid).collect(toList()), - equalTo(org.opensearch.common.collect.List.of(1.0, 10.5)) + equalTo(List.of(1.0, 10.5)) ); LongTerms.Bucket t2 = terms.getBucketByKey("1"); InternalVariableWidthHistogram v2 = t2.getAggregations().get("v"); assertThat( v2.getBuckets().stream().map(InternalVariableWidthHistogram.Bucket::centroid).collect(toList()), - equalTo(org.opensearch.common.collect.List.of(20.0, 30)) + equalTo(List.of(20.0, 30)) ); }; Exception e = expectThrows( @@ -550,7 +540,7 @@ public void testSmallShardSize() throws Exception { IllegalArgumentException.class, () -> testSearchCase( DEFAULT_QUERY, - org.opensearch.common.collect.List.of(), + List.of(), true, aggregation -> aggregation.field(NUMERIC_FIELD).setNumBuckets(2).setShardSize(2), histogram -> { fail(); } @@ -568,7 +558,7 @@ public void testHugeShardSize() throws Exception { aggregation -> aggregation.field(NUMERIC_FIELD).setShardSize(1000000000), histogram -> assertThat( histogram.getBuckets().stream().map(InternalVariableWidthHistogram.Bucket::getKey).collect(toList()), - equalTo(org.opensearch.common.collect.List.of(1.0, 2.0, 3.0)) + equalTo(List.of(1.0, 2.0, 3.0)) ) ); } @@ -578,7 +568,7 @@ public void testSmallInitialBuffer() throws Exception { IllegalArgumentException.class, () -> testSearchCase( DEFAULT_QUERY, - org.opensearch.common.collect.List.of(), + List.of(), true, aggregation -> aggregation.field(NUMERIC_FIELD).setInitialBuffer(1), histogram -> { fail(); } @@ -597,7 +587,7 @@ public void testOutOfOrderInitialBuffer() throws Exception { histogram -> { assertThat( histogram.getBuckets().stream().map(InternalVariableWidthHistogram.Bucket::getKey).collect(toList()), - equalTo(org.opensearch.common.collect.List.of(1.0, 2.0, 3.0)) + equalTo(List.of(1.0, 2.0, 3.0)) ); } ); diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/missing/MissingAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/missing/MissingAggregatorTests.java index e888972b8e447..c544dcce45cce 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/missing/MissingAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/missing/MissingAggregatorTests.java @@ -120,7 +120,7 @@ public void testMatchAllDocs() throws IOException { }, internalMissing -> { assertEquals(numDocs, internalMissing.getDocCount()); assertTrue(AggregationInspectionHelper.hasValue(internalMissing)); - }, org.opensearch.common.collect.List.of(aggFieldType, anotherFieldType)); + }, List.of(aggFieldType, anotherFieldType)); } public void testMatchSparse() throws IOException { @@ -145,7 +145,7 @@ public void testMatchSparse() throws IOException { testCase(newMatchAllQuery(), builder, writer -> writer.addDocuments(docs), internalMissing -> { assertEquals(finalDocsMissingAggField, internalMissing.getDocCount()); assertTrue(AggregationInspectionHelper.hasValue(internalMissing)); - }, org.opensearch.common.collect.List.of(aggFieldType, anotherFieldType)); + }, List.of(aggFieldType, anotherFieldType)); } public void testMatchSparseRangeField() throws IOException { @@ -225,7 +225,7 @@ public void testMissingParam() throws IOException { }, internalMissing -> { assertEquals(0, internalMissing.getDocCount()); assertFalse(AggregationInspectionHelper.hasValue(internalMissing)); - }, org.opensearch.common.collect.List.of(aggFieldType, anotherFieldType)); + }, List.of(aggFieldType, anotherFieldType)); } public void testMultiValuedField() throws IOException { @@ -241,7 +241,7 @@ public void testMultiValuedField() throws IOException { if (randomBoolean()) { final long randomLong = randomLong(); docs.add( - org.opensearch.common.collect.Set.of( + Set.of( new SortedNumericDocValuesField(aggFieldType.name(), randomLong), new SortedNumericDocValuesField(aggFieldType.name(), randomLong + 1) ) @@ -256,7 +256,7 @@ public void testMultiValuedField() throws IOException { testCase(newMatchAllQuery(), builder, writer -> writer.addDocuments(docs), internalMissing -> { assertEquals(finalDocsMissingAggField, internalMissing.getDocCount()); assertTrue(AggregationInspectionHelper.hasValue(internalMissing)); - }, org.opensearch.common.collect.List.of(aggFieldType, anotherFieldType)); + }, List.of(aggFieldType, anotherFieldType)); } public void testSingleValuedFieldWithValueScript() throws IOException { @@ -289,12 +289,12 @@ private void valueScriptTestCase(Script script) throws IOException { testCase(newMatchAllQuery(), builder, writer -> writer.addDocuments(docs), internalMissing -> { assertEquals(finalDocsMissingField, internalMissing.getDocCount()); assertTrue(AggregationInspectionHelper.hasValue(internalMissing)); - }, org.opensearch.common.collect.List.of(aggFieldType, anotherFieldType)); + }, List.of(aggFieldType, anotherFieldType)); } public void testMultiValuedFieldWithFieldScriptWithParams() throws IOException { final long threshold = 10; - final Map params = org.opensearch.common.collect.Map.of("field", "agg_field", "threshold", threshold); + final Map params = Map.of("field", "agg_field", "threshold", threshold); fieldScriptTestCase(new Script(ScriptType.INLINE, MockScriptEngine.NAME, FIELD_SCRIPT_PARAMS, params), threshold); } @@ -320,7 +320,7 @@ private void fieldScriptTestCase(Script script, long threshold) throws IOExcepti docsBelowThreshold++; } docs.add( - org.opensearch.common.collect.Set.of( + Set.of( new SortedNumericDocValuesField(aggFieldType.name(), firstValue), new SortedNumericDocValuesField(aggFieldType.name(), secondValue) ) @@ -362,7 +362,7 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy @Override protected List getSupportedValuesSourceTypes() { - return org.opensearch.common.collect.List.of( + return List.of( CoreValuesSourceType.NUMERIC, CoreValuesSourceType.BYTES, CoreValuesSourceType.GEOPOINT, diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/RangeAggregationBuilderTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/RangeAggregationBuilderTests.java index 8891cc1b89c40..0df7ce14d28ea 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/range/RangeAggregationBuilderTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/range/RangeAggregationBuilderTests.java @@ -128,6 +128,6 @@ public void testNumericKeys() throws IOException { ); assertThat(builder.getName(), equalTo("test")); assertThat(builder.field(), equalTo("f")); - assertThat(builder.ranges, equalTo(org.opensearch.common.collect.List.of(new RangeAggregator.Range("1", null, 0d)))); + assertThat(builder.ranges, equalTo(List.of(new RangeAggregator.Range("1", null, 0d)))); } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregatorTests.java index f3922a65ff264..75ad9e12e0776 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/MultiTermsAggregatorTests.java @@ -127,7 +127,7 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy @Override protected ScriptService getMockScriptService() { - final Map, Object>> scripts = org.opensearch.common.collect.Map.of( + final Map, Object>> scripts = Map.of( VALUE_SCRIPT_NAME, vars -> ((Number) vars.get("_value")).doubleValue() + 1, FIELD_SCRIPT_NAME, diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java index 678bc2fc6f536..debe4d343e874 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java @@ -376,25 +376,13 @@ public void testInsideTerms() throws IOException { StringTerms.Bucket even = terms.getBucketByKey("even"); InternalRareTerms evenRare = even.getAggregations().get("rare"); - assertEquals( - evenRare.getBuckets().stream().map(InternalRareTerms.Bucket::getKeyAsString).collect(toList()), - org.opensearch.common.collect.List.of("2") - ); - assertEquals( - evenRare.getBuckets().stream().map(InternalRareTerms.Bucket::getDocCount).collect(toList()), - org.opensearch.common.collect.List.of(2L) - ); + assertEquals(evenRare.getBuckets().stream().map(InternalRareTerms.Bucket::getKeyAsString).collect(toList()), List.of("2")); + assertEquals(evenRare.getBuckets().stream().map(InternalRareTerms.Bucket::getDocCount).collect(toList()), List.of(2L)); StringTerms.Bucket odd = terms.getBucketByKey("odd"); InternalRareTerms oddRare = odd.getAggregations().get("rare"); - assertEquals( - oddRare.getBuckets().stream().map(InternalRareTerms.Bucket::getKeyAsString).collect(toList()), - org.opensearch.common.collect.List.of("1") - ); - assertEquals( - oddRare.getBuckets().stream().map(InternalRareTerms.Bucket::getDocCount).collect(toList()), - org.opensearch.common.collect.List.of(1L) - ); + assertEquals(oddRare.getBuckets().stream().map(InternalRareTerms.Bucket::getKeyAsString).collect(toList()), List.of("1")); + assertEquals(oddRare.getBuckets().stream().map(InternalRareTerms.Bucket::getDocCount).collect(toList()), List.of(1L)); } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/StatsAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/StatsAggregatorTests.java index d8d736595164a..c215c0959b342 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/StatsAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/StatsAggregatorTests.java @@ -470,7 +470,7 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy @Override protected ScriptService getMockScriptService() { - final Map, Object>> scripts = org.opensearch.common.collect.Map.of( + final Map, Object>> scripts = Map.of( VALUE_SCRIPT_NAME, vars -> ((Number) vars.get("_value")).doubleValue() + 1, FIELD_SCRIPT_NAME, diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/SumAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/SumAggregatorTests.java index 8c0087ca0b87d..72b09d7509b02 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/SumAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/SumAggregatorTests.java @@ -418,7 +418,7 @@ protected AggregationBuilder createAggBuilderForTypeTest(MappedFieldType fieldTy @Override protected ScriptService getMockScriptService() { - final Map, Object>> scripts = org.opensearch.common.collect.Map.of( + final Map, Object>> scripts = Map.of( VALUE_SCRIPT_NAME, vars -> ((Number) vars.get("_value")).doubleValue() + 1, FIELD_SCRIPT_NAME, diff --git a/server/src/test/java/org/opensearch/search/fetch/subphase/FieldFetcherTests.java b/server/src/test/java/org/opensearch/search/fetch/subphase/FieldFetcherTests.java index 4ad93f410a424..f6d5789c1d503 100644 --- a/server/src/test/java/org/opensearch/search/fetch/subphase/FieldFetcherTests.java +++ b/server/src/test/java/org/opensearch/search/fetch/subphase/FieldFetcherTests.java @@ -49,6 +49,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Set; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; @@ -66,10 +67,7 @@ public void testLeafValues() throws IOException { .endObject() .endObject(); - List fieldAndFormats = org.opensearch.common.collect.List.of( - new FieldAndFormat("field", null), - new FieldAndFormat("object.field", null) - ); + List fieldAndFormats = List.of(new FieldAndFormat("field", null), new FieldAndFormat("object.field", null)); Map fields = fetchFields(mapperService, source, fieldAndFormats); assertThat(fields.size(), equalTo(2)); @@ -100,7 +98,7 @@ public void testObjectValues() throws IOException { DocumentField rangeField = fields.get("float_range"); assertNotNull(rangeField); assertThat(rangeField.getValues().size(), equalTo(1)); - assertThat(rangeField.getValue(), equalTo(org.opensearch.common.collect.Map.of("gte", 0.0f, "lte", 2.718f))); + assertThat(rangeField.getValue(), equalTo(Map.of("gte", 0.0f, "lte", 2.718f))); } public void testNonExistentField() throws IOException { @@ -255,7 +253,7 @@ public void testDateFormat() throws IOException { Map fields = fetchFields( mapperService, source, - org.opensearch.common.collect.List.of(new FieldAndFormat("field", null), new FieldAndFormat("date_field", "yyyy/MM/dd")) + List.of(new FieldAndFormat("field", null), new FieldAndFormat("date_field", "yyyy/MM/dd")) ); assertThat(fields.size(), equalTo(2)); @@ -440,7 +438,7 @@ public void testTextSubFields() throws IOException { private static Map fetchFields(MapperService mapperService, XContentBuilder source, String fieldPattern) throws IOException { - List fields = org.opensearch.common.collect.List.of(new FieldAndFormat(fieldPattern, null)); + List fields = List.of(new FieldAndFormat(fieldPattern, null)); return fetchFields(mapperService, source, fields); } @@ -451,7 +449,7 @@ private static Map fetchFields(MapperService mapperServic sourceLookup.setSource(BytesReference.bytes(source)); FieldFetcher fieldFetcher = FieldFetcher.create(createQueryShardContext(mapperService), null, fields); - return fieldFetcher.fetch(sourceLookup, org.opensearch.common.collect.Set.of()); + return fieldFetcher.fetch(sourceLookup, Set.of()); } public MapperService createMapperService() throws IOException { diff --git a/server/src/test/java/org/opensearch/search/profile/ProfileResultTests.java b/server/src/test/java/org/opensearch/search/profile/ProfileResultTests.java index ae8a7e3ee1e7b..121ae1646f5de 100644 --- a/server/src/test/java/org/opensearch/search/profile/ProfileResultTests.java +++ b/server/src/test/java/org/opensearch/search/profile/ProfileResultTests.java @@ -121,26 +121,8 @@ private void doFromXContentTestWithRandomFields(boolean addRandomFields) throws public void testToXContent() throws IOException { List children = new ArrayList<>(); - children.add( - new ProfileResult( - "child1", - "desc1", - org.opensearch.common.collect.Map.of("key1", 100L), - org.opensearch.common.collect.Map.of(), - 100L, - org.opensearch.common.collect.List.of() - ) - ); - children.add( - new ProfileResult( - "child2", - "desc2", - org.opensearch.common.collect.Map.of("key1", 123356L), - org.opensearch.common.collect.Map.of(), - 123356L, - org.opensearch.common.collect.List.of() - ) - ); + children.add(new ProfileResult("child1", "desc1", Map.of("key1", 100L), Map.of(), 100L, List.of())); + children.add(new ProfileResult("child2", "desc2", Map.of("key1", 123356L), Map.of(), 123356L, List.of())); Map breakdown = new LinkedHashMap<>(); breakdown.put("key1", 123456L); breakdown.put("stuff", 10000L); @@ -225,14 +207,7 @@ public void testToXContent() throws IOException { Strings.toString(builder) ); - result = new ProfileResult( - "profileName", - "some description", - org.opensearch.common.collect.Map.of("key1", 12345678L), - org.opensearch.common.collect.Map.of(), - 12345678L, - org.opensearch.common.collect.List.of() - ); + result = new ProfileResult("profileName", "some description", Map.of("key1", 12345678L), Map.of(), 12345678L, List.of()); builder = XContentFactory.jsonBuilder().prettyPrint().humanReadable(true); result.toXContent(builder, ToXContent.EMPTY_PARAMS); assertEquals( @@ -248,14 +223,7 @@ public void testToXContent() throws IOException { Strings.toString(builder) ); - result = new ProfileResult( - "profileName", - "some description", - org.opensearch.common.collect.Map.of("key1", 1234567890L), - org.opensearch.common.collect.Map.of(), - 1234567890L, - org.opensearch.common.collect.List.of() - ); + result = new ProfileResult("profileName", "some description", Map.of("key1", 1234567890L), Map.of(), 1234567890L, List.of()); builder = XContentFactory.jsonBuilder().prettyPrint().humanReadable(true); result.toXContent(builder, ToXContent.EMPTY_PARAMS); assertEquals( diff --git a/server/src/test/java/org/opensearch/search/profile/aggregation/AggregationProfileShardResultTests.java b/server/src/test/java/org/opensearch/search/profile/aggregation/AggregationProfileShardResultTests.java index 7107e68b61c16..8bc32efdad489 100644 --- a/server/src/test/java/org/opensearch/search/profile/aggregation/AggregationProfileShardResultTests.java +++ b/server/src/test/java/org/opensearch/search/profile/aggregation/AggregationProfileShardResultTests.java @@ -87,7 +87,7 @@ public void testToXContent() throws IOException { breakdown.put("timing2", 4000L); Map debug = new LinkedHashMap<>(); debug.put("stuff", "stuff"); - debug.put("other_stuff", org.opensearch.common.collect.List.of("foo", "bar")); + debug.put("other_stuff", List.of("foo", "bar")); ProfileResult profileResult = new ProfileResult("someType", "someDescription", breakdown, debug, 6000L, Collections.emptyList()); profileResults.add(profileResult); AggregationProfileShardResult aggProfileResults = new AggregationProfileShardResult(profileResults); diff --git a/server/src/test/java/org/opensearch/transport/InboundHandlerTests.java b/server/src/test/java/org/opensearch/transport/InboundHandlerTests.java index 4076e7229ebf7..c340042f99d86 100644 --- a/server/src/test/java/org/opensearch/transport/InboundHandlerTests.java +++ b/server/src/test/java/org/opensearch/transport/InboundHandlerTests.java @@ -63,6 +63,8 @@ import java.io.InputStream; import java.nio.ByteBuffer; import java.util.Collections; +import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -254,8 +256,8 @@ public void testSendsErrorResponseToHandshakeFromCompatibleVersion() throws Exce ); final InboundMessage requestMessage = unreadableInboundHandshake(remoteVersion, requestHeader); requestHeader.actionName = TransportHandshaker.HANDSHAKE_ACTION_NAME; - requestHeader.headers = Tuple.tuple(org.opensearch.common.collect.Map.of(), org.opensearch.common.collect.Map.of()); - requestHeader.features = org.opensearch.common.collect.Set.of(); + requestHeader.headers = Tuple.tuple(Map.of(), Map.of()); + requestHeader.features = Set.of(); handler.inboundMessage(channel, requestMessage); final BytesReference responseBytesReference = channel.getMessageCaptor().get(); @@ -294,8 +296,8 @@ public void testClosesChannelOnErrorInHandshakeWithIncompatibleVersion() throws ); final InboundMessage requestMessage = unreadableInboundHandshake(remoteVersion, requestHeader); requestHeader.actionName = TransportHandshaker.HANDSHAKE_ACTION_NAME; - requestHeader.headers = Tuple.tuple(org.opensearch.common.collect.Map.of(), org.opensearch.common.collect.Map.of()); - requestHeader.features = org.opensearch.common.collect.Set.of(); + requestHeader.headers = Tuple.tuple(Map.of(), Map.of()); + requestHeader.features = Set.of(); handler.inboundMessage(channel, requestMessage); assertTrue(isClosed.get()); assertNull(channel.getMessageCaptor().get()); @@ -332,7 +334,7 @@ public void testLogsSlowInboundProcessing() throws Exception { }); requestHeader.actionName = TransportHandshaker.HANDSHAKE_ACTION_NAME; requestHeader.headers = Tuple.tuple(Collections.emptyMap(), Collections.emptyMap()); - requestHeader.features = org.opensearch.common.collect.Set.of(); + requestHeader.features = Set.of(); handler.inboundMessage(channel, requestMessage); assertNotNull(channel.getMessageCaptor().get()); mockAppender.assertAllExpectationsMatched(); diff --git a/test/framework/src/main/java/org/opensearch/index/mapper/FieldTypeTestCase.java b/test/framework/src/main/java/org/opensearch/index/mapper/FieldTypeTestCase.java index 571f1b21dd7e3..7ed0da8509fab 100644 --- a/test/framework/src/main/java/org/opensearch/index/mapper/FieldTypeTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/mapper/FieldTypeTestCase.java @@ -38,6 +38,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Set; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -65,7 +66,7 @@ public static List fetchSourceValue(MappedFieldType fieldType, Object sourceV public static List fetchSourceValue(MappedFieldType fieldType, Object sourceValue, String format) throws IOException { String field = fieldType.name(); QueryShardContext context = mock(QueryShardContext.class); - when(context.sourcePath(field)).thenReturn(org.opensearch.common.collect.Set.of(field)); + when(context.sourcePath(field)).thenReturn(Set.of(field)); ValueFetcher fetcher = fieldType.valueFetcher(context, null, format); SourceLookup lookup = new SourceLookup(); diff --git a/test/framework/src/main/java/org/opensearch/repositories/blobstore/OpenSearchMockAPIBasedRepositoryIntegTestCase.java b/test/framework/src/main/java/org/opensearch/repositories/blobstore/OpenSearchMockAPIBasedRepositoryIntegTestCase.java index 28dbcf478eb86..28153e0ecce9d 100644 --- a/test/framework/src/main/java/org/opensearch/repositories/blobstore/OpenSearchMockAPIBasedRepositoryIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/repositories/blobstore/OpenSearchMockAPIBasedRepositoryIntegTestCase.java @@ -359,7 +359,7 @@ public HttpHandler getDelegate() { } synchronized Map getOperationsCount() { - return org.opensearch.common.collect.Map.copyOf(operationCount); + return Map.copyOf(operationCount); } protected synchronized void trackRequest(final String requestType) { diff --git a/test/framework/src/main/java/org/opensearch/script/MockScriptService.java b/test/framework/src/main/java/org/opensearch/script/MockScriptService.java index e4887255d0b9f..4fbc4c4d4bc90 100644 --- a/test/framework/src/main/java/org/opensearch/script/MockScriptService.java +++ b/test/framework/src/main/java/org/opensearch/script/MockScriptService.java @@ -79,14 +79,10 @@ public FactoryType compile( @Override public Set> getSupportedContexts() { - return org.opensearch.common.collect.Set.of(context); + return Set.of(context); } }; - return new MockScriptService( - Settings.EMPTY, - org.opensearch.common.collect.Map.of("lang", engine), - org.opensearch.common.collect.Map.of(context.name, context) - ) { + return new MockScriptService(Settings.EMPTY, Map.of("lang", engine), Map.of(context.name, context)) { @Override protected StoredScriptSource getScriptFromClusterState(String id) { return storedLookup.get(id); diff --git a/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java b/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java index cb74925d290c2..9b8a84a5ed842 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java @@ -623,7 +623,7 @@ protected static void wipeDataStreams() throws IOException { // We hit a version of ES that doesn't serialize DeleteDataStreamAction.Request#wildcardExpressionsOriginallySpecified field or // that doesn't support data streams so it's safe to ignore int statusCode = e.getResponse().getStatusLine().getStatusCode(); - if (org.opensearch.common.collect.Set.of(404, 405, 500).contains(statusCode) == false) { + if (Set.of(404, 405, 500).contains(statusCode) == false) { throw e; } }