Skip to content

Commit c9b9681

Browse files
fix some test NPE due to validation
1 parent 611b0ca commit c9b9681

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

server/src/test/java/org/elasticsearch/indices/NodeIndicesStatsTests.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
public class NodeIndicesStatsTests extends ESTestCase {
2828

2929
public void testInvalidLevel() {
30-
final NodeIndicesStats stats = new NodeIndicesStats(null, Collections.emptyMap(), Collections.emptyMap(), null, randomBoolean());
30+
final NodeIndicesStats stats = new NodeIndicesStats(
31+
null,
32+
Collections.emptyMap(),
33+
Collections.emptyMap(),
34+
Collections.emptyMap(),
35+
randomBoolean()
36+
);
3137
final String level = randomAlphaOfLength(16);
3238
final ToXContent.Params params = new ToXContent.MapParams(Collections.singletonMap("level", level));
3339
final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> stats.toXContentChunked(params));
@@ -42,9 +48,9 @@ public void testIncludeShardsStatsFlag() {
4248
final Map<Index, List<IndexShardStats>> statsByShards = new HashMap<>();
4349
final List<IndexShardStats> emptyList = List.of();
4450
statsByShards.put(index, emptyList);
45-
NodeIndicesStats stats = new NodeIndicesStats(null, Collections.emptyMap(), statsByShards, null, true);
51+
NodeIndicesStats stats = new NodeIndicesStats(null, Collections.emptyMap(), statsByShards, Collections.emptyMap(), true);
4652
assertThat(stats.getShardStats(index), sameInstance(emptyList));
47-
stats = new NodeIndicesStats(null, Collections.emptyMap(), statsByShards, null, false);
53+
stats = new NodeIndicesStats(null, Collections.emptyMap(), statsByShards, Collections.emptyMap(), false);
4854
assertThat(stats.getShardStats(index), nullValue());
4955
}
5056

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/datatiers/DataTierUsageFixtures.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static NodeIndicesStats buildNodeIndicesStats(RoutingNode routingNode, long byte
7979
IndexShardStats shardStats = new IndexShardStats(shardId, new ShardStats[] { shardStat });
8080
indexStats.computeIfAbsent(shardId.getIndex(), k -> new ArrayList<>()).add(shardStats);
8181
}
82-
return new NodeIndicesStats(COMMON_STATS, Map.of(), indexStats, null, true);
82+
return new NodeIndicesStats(COMMON_STATS, Map.of(), indexStats, Map.of(), true);
8383
}
8484

8585
private static ShardStats shardStat(long byteCount, long docCount, ShardRouting routing) {

x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ private static NodeStats mockNodeStats() {
367367
segmentsStats.addBitsetMemoryInBytes(++iota);
368368
indicesCommonStats.getSegments().add(segmentsStats);
369369

370-
final NodeIndicesStats indices = new NodeIndicesStats(indicesCommonStats, emptyMap(), emptyMap(), null, randomBoolean());
370+
final NodeIndicesStats indices = new NodeIndicesStats(indicesCommonStats, emptyMap(), emptyMap(), emptyMap(), randomBoolean());
371371

372372
// Filesystem
373373
final FsInfo.DeviceStats ioStatsOne = new FsInfo.DeviceStats(

0 commit comments

Comments
 (0)