@Test
  public void testAmILeader() {
    BooleanResult isLeader1 = new BooleanResult();
    BooleanResult isLeader2 = new BooleanResult();
    // Processor-1

    ZkUtils zkUtils1 = getZkUtilsWithNewClient();
    ZkLeaderElector leaderElector1 = new ZkLeaderElector("1", zkUtils1);
    leaderElector1.setLeaderElectorListener(() -> isLeader1.res = true);

    // Processor-2
    ZkUtils zkUtils2 = getZkUtilsWithNewClient();
    ZkLeaderElector leaderElector2 = new ZkLeaderElector("2", zkUtils2);
    leaderElector2.setLeaderElectorListener(() -> isLeader2.res = true);

    // Before Leader Election
    Assert.assertFalse(leaderElector1.amILeader());
    Assert.assertFalse(leaderElector2.amILeader());

    leaderElector1.tryBecomeLeader();
    leaderElector2.tryBecomeLeader();

    // After Leader Election
    Assert.assertTrue(leaderElector1.amILeader());
    Assert.assertFalse(leaderElector2.amILeader());

    zkUtils1.close();
    zkUtils2.close();
  }
electionLatch and count together verify that:
1. the registered listeners are actually invoked by the ZkClient on the correct path
2. for a single participant failure, at-most 1 other participant is notified
samza-core/src/test/java/org/apache/samza/zk/TestZkLeaderElector.java