@SuppressWarnings("unchecked")
@Override
protected void configure() {
bind(Settings.class).toInstance(ImmutableSettings.EMPTY);
ClusterService clusterService = mock(ClusterService.class);
bind(ClusterService.class).toInstance(clusterService);
ClusterName clusterName = mock(ClusterName.class);
when(clusterName.value()).thenReturn("crate");
bind(ClusterName.class).toInstance(clusterName);
Index index = new Index(SysShardsTableInfo.IDENT.name());
bind(Index.class).toInstance(index);
ShardId shardId = mock(ShardId.class);
when(shardId.getId()).thenReturn(1);
when(shardId.getIndex()).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return indexName;
}
});
bind(ShardId.class).toInstance(shardId);
IndexShard indexShard = mock(IndexShard.class);
bind(IndexShard.class).toInstance(indexShard);
StoreStats storeStats = mock(StoreStats.class);
when(indexShard.storeStats()).thenReturn(storeStats);
when(storeStats.getSizeInBytes()).thenReturn(123456L);
DocsStats docsStats = mock(DocsStats.class);
when(indexShard.docStats()).thenReturn(docsStats).thenThrow(IllegalIndexShardStateException.class);
when(docsStats.getCount()).thenReturn(654321L);
ShardRouting shardRouting = mock(ShardRouting.class);
when(indexShard.routingEntry()).thenReturn(shardRouting);
when(shardRouting.primary()).thenReturn(true);
when(shardRouting.relocatingNodeId()).thenReturn("node_X");
TransportPutIndexTemplateAction transportPutIndexTemplateAction = mock(TransportPutIndexTemplateAction.class);
bind(TransportPutIndexTemplateAction.class).toInstance(transportPutIndexTemplateAction);
when(indexShard.state()).thenReturn(IndexShardState.STARTED);
MetaData metaData = mock(MetaData.class);
when(metaData.hasConcreteIndex(Constants.PARTITIONED_TABLE_PREFIX + ".wikipedia_de._1")).thenReturn(false);
ClusterState clusterState = mock(ClusterState.class);
when(clusterService.state()).thenReturn(clusterState);
when(clusterState.metaData()).thenReturn(metaData);
}