GuaranteeService { public boolean isAllStarted() { return jobNodeStorage.isJobNodeExisted(GuaranteeNode.STARTED_ROOT) && configService.getShardingTotalCount() == jobNodeStorage.getJobNodeChildrenKeys(GuaranteeNode.STARTED_ROOT).size(); } GuaranteeService(final CoordinatorRegistryCenter coordinatorRegistryCenter, final JobConfiguration jobConfiguration); void registerStart(final Collection<Integer> shardingItems); boolean isAllStarted(); void clearAllStartedInfo(); void registerComplete(final Collection<Integer> shardingItems); boolean isAllCompleted(); void clearAllCompletedInfo();  }
@Test public void testIsNotAllStartedWhenRootNodeIsNotExisted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(false); assertFalse(guaranteeService.isAllStarted()); }
@Test public void testIsNotAllStarted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true); when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/started")).thenReturn(Arrays.asList("0", "1")); assertFalse(guaranteeService.isAllStarted()); }
@Test public void testIsAllStarted() { when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true); when(configService.getShardingTotalCount()).thenReturn(3); when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/started")).thenReturn(Arrays.asList("0", "1", "2")); assertTrue(guaranteeService.isAllStarted()); }