test_class.file: nvadaemon/src/test/java/com/microsoft/azure/practices/nvadaemon/NvaLeaderSelectorListenerAdapterTest.java
test_class.identifier: NvaLeaderSelectorListenerAdapterTest
test_case.body: @Test
      void testTakeLeadershipNvaMonitorException() throws Exception {
          ZookeeperConfiguration zookeeperConfiguration =
              new ZookeeperConfiguration("connection-string", "/leader-selector-path", null, null);
          List<MonitorConfiguration> monitors = new ArrayList<>();
          monitors.add(
              new MonitorConfiguration(
                  "com.microsoft.azure.practices.nvadaemon.NvaMonitorTest$InvalidMonitor",
                  null));
          DaemonConfiguration daemonConfiguration = new DaemonConfiguration(monitors, null);
          NvaDaemonConfiguration nvaDaemonConfiguration = new NvaDaemonConfiguration(
              zookeeperConfiguration, daemonConfiguration);
  
          CuratorFramework curatorFramework = mock(CuratorFramework.class);
          NvaLeaderSelectorListenerAdapter nvaLeaderSelectorListenerAdapter =
              new NvaLeaderSelectorListenerAdapter(nvaDaemonConfiguration, curatorFramework);
          Assertions.assertThrows(NvaMonitor.NvaMonitorException.class,
              () -> nvaLeaderSelectorListenerAdapter.takeLeadership(curatorFramework));
  
      }
test_case.class_method_signature: NvaLeaderSelectorListenerAdapterTest.testTakeLeadershipNvaMonitorException()
test_case.full_signature: @Test void testTakeLeadershipNvaMonitorException()
test_case.identifier: testTakeLeadershipNvaMonitorException
test_case.invocations: add mock assertThrows takeLeadership
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void testTakeLeadershipNvaMonitorException()
focal_class.declarator: log = LoggerFactory.getLogger(NvaLeaderSelectorListenerAdapter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(NvaLeaderSelectorListenerAdapter.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: leaderSelector
focal_class.modifier: private final
focal_class.original_string: private final LeaderSelector leaderSelector;
focal_class.type: LeaderSelector
focal_class.var_name: leaderSelector
focal_class.declarator: configuration
focal_class.modifier: private final
focal_class.original_string: private final NvaDaemonConfiguration configuration;
focal_class.type: NvaDaemonConfiguration
focal_class.var_name: configuration
focal_class.declarator: nvaMonitor
focal_class.modifier: private final
focal_class.original_string: private final NvaMonitor nvaMonitor;
focal_class.type: NvaMonitor
focal_class.var_name: nvaMonitor
focal_class.file: nvadaemon/src/main/java/com/microsoft/azure/practices/nvadaemon/NvaLeaderSelectorListenerAdapter.java
focal_class.identifier: NvaLeaderSelectorListenerAdapter
focal_class.interfaces: implements AutoCloseable
focal_class.class_method_signature: NvaLeaderSelectorListenerAdapter.NvaLeaderSelectorListenerAdapter(NvaDaemonConfiguration configuration,
                                              CuratorFramework client)
focal_class.full_signature: public  NvaLeaderSelectorListenerAdapter(NvaDaemonConfiguration configuration,
                                              CuratorFramework client)
focal_class.identifier: NvaLeaderSelectorListenerAdapter
focal_class.modifiers: public
focal_class.parameters: (NvaDaemonConfiguration configuration,
                                              CuratorFramework client)
focal_class.signature:  NvaLeaderSelectorListenerAdapter(NvaDaemonConfiguration configuration,
                                              CuratorFramework client)
focal_class.class_method_signature: NvaLeaderSelectorListenerAdapter.start()
focal_class.full_signature: public synchronized void start()
focal_class.identifier: start
focal_class.modifiers: public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void start()
focal_class.class_method_signature: NvaLeaderSelectorListenerAdapter.close()
focal_class.full_signature: public synchronized void close()
focal_class.identifier: close
focal_class.modifiers: public synchronized
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void close()
focal_class.class_method_signature: NvaLeaderSelectorListenerAdapter.takeLeadership(CuratorFramework curatorFramework)
focal_class.full_signature: @Override public void takeLeadership(CuratorFramework curatorFramework)
focal_class.identifier: takeLeadership
focal_class.modifiers: @Override public
focal_class.parameters: (CuratorFramework curatorFramework)
focal_class.return: void
focal_class.signature: void takeLeadership(CuratorFramework curatorFramework)
focal_class.superclass: extends LeaderSelectorListenerAdapter
focal_method.body: @Override
      public void takeLeadership(CuratorFramework curatorFramework) throws Exception {
          log.info("Leadership acquired");
          try {
              log.info("Starting nvaMonitor");
              Future<Void> task = nvaMonitor.start();
              task.get();
              log.debug("task.get() returned");
          } catch (InterruptedException e) {
              log.info("takeLeadership interrupted");
              Thread.currentThread().interrupt();
          } catch (NvaMonitorException e){
              log.error("Error creating NvaMonitor", e);
              throw e;
          } catch (ExecutionException e) {
              // This should happen when there is an exception starting the nvaMonitor.  We need to
              // relinquish leadership so someone else can try.  However, if this is a configuration
              // issue, it will just bounce from leader to leader, so we need to log it.
              log.error("Error executing NvaMonitor", e);
              throw e;
          } finally {
              this.nvaMonitor.stop();
          }
      }
focal_method.class_method_signature: NvaLeaderSelectorListenerAdapter.takeLeadership(CuratorFramework curatorFramework)
focal_method.full_signature: @Override public void takeLeadership(CuratorFramework curatorFramework)
focal_method.identifier: takeLeadership
focal_method.invocations: info info start get debug info interrupt currentThread error error stop
focal_method.modifiers: @Override public
focal_method.parameters: (CuratorFramework curatorFramework)
focal_method.return: void
focal_method.signature: void takeLeadership(CuratorFramework curatorFramework)