Skip to content

Commit c3ac2d7

Browse files
committed
Remove ImmutableOpenMap from rollupt tests
Some tests for rollup were still using ImmutableOpenMap for testing internal methods, even though those methods were already converted to Map. This commit changes those tests to use Map. relates elastic#86239
1 parent a9d1986 commit c3ac2d7

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupCapsActionRequestTests.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.elasticsearch.cluster.metadata.IndexMetadata;
1010
import org.elasticsearch.cluster.metadata.MappingMetadata;
1111
import org.elasticsearch.cluster.metadata.Metadata;
12-
import org.elasticsearch.common.collect.ImmutableOpenMap;
1312
import org.elasticsearch.common.io.stream.Writeable;
1413
import org.elasticsearch.common.util.Maps;
1514
import org.elasticsearch.test.AbstractWireSerializingTestCase;
@@ -129,14 +128,13 @@ public void testMultipleJobs() throws IOException {
129128
}
130129

131130
public void testNoIndices() {
132-
ImmutableOpenMap<String, IndexMetadata> indices = new ImmutableOpenMap.Builder<String, IndexMetadata>().build();
133-
Map<String, RollableIndexCaps> caps = TransportGetRollupCapsAction.getCaps("foo", indices);
131+
Map<String, RollableIndexCaps> caps = TransportGetRollupCapsAction.getCaps("foo", Map.of());
134132
assertThat(caps.size(), equalTo(0));
135133
}
136134

137135
public void testAllIndices() throws IOException {
138136
int num = randomIntBetween(1, 5);
139-
ImmutableOpenMap.Builder<String, IndexMetadata> indices = new ImmutableOpenMap.Builder<>(5);
137+
Map<String, IndexMetadata> indices = Maps.newMapWithExpectedSize(5);
140138
int indexCounter = 0;
141139
for (int j = 0; j < 5; j++) {
142140

@@ -161,13 +159,13 @@ public void testAllIndices() throws IOException {
161159
indices.put(randomAlphaOfLength(10), meta);
162160
}
163161

164-
Map<String, RollableIndexCaps> caps = TransportGetRollupCapsAction.getCaps(Metadata.ALL, indices.build());
162+
Map<String, RollableIndexCaps> caps = TransportGetRollupCapsAction.getCaps(Metadata.ALL, indices);
165163
assertThat(caps.size(), equalTo(num * 5));
166164
}
167165

168166
public void testOneIndex() throws IOException {
169167
int num = randomIntBetween(1, 5);
170-
ImmutableOpenMap.Builder<String, IndexMetadata> indices = new ImmutableOpenMap.Builder<>(5);
168+
Map<String, IndexMetadata> indices = Maps.newMapWithExpectedSize(5);
171169
String selectedIndexName = null;
172170
for (int j = 0; j < 5; j++) {
173171
String indexName = randomAlphaOfLength(10);
@@ -195,7 +193,7 @@ public void testOneIndex() throws IOException {
195193
indices.put(indexName, meta);
196194
}
197195

198-
Map<String, RollableIndexCaps> caps = TransportGetRollupCapsAction.getCaps(selectedIndexName, indices.build());
196+
Map<String, RollableIndexCaps> caps = TransportGetRollupCapsAction.getCaps(selectedIndexName, indices);
199197
assertThat(caps.size(), equalTo(1));
200198
}
201199

x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.elasticsearch.cluster.metadata.IndexMetadata;
1010
import org.elasticsearch.cluster.metadata.MappingMetadata;
1111
import org.elasticsearch.cluster.metadata.Metadata;
12-
import org.elasticsearch.common.collect.ImmutableOpenMap;
1312
import org.elasticsearch.common.io.stream.Writeable;
1413
import org.elasticsearch.common.util.Maps;
1514
import org.elasticsearch.test.AbstractWireSerializingTestCase;
@@ -43,14 +42,13 @@ protected Writeable.Reader<GetRollupIndexCapsAction.Request> instanceReader() {
4342
}
4443

4544
public void testNoIndicesByRollup() {
46-
ImmutableOpenMap<String, IndexMetadata> indices = new ImmutableOpenMap.Builder<String, IndexMetadata>().build();
47-
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Collections.singletonList("foo"), indices);
45+
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Collections.singletonList("foo"), Map.of());
4846
assertThat(caps.size(), equalTo(0));
4947
}
5048

5149
public void testAllIndicesByRollupSingleRollup() throws IOException {
5250
int num = randomIntBetween(1, 5);
53-
ImmutableOpenMap.Builder<String, IndexMetadata> indices = new ImmutableOpenMap.Builder<>(5);
51+
Map<String, IndexMetadata> indices = Maps.newMapWithExpectedSize(5);
5452
int indexCounter = 0;
5553
for (int j = 0; j < 5; j++) {
5654

@@ -75,12 +73,12 @@ public void testAllIndicesByRollupSingleRollup() throws IOException {
7573
indices.put("foo", meta);
7674
}
7775

78-
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Collections.singletonList("foo"), indices.build());
76+
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Collections.singletonList("foo"), indices);
7977
assertThat(caps.size(), equalTo(1));
8078
}
8179

8280
public void testAllIndicesByRollupManyRollup() throws IOException {
83-
ImmutableOpenMap.Builder<String, IndexMetadata> indices = new ImmutableOpenMap.Builder<>(5);
81+
Map<String, IndexMetadata> indices = Maps.newMapWithExpectedSize(5);
8482
int indexCounter = 0;
8583
for (int j = 0; j < 5; j++) {
8684

@@ -103,12 +101,12 @@ public void testAllIndicesByRollupManyRollup() throws IOException {
103101
indices.put("rollup_" + indexName, meta);
104102
}
105103

106-
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Arrays.asList(indices.keys().toArray(new String[0])), indices.build());
104+
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Arrays.asList(indices.keySet().toArray(new String[0])), indices);
107105
assertThat(caps.size(), equalTo(5));
108106
}
109107

110108
public void testOneIndexByRollupManyRollup() throws IOException {
111-
ImmutableOpenMap.Builder<String, IndexMetadata> indices = new ImmutableOpenMap.Builder<>(5);
109+
Map<String, IndexMetadata> indices = Maps.newMapWithExpectedSize(5);
112110
int indexCounter = 0;
113111
for (int j = 0; j < 5; j++) {
114112

@@ -131,14 +129,14 @@ public void testOneIndexByRollupManyRollup() throws IOException {
131129
indices.put("rollup_" + indexName, meta);
132130
}
133131

134-
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Collections.singletonList("rollup_1"), indices.build());
132+
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Collections.singletonList("rollup_1"), indices);
135133
assertThat(caps.size(), equalTo(1));
136134
assertThat(caps.get("rollup_1").getIndexName(), equalTo("rollup_1"));
137135
assertThat(caps.get("rollup_1").getJobCaps().size(), equalTo(1));
138136
}
139137

140138
public void testOneIndexByRollupOneRollup() throws IOException {
141-
ImmutableOpenMap.Builder<String, IndexMetadata> indices = new ImmutableOpenMap.Builder<>(5);
139+
Map<String, IndexMetadata> indices = Maps.newMapWithExpectedSize(5);
142140
int indexCounter = 0;
143141
for (int j = 0; j < 5; j++) {
144142

@@ -161,7 +159,7 @@ public void testOneIndexByRollupOneRollup() throws IOException {
161159
indices.put("rollup_foo", meta);
162160
}
163161

164-
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Collections.singletonList("rollup_foo"), indices.build());
162+
Map<String, RollableIndexCaps> caps = getCapsByRollupIndex(Collections.singletonList("rollup_foo"), indices);
165163
assertThat(caps.size(), equalTo(1));
166164
assertThat(caps.get("rollup_foo").getIndexName(), equalTo("rollup_foo"));
167165
assertThat(caps.get("rollup_foo").getJobCaps().size(), equalTo(1));

0 commit comments

Comments
 (0)