@Override
    public LeaderElection createLeaderElection(String componentId) {
        synchronized (lock) {
            Preconditions.checkState(
                    !leadershipOperationExecutor.isShutdown(),
                    "The service was already closed and cannot be reused.");
            Preconditions.checkState(
                    !leaderContenderRegistry.containsKey(componentId),
                    "There shouldn't be any contender registered under the passed component '%s'.",
                    componentId);
            return new DefaultLeaderElection(this, componentId);
        }
    }
@Test
    void testLazyDriverInstantiation() throws Exception {
        final AtomicBoolean driverCreated = new AtomicBoolean();
        try (final DefaultLeaderElectionService testInstance =
                new DefaultLeaderElectionService(
                        listener -> {
                            driverCreated.set(true);
                            return TestingLeaderElectionDriver.newNoOpBuilder().build(listener);
                        },
                        fatalErrorHandlerExtension.getTestingFatalErrorHandler(),
                        Executors.newDirectExecutorService())) {
            assertThat(driverCreated)
                    .as("The driver shouldn't have been created during service creation.")
                    .isFalse();

            try (final LeaderElection leaderElection =
                    testInstance.createLeaderElection("component-id")) {
                assertThat(driverCreated)
                        .as(
                                "The driver shouldn't have been created during LeaderElection creation.")
                        .isFalse();

                leaderElection.startLeaderElection(
                        TestingGenericLeaderContender.newBuilder().build());
                assertThat(driverCreated)
                        .as(
                                "The driver should have been created when registering the contender in the LeaderElection.")
                        .isTrue();
            }
        }
    }