LeaderService { public boolean isLeader() { return !JobRegistry.getInstance().isShutdown(jobName) && JobRegistry.getInstance().getJobInstance(jobName).getJobInstanceId().equals(jobNodeStorage.getJobNodeData(LeaderNode.INSTANCE)); } LeaderService(final CoordinatorRegistryCenter regCenter, final String jobName); void electLeader(); boolean isLeaderUntilBlock(); boolean isLeader(); boolean hasLeader(); void removeLeader();  }
@Test public void assertIsLeader() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(jobNodeStorage.getJobNodeData("leader/election/instance")).thenReturn("127.0.0.1@-@0"); assertTrue(leaderService.isLeader()); JobRegistry.getInstance().shutdown("test_job"); }