@GuardedBy("lock")
    private boolean isLeader(ResourceManager<?> resourceManager) {
        return running && this.leaderResourceManager == resourceManager;
    }
@Test
    void closeService_stopRmAndLeaderElection() throws Exception {
        final CompletableFuture<UUID> terminateRmFuture = new CompletableFuture<>();

        rmFactoryBuilder.setTerminateConsumer(terminateRmFuture::complete);

        createAndStartResourceManager();

        // grant leadership
        leaderElection.isLeader(UUID.randomUUID()).join();

        assertThat(leaderElection.isStopped()).isFalse();

        // close service
        resourceManagerService.close();

        // should stop RM and leader election
        assertThatFuture(terminateRmFuture).isDone();
        assertThat(leaderElection.isStopped()).isTrue();
    }