@Override
    protected boolean hasLeadership(String componentId, UUID leaderSessionId) {
        synchronized (lock) {
            if (leaderElectionDriver != null) {
                if (leaderContenderRegistry.containsKey(componentId)) {
                    return leaderElectionDriver.hasLeadership()
                            && leaderSessionId.equals(issuedLeaderSessionID);
                } else {
                    LOG.debug(
                            "hasLeadership is called for component '{}' while there is no contender registered under that ID in the service, returning false.",
                            componentId);
                    return false;
                }
            } else {
                LOG.debug("hasLeadership is called after the service is closed, returning false.");
                return false;
            }
        }
    }
@Test
    void testHasLeadershipWithLeadershipButNoGrantEventProcessed() throws Exception {
        new Context() {
            {
                runTestWithManuallyTriggeredEvents(
                        executorService -> {
                            final UUID expectedSessionID = UUID.randomUUID();
                            grantLeadership(expectedSessionID);

                            applyToBothContenderContexts(
                                    ctx -> {
                                        assertThat(
                                                        leaderElectionService.hasLeadership(
                                                                ctx.componentId, expectedSessionID))
                                                .isFalse();
                                        assertThat(
                                                        leaderElectionService.hasLeadership(
                                                                ctx.componentId, UUID.randomUUID()))
                                                .isFalse();
                                    });
                        });
            }
        };
    }