@Override
    public void startLeaderElection(LeaderContender contender) throws Exception {
        synchronized (lock) {
            Preconditions.checkState(
                    leaderContender == null,
                    "No LeaderContender should have been registered with this LeaderElection, yet.");
            this.leaderContender = contender;

            this.leaderContender.grantLeadership(sessionID);
        }
    }
@Test
    void testStandaloneLeaderElectionRetrieval() throws Exception {
        final UUID expectedSessionID = UUID.randomUUID();
        StandaloneLeaderRetrievalService leaderRetrievalService =
                new StandaloneLeaderRetrievalService(TEST_URL, expectedSessionID);
        TestingListener testingListener = new TestingListener();

        try (LeaderElection leaderElection = new StandaloneLeaderElection(expectedSessionID)) {
            TestingContender contender = new TestingContender(TEST_URL, leaderElection);
            contender.startLeaderElection();

            leaderRetrievalService.start(testingListener);

            contender.waitForLeader();

            assertThat(contender.isLeader()).isTrue();
            assertThat(contender.getLeaderSessionID()).isEqualTo(expectedSessionID);

            testingListener.waitForNewLeader();

            assertThat(testingListener.getAddress()).isEqualTo(TEST_URL);
            assertThat(testingListener.getLeaderSessionID()).isEqualTo(expectedSessionID);
        } finally {
            leaderRetrievalService.stop();
        }
    }