@Before
  public void before() {
    service = new DefaultOperationsServerListService();
    BootstrapNode zkNode = Mockito.mock(BootstrapNode.class);
    OperationsNodeInfo nodeInfo = new OperationsNodeInfo();
    nodeInfo.setConnectionInfo(new ConnectionInfo("localhost", 8000, ByteBuffer.wrap(new byte[0])));
    List<TransportMetaData> mdList = new ArrayList<TransportMetaData>();
    mdList.add(
        new TransportMetaData(
            1,
            42,
            42,
            Collections.singletonList(
                new VersionConnectionInfoPair(42, ByteBuffer.wrap("test".getBytes())))));
    mdList.add(
        new TransportMetaData(
            2,
            73,
            73,
            Collections.singletonList(
                new VersionConnectionInfoPair(73, ByteBuffer.wrap("test".getBytes())))));
    mdList.add(
        new TransportMetaData(
            3,
            1,
            3,
            Arrays.asList(
                new VersionConnectionInfoPair(1, ByteBuffer.wrap("test1".getBytes())),
                new VersionConnectionInfoPair(2, ByteBuffer.wrap("test2".getBytes())),
                new VersionConnectionInfoPair(3, ByteBuffer.wrap("test3".getBytes())))));
    nodeInfo.setTransports(mdList);

    Mockito.when(zkNode.getCurrentOperationServerNodes()).thenReturn(Arrays.asList(nodeInfo));
    service.init(zkNode);
  }
 /** Stop zk. */
 private void stopZk() {
   try {
     if (bootstrapNode != null) {
       bootstrapNode.close();
     }
   } catch (IOException ex) {
     LOG.warn("Exception when closing ZK node", ex);
   } finally {
     bootstrapNode = null;
   }
 }
 /**
  * Start zk.
  *
  * @throws Exception in case of error
  */
 private void startZk() throws Exception { // NOSONAR
   if (getNodeConfig().isZkEnabled()) {
     LOG.info(
         "Bootstrap service starting ZooKepper connection to {}",
         getNodeConfig().getZkHostPortList());
     BootstrapNodeInfo nodeInfo = new BootstrapNodeInfo();
     ByteBuffer keyData = ByteBuffer.wrap(bootstrapKeyStoreService.getPublicKey().getEncoded());
     LOG.trace(
         "Bootstrap service: registering in ZK: thriftHost {}; "
             + "thriftPort {}; nettyHost {}; nettyPort {}",
         getNodeConfig().getThriftHost(),
         getNodeConfig().getThriftPort());
     nodeInfo.setConnectionInfo(
         new ConnectionInfo(
             getNodeConfig().getThriftHost(), getNodeConfig().getThriftPort(), keyData));
     nodeInfo.setTransports(new ArrayList<>());
     nodeInfo.setTimeStarted(System.currentTimeMillis());
     bootstrapNode = new BootstrapNode(nodeInfo, zkClient);
     if (bootstrapNode != null) {
       bootstrapNode.start();
     }
   }
 }