From eb60d5925a515a641f0251a781488af7d0330e95 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 5 Oct 2015 09:11:02 -0400 Subject: [PATCH] Start banning ImmutableMap Original commit: elastic/x-pack-elasticsearch@b895e519441704d2bb3cf168994d2323e5682832 --- .../execution/TriggeredWatchStoreTests.java | 27 ++++++++++---- .../watcher/watch/WatchStoreTests.java | 37 ++++++++++++------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/watcher/src/test/java/org/elasticsearch/watcher/execution/TriggeredWatchStoreTests.java b/watcher/src/test/java/org/elasticsearch/watcher/execution/TriggeredWatchStoreTests.java index 159fce115d8..f8932e2381b 100644 --- a/watcher/src/test/java/org/elasticsearch/watcher/execution/TriggeredWatchStoreTests.java +++ b/watcher/src/test/java/org/elasticsearch/watcher/execution/TriggeredWatchStoreTests.java @@ -15,7 +15,12 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.cluster.routing.*; +import org.elasticsearch.cluster.routing.IndexRoutingTable; +import org.elasticsearch.cluster.routing.IndexShardRoutingTable; +import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.ShardRoutingState; +import org.elasticsearch.cluster.routing.TestShardRouting; +import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; @@ -34,12 +39,18 @@ import org.junit.Test; import java.util.Collection; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.core.IsEqual.equalTo; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; public class TriggeredWatchStoreTests extends ESTestCase { @@ -100,7 +111,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); ClusterState cs = csBuilder.build(); assertThat(triggeredWatchStore.validate(cs), is(false)); @@ -133,7 +144,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); ClusterState cs = csBuilder.build(); assertThat(triggeredWatchStore.validate(cs), is(true)); @@ -168,7 +179,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); ClusterState cs = csBuilder.build(); RefreshResponse refreshResponse = mockRefreshResponse(1, 1); @@ -212,7 +223,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); ClusterState cs = csBuilder.build(); RefreshResponse refreshResponse = mockRefreshResponse(1, 1); @@ -255,7 +266,7 @@ public class TriggeredWatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); ClusterState cs = csBuilder.build(); RefreshResponse refreshResponse = mockRefreshResponse(1, 1); diff --git a/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchStoreTests.java b/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchStoreTests.java index d87cf0e7e95..7f1dba418b9 100644 --- a/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchStoreTests.java +++ b/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchStoreTests.java @@ -5,6 +5,19 @@ */ package org.elasticsearch.watcher.watch; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsEqual.equalTo; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + +import java.util.Collections; + import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; @@ -15,7 +28,12 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; -import org.elasticsearch.cluster.routing.*; +import org.elasticsearch.cluster.routing.IndexRoutingTable; +import org.elasticsearch.cluster.routing.IndexShardRoutingTable; +import org.elasticsearch.cluster.routing.RoutingTable; +import org.elasticsearch.cluster.routing.ShardRoutingState; +import org.elasticsearch.cluster.routing.TestShardRouting; +import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; @@ -30,13 +48,6 @@ import org.elasticsearch.watcher.support.init.proxy.ClientProxy; import org.junit.Before; import org.junit.Test; -import java.util.Collections; - -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsEqual.equalTo; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; - /** */ public class WatchStoreTests extends ESTestCase { @@ -86,7 +97,7 @@ public class WatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); ClusterState cs = csBuilder.build(); assertThat(watchStore.validate(cs), is(false)); @@ -110,7 +121,7 @@ public class WatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); RefreshResponse refreshResponse = mockRefreshResponse(1, 0); when(clientProxy.refresh(any(RefreshRequest.class))).thenReturn(refreshResponse); @@ -145,7 +156,7 @@ public class WatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); RefreshResponse refreshResponse = mockRefreshResponse(1, 1); when(clientProxy.refresh(any(RefreshRequest.class))).thenReturn(refreshResponse); @@ -184,7 +195,7 @@ public class WatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); RefreshResponse refreshResponse = mockRefreshResponse(1, 1); when(clientProxy.refresh(any(RefreshRequest.class))).thenReturn(refreshResponse); @@ -221,7 +232,7 @@ public class WatchStoreTests extends ESTestCase { indexRoutingTableBuilder.addReplica(); routingTableBuilder.add(indexRoutingTableBuilder.build()); csBuilder.metaData(metaDateBuilder); - csBuilder.routingTable(routingTableBuilder); + csBuilder.routingTable(routingTableBuilder.build()); RefreshResponse refreshResponse = mockRefreshResponse(1, 1); when(clientProxy.refresh(any(RefreshRequest.class))).thenReturn(refreshResponse);