@Override
    public boolean isLeader() {
        return isLeader;
    }
@Test
    void leaderWhenLockIsAcquired() {
        when(lockService.lock(any(), isNull())).thenReturn(Optional.of(mock(Lock.class)));

        assertThat(leaderElectionService.isLeader()).isFalse();

        leaderElectionService.startAsync().awaitRunning();

        // wait until the service executed the run loop at least 2 times
        verify(lockService, timeout(10_000).atLeast(2)).lock(any(), isNull());

        assertThat(leaderElectionService.isLeader()).isTrue();
    }