@Before
public void setUp() throws Exception {
clusterService = mock(ClusterService.class);
clusterIdService = mock(ClusterIdService.class);
httpServerTransport = mock(HttpServerTransport.class);
DiscoveryNode discoveryNode = mock(DiscoveryNode.class);
BoundTransportAddress boundAddress = mock(BoundTransportAddress.class);
TransportAddress transportAddress = new InetSocketTransportAddress(
InetAddress.getLocalHost().getHostName(), 4200);
SettableFuture<ClusterId> clusterIdFuture = SettableFuture.create();
clusterIdFuture.set(new ClusterId(UUID.randomUUID()));
when(clusterIdService.clusterId()).thenReturn(clusterIdFuture);
when(clusterService.localNode()).thenReturn(discoveryNode);
when(discoveryNode.isMasterNode()).thenReturn(true);
when(httpServerTransport.boundAddress()).thenReturn(boundAddress);
when(boundAddress.publishAddress()).thenReturn(transportAddress);
}