@VisibleForTesting
    @Nullable
    public UUID getLeaderSessionID(String componentId) {
        synchronized (lock) {
            return leaderContenderRegistry.containsKey(componentId)
                    ? confirmedLeaderInformation
                            .forComponentIdOrEmpty(componentId)
                            .getLeaderSessionID()
                    : null;
        }
    }
@Test
    void testOnGrantLeadershipIsIgnoredAfterLeaderElectionClose() throws Exception {
        new Context() {
            {
                runTestWithSynchronousEventHandling(
                        () -> {
                            closeLeaderElectionInBothContexts();
                            grantLeadership();

                            applyToBothContenderContexts(
                                    ctx -> {
                                        assertThat(
                                                        leaderElectionService.getLeaderSessionID(
                                                                ctx.componentId))
                                                .as(
                                                        "The grant event shouldn't have been processed by the LeaderElectionService.")
                                                .isNull();
                                        assertThat(ctx.contender.getLeaderSessionID())
                                                .as(
                                                        "The grant event shouldn't have been forwarded to the contender.")
                                                .isNull();
                                    });
                        });
            }
        };
    }