@Test
public void testAddRemoveIndexForWatching() throws Exception {
InteractionProtocol protocol = mock(InteractionProtocol.class);
Client client = new Client(ISleepServer.class, new DefaultNodeSelectionPolicy(), protocol,
new ClientConfiguration());
IndexMetaData indexMD = new IndexMetaData("index1", "path", 1);
indexMD.getShards().add(new Shard("shard1", "path"));
indexMD.getShards().add(new Shard("shard2", "path"));
client.addIndexForWatching(indexMD.getName());
verify(protocol, times(1)).registerDataListener(eq(client), eq(PathDef.INDICES_METADATA), anyString(),
any(IZkDataListener.class));
client.removeIndex(indexMD.getName());
verify(protocol, times(1)).unregisterDataChanges(eq(client), eq(PathDef.INDICES_METADATA), anyString());
}