@Override
    public void publishLeaderInformation(String componentId, LeaderInformation leaderInformation) {
        Preconditions.checkState(running.get());

        try {
            kubeClient
                    .checkAndUpdateConfigMap(
                            configMapName,
                            updateConfigMapWithLeaderInformation(componentId, leaderInformation))
                    .get();
        } catch (InterruptedException | ExecutionException e) {
            leaderElectionListener.onError(e);
        }

        LOG.debug(
                "Successfully wrote leader information {} for leader {} into the config map {}.",
                leaderInformation,
                componentId,
                configMapName);
    }
@Test
    void testWriteLeaderInformationWhenConfigMapNotExist() throws Exception {
        new Context() {
            {
                runTest(
                        () -> {
                            leaderElectionDriver.publishLeaderInformation(
                                    componentId,
                                    LeaderInformation.known(UUID.randomUUID(), LEADER_ADDRESS));

                            final String expectedErrorMessage =
                                    "ConfigMap " + LEADER_CONFIGMAP_NAME + " does not exist.";
                            final LeaderElectionEvent.ErrorEvent errorEvent =
                                    electionEventHandler.assertNextEvent(
                                            LeaderElectionEvent.ErrorEvent.class);
                            assertThat(errorEvent.getError())
                                    .cause()
                                    .isInstanceOf(KubernetesException.class)
                                    .hasMessage(expectedErrorMessage);
                        });
            }
        };
    }