### Question:
EmbeddedHaServices extends AbstractNonHaServices { @Override public LeaderElectionService getJobManagerLeaderElectionService(JobID jobID) { checkNotNull(jobID); synchronized (lock) { checkNotShutdown(); EmbeddedLeaderService service = getOrCreateJobManagerService(jobID); return service.createLeaderElectionService(); } } EmbeddedHaServices(Executor executor); @Override LeaderRetrievalService getResourceManagerLeaderRetriever(); @Override LeaderRetrievalService getDispatcherLeaderRetriever(); @Override LeaderElectionService getResourceManagerLeaderElectionService(); @Override LeaderElectionService getDispatcherLeaderElectionService(); @Override LeaderRetrievalService getJobManagerLeaderRetriever(JobID jobID); @Override LeaderRetrievalService getJobManagerLeaderRetriever(JobID jobID, String defaultJobManagerAddress); @Override LeaderRetrievalService getWebMonitorLeaderRetriever(); @Override LeaderElectionService getJobManagerLeaderElectionService(JobID jobID); @Override LeaderElectionService getWebMonitorLeaderElectionService(); @Override void close();  }### Answer:
@Test public void testJobManagerLeaderElection() throws Exception { JobID jobId1 = new JobID(); JobID jobId2 = new JobID(); LeaderContender leaderContender1 = mock(LeaderContender.class); LeaderContender leaderContender2 = mock(LeaderContender.class); LeaderContender leaderContenderDifferentJobId = mock(LeaderContender.class); LeaderElectionService leaderElectionService1 = embeddedHaServices.getJobManagerLeaderElectionService(jobId1); LeaderElectionService leaderElectionService2 = embeddedHaServices.getJobManagerLeaderElectionService(jobId1); LeaderElectionService leaderElectionServiceDifferentJobId = embeddedHaServices.getJobManagerLeaderElectionService(jobId2); leaderElectionService1.start(leaderContender1); leaderElectionService2.start(leaderContender2); leaderElectionServiceDifferentJobId.start(leaderContenderDifferentJobId); ArgumentCaptor<UUID> leaderIdArgumentCaptor1 = ArgumentCaptor.forClass(UUID.class); ArgumentCaptor<UUID> leaderIdArgumentCaptor2 = ArgumentCaptor.forClass(UUID.class); verify(leaderContender1, atLeast(0)).grantLeadership(leaderIdArgumentCaptor1.capture()); verify(leaderContender2, atLeast(0)).grantLeadership(leaderIdArgumentCaptor2.capture()); assertTrue(leaderIdArgumentCaptor1.getAllValues().isEmpty() ^ leaderIdArgumentCaptor2.getAllValues().isEmpty()); verify(leaderContenderDifferentJobId).grantLeadership(any(UUID.class)); }