GuaranteeService { public boolean isAllStarted() { return jobNodeStorage.isJobNodeExisted(GuaranteeNode.STARTED_ROOT) && configService.load(false).getShardingTotalCount() == jobNodeStorage.getJobNodeChildrenKeys(GuaranteeNode.STARTED_ROOT).size(); } GuaranteeService(final CoordinatorRegistryCenter regCenter, final String jobName); void registerStart(final Collection<Integer> shardingItems); boolean isRegisterStartSuccess(final Collection<Integer> shardingItems); boolean isAllStarted(); void clearAllStartedInfo(); void registerComplete(final Collection<Integer> shardingItems); boolean isRegisterCompleteSuccess(final Collection<Integer> shardingItems); boolean isAllCompleted(); void clearAllCompletedInfo();  }
@Test public void assertIsNotAllStartedWhenRootNodeIsNotExisted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(false); assertFalse(guaranteeService.isAllStarted()); }
@Test public void assertIsNotAllStarted() { when(configService.load(false)).thenReturn( JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").setProperty("streaming.process", Boolean.TRUE.toString()).build()); when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true); when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/started")).thenReturn(Arrays.asList("0", "1")); assertFalse(guaranteeService.isAllStarted()); }
@Test public void assertIsAllStarted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true); when(configService.load(false)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build()); when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/started")).thenReturn(Arrays.asList("0", "1", "2")); assertTrue(guaranteeService.isAllStarted()); }